Run the EveryAPI gateway inside LangChain
Use EveryAPI with LangChain’s OpenAI-compatible client by setting its base URL and API key. Model and feature compatibility depends on the selected model and the request shape.
One base URL line points LangChain at EveryAPI
Default global Base URL / China-first Base URL: https://api.everyapi.ai/v1 / https://api-cn.everyapi.ai/v1
from langchain_openai import ChatOpenAI llm = ChatOpenAI( base_url="https://api.everyapi.ai/v1", api_key="sk-everyapi-...", model="claude-sonnet-5", # can also be gpt-5.5 / gemini-3.1-pro-low etc.) response = llm.invoke("Explain the PageRank algorithm in three sentences")print(response.content)From zero to your first call
- Install langchain-openai
pip install langchain langchain-openai or npm install @langchain/openai. EveryAPI needs no dedicated LangChain provider — just reuse the official OpenAI provider and change base_url.
- Generate an API key in the EveryAPI dashboard
Sign in at app.everyapi.ai → API Keys → New Key. Copy the string that starts with sk-everyapi-.
- Pass two parameters when initializing ChatOpenAI
Set base_url to https://api.everyapi.ai/v1 and api_key to your EveryAPI key. Set the model field to the real upstream model name (claude-sonnet-5 / gpt-5.5 / gemini-3.1-pro-low / MiniMax-M3 etc.).
- LCEL / Agent / tool calling all stay the same
Chains, agents, tools, and streaming still use LangChain’s normal interfaces. Test each model’s tool and streaming behavior because capabilities can differ.
LangChain × EveryAPI
Is function / tool calling behavior consistent across upstreams?
EveryAPI translates supported protocol fields when required, but models differ in tool support and behavior. Validate your tool schema and expected responses with the exact model used in production.
Is streaming supported?
The gateway supports streaming on compatible endpoints and models. Stream event shapes and failure behavior can vary, so test the selected model with your LangChain version.