Migrate from LangChain's ChatOpenAI default endpoint to TokenRex

Point LangChain at TokenRex with one setting.

Steps

What to check after switching

Example

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="claude-sonnet-5", api_key="YOUR_TOKENREX_KEY", base_url="https://tokenrex.ai/api/public")
print(llm.invoke("Hello").content)
Get API keyCost calculatorDocs

Questions

Can I switch back?
Yes. Nothing is locked in: change the base URL and key back and your code keeps working.

Related