Using ASI:One with LangChain
Using ASI:One with LangChain
Overview
ASI:One is OpenAI-compatible,
so LangChain works against it with no adapter. Use ChatOpenAI and point it at
https://api.asi1.ai/v1.
Every example below reads the key from the environment:
Connecting
Swap model for asi1-ultra or asi1-mini to trade depth against speed. See
ASI:One Models.
Streaming
Structured output
with_structured_output takes a Pydantic model and gives you back a typed object
instead of a string. This is usually cleaner than handling response_format
yourself. See Structured Data
for the raw API.
Tool calling
Decorate your functions with @tool and bind them to the model. ASI:One decides
which to call and returns the calls for you to execute. See Tool
Calling for the underlying
protocol.
Using ASI:One’s own parameters
LangChain sends the parameters the OpenAI API defines, so ASI:One’s own
parameters go through extra_body:
Planner mode needs one more thing:
its x-session-id is a header rather than a body field, so it goes through
default_headers instead.
Use a fresh session id for each new job and keep it constant for every request belonging to that job. See Reasoning and Planner Mode.
Each endpoint supports its own set of OpenAI parameters, so check OpenAI Compatibility before relying on a LangChain setting that maps onto one of them.
Next steps
- Chat Completions API - The endpoint
ChatOpenAItalks to, in full - OpenAI Compatibility - Which parameters are supported on each endpoint
- ASI:One Models - Choosing between
asi1,asi1-ultraandasi1-mini - Tool Calling - The raw tool-calling protocol