ChatOpenAI class accepts a custom base_url, making Meliai a drop-in provider for any LangChain application. You keep every chain, agent, tool, and memory component exactly as-is — only the endpoint and API key change. Your data stays within the EU on every call.
1
Install LangChain
Install the
langchain-openai package, which provides the ChatOpenAI and OpenAIEmbeddings classes used throughout this guide.2
Configure ChatOpenAI with Meliai
Pass your Meliai API key and base URL when instantiating
ChatOpenAI. Everything else — temperature, streaming, callbacks — works the same way.3
Use in a chain
Compose your
ChatOpenAI instance with prompts and other runnables using LangChain Expression Language (LCEL). No changes are needed compared to a standard OpenAI setup.4
Use embeddings
OpenAIEmbeddings accepts the same base_url parameter, giving you Meliai-hosted embedding models for vector search, RAG pipelines, and semantic similarity tasks.