Skip to content

LangChain Integration

LangChain supports custom model services through OpenAI-compatible client configuration.

from langchain_openai import ChatOpenAI
import os
llm = ChatOpenAI(
model="gpt-4o",
api_key=os.environ["ROUTEAPI_KEY"],
base_url="https://www.routeapi.ai/v1",
)
response = llm.invoke("Introduce RouteAPI in one sentence")
print(response.content)
  • Verify the model and Token with cURL first.
  • Then connect LangChain.
  • If you use tools or structured output, confirm that the selected model supports the capability.