ChatOpenAI from langchain-openai with base_url set to https://llm.modellix.ai/v1 — the same pattern as the OpenAI SDK.
This page covers LLM chat only (
https://llm.modellix.ai). Modellix model IDs are provider/name (for example openai/gpt-5.5). Pass that full string as model. See Models & Pricing.The LLM gateway does not document an embeddings API. For RAG, use Modellix for generation and a separate embeddings provider, or keep embeddings on another OpenAI-compatible host.Set Up LangChain
1
Install Packages
Python (recommended imports from TypeScript:
langchain-openai):2
Set Credentials
3
Create ChatOpenAI
Prefer constructor args so the base URL is explicit in code. Environment variables work as a fallback when you omit You can use the same
api_key / base_url.base_url with other Modellix catalog IDs (for example anthropic/claude-sonnet-5 or google/gemini-3.6-flash); traffic still goes through Chat Completions on https://llm.modellix.ai/v1.4
Optional: Streaming and Fallbacks
Streaming:Multi-model fallback on the same gateway:
5
Optional: ChatAnthropic (Messages)
For native Anthropic Messages instead of Chat Completions, use Most LangChain apps should stay on
langchain-anthropic with the same host shape as the Anthropic SDK (no /v1 on the base URL):ChatOpenAI + /v1 unless you specifically need the Messages protocol.Troubleshooting
Related
- LangChain OpenAI-compatible providers —
ChatOpenAI+base_url - OpenAI SDK — same
/v1gateway without LangChain - Anthropic SDK — Messages protocol used by
ChatAnthropic - Models & Pricing — Model IDs and rates
- LLM API guide — protocols and curl examples
- Chat Completions — OpenAPI reference