Use OpenLux with LangChain and LangGraph
LangChain's OpenAI integrations accept a base_url, which makes OpenLux a drop-in upgrade: keep ChatOpenAI, swap the model name to change provider, and run every chain, tool and embedding on one key and one bill.

Set it up in four steps
Install the integration
pip install langchain-openai, plus langchain and langgraph for chains and agents.
Point ChatOpenAI at OpenLux
Instantiate ChatOpenAI with your OpenLux key, the base URL https://openlux.lol/v1 and any catalogue model name.
Keep building as usual
Streaming, structured output, bind_tools and LangGraph agents all work unchanged because the wire format is the OpenAI API LangChain already targets.
Route models per step
Bind different models to different chains or graph nodes — a cheap tier for extraction, a flagship for reasoning — and see every request on one invoice.
Configuration
Copy these blocks, replace the placeholder key and you are done.
Python
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-6-astra",
api_key="sk-openlux-...",
base_url="https://openlux.lol/v1",
temperature=0.2,
)
print(llm.invoke("Explain OpenLux in one sentence.").content)Streaming and a cheaper tier
for chunk in llm.stream("Write a haiku about APIs."):
print(chunk.content, end="")
budget = ChatOpenAI(
model="gemini-3-flash-preview",
api_key="sk-openlux-...",
base_url="https://openlux.lol/v1",
)Models that fit LangChain
GPT-6 Astra
OpenAI · $0.3677 / 1M tokens
Gemini 3 Flash (preview)
Google · $0.0368 / 1M tokens
BGE-M3
AIGC · $0.0035 / 1M tokens
Claude Sonnet 4.5
Anthropic · $0.2647 / 1M tokens
The full list is in the model catalogue and the use-case collections.
LangChain + OpenLux questions
Does LangChain need a custom integration for OpenLux?
No. OpenLux is OpenAI-compatible, so langchain-openai's ChatOpenAI, OpenAIEmbeddings and related classes work as soon as base_url points at the gateway.
Do tools and agents work the same way?
Yes. Models tagged Tools in the catalogue support bind_tools and tool-calling agents, and the request and response shapes match the OpenAI API LangChain already speaks.
Can I use OpenLux embeddings with LangChain?
BGE-M3 embeddings work through the OpenAI-compatible embeddings endpoint (OpenAIEmbeddings with model="bge-m3"), covering vector stores, retrievers and RAG chains.
How do I keep costs visible across a LangGraph app?
Every node calls the same base URL and key, so the console shows per-request cost for the whole graph, and moving a node to a cheaper model is a config change.
Connect LangChain to OpenLux today
One key covers every model in this guide and the rest of the catalogue, metered in USD with free trial credit to start.