Skip to content
Home

LangChain

LangChain can call OdiRouter through OpenAI-compatible chat model integrations. Set the API key, model, and Base URL on the ChatOpenAI client.

RequirementValue
Packagelangchain-openai or the OpenAI integration used by your LangChain version
Base URLhttps://www.odirouter.ai/v1
API KeyOdiRouter API key
ModelAn OdiRouter LLM model ID
Окно терминала
pip install langchain-openai
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-5.5",
api_key=os.environ["ODIROUTER_API_KEY"],
base_url="https://www.odirouter.ai/v1",
)
response = llm.invoke("Reply with a one-line LangChain integration test.")
print(response.content)
from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_messages([
("system", "You are a concise engineering assistant."),
("user", "{question}"),
])
chain = prompt | llm
result = chain.invoke({"question": "List two integration checks."})
print(result.content)
SymptomFix
LangChain calls OpenAI directlyConfirm base_url is set on the active ChatOpenAI instance
401 responseSet ODIROUTER_API_KEY in the process environment
Model not foundCopy the model ID from GET https://www.odirouter.ai/v1/models
Tool calling failsConfirm the selected OdiRouter model supports the tool-calling behavior your chain requires