Use LangChain with OAIRoute
LangChain binds to a model through a provider class. Keep ChatOpenAI, change base_url — every chain, tool and callback above it stays as it is.
Configuration
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-opus-5",
api_key="YOUR_OAIROUTE_KEY",
base_url="https://api.oairoute.com/v1",
)
# Every LangChain chain, agent and tool works unchanged —
# swap the model string to route to a different provider.
print(llm.invoke("Explain API routing.").content)Why route it through OAIRoute
One integration, any vendor
Model choice becomes a string. Evaluating Claude against GPT on the same agent is a config change, not a rewrite.
Works with the rest of the ecosystem
LlamaIndex, the Vercel AI SDK and any OpenAI-compatible client hit the same endpoint the same way.
Spend visible per key
Give each agent or experiment its own key and the gateway reports cost per key rather than per process.
Setup
- 1
Create a key
Register at api.oairoute.com and create a key on the token page.
- 2
Point the client at the gateway
Pass base_url and api_key to ChatOpenAI, or set OPENAI_BASE_URL in the environment.
- 3
Verify
Invoke the model once and check the response comes back through the gateway.
Models worth trying
| Model ID | Name | Use it for | USD per 1M in / out |
|---|---|---|---|
claude-opus-5-5 | Claude Opus 5.5 | Best all-round agent reasoning. | $0.20 / $1.00 |
gpt-6-astra | GPT-6-Astra | Long-context planning, 1.1M tokens. | $0.50 / $2.50 |
glm-5.3-flash | GLM-5.3 Flash | Cheap executor step in multi-agent graphs. | $0.036 / $0.126 |
Prices are per million tokens, input / output, at the rates published in the model catalogue.
Questions
Do I need a custom LangChain integration?
No. ChatOpenAI plus a base_url is enough — the gateway speaks the OpenAI schema.
Does streaming work?
Yes, including tool calls and structured outputs, since those travel through the same schema.
How do I compare two models on one agent?
Instantiate the same chain twice with different model strings; everything above the model is reused.