All posts
LangChain + TokenRex — setup in 3 lines
Guides 4 min read· Aug 5, 2026· By Guides

LangChain + TokenRex — setup in 3 lines

How to point LangChain's ChatOpenAI class at TokenRex.

LangChain's ChatOpenAI takes a base_url. That's the whole setup.

python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="openai/gpt-5.4-mini",
    api_key="sk-tb-...",
    base_url="https://tokenrex.ai/api/public",
)
All LangChain chains, tools, and agents work unchanged — LangChain doesn't know or care about the endpoint.

Ready to build?

Grab a key, keep your OpenAI SDK, and pay only for what you use.

Start free