Skip to main content
LangChain’s ChatOpenAI and OpenAI classes accept a custom openai_api_base (Python) or configuration.baseURL (JavaScript), which means you can point them at Portrix without any custom integrations or provider plugins. Your LangChain chains, agents, and pipelines gain access to every model on the platform — swapping providers becomes a one-line change.

Python (LangChain)

Installation

Basic chat model

Configure ChatOpenAI with Portrix’s base URL and your Portrix API key. Use the model_name parameter to specify any model available on Portrix:

Simple chain

Build a prompt-model-parser chain using LangChain’s pipe syntax:

JavaScript (LangChain.js)

Installation

Basic chat model

Using different models

Because changing models is a single property update, you can use different providers at different steps of a pipeline — for example, a fast cheap model for classification and a more powerful model for generation:

LangChain agents with Portrix

Use ChatOpenAI pointed at Portrix as the backbone for a LangChain tool-calling agent. Portrix normalises function/tool call responses across providers:
The model_name parameter (Python) and model parameter (JavaScript) must use Portrix’s provider/model format — for example, "openai/gpt-4o" or "anthropic/claude-3-5-sonnet". Passing OpenAI’s native format (e.g. "gpt-4o") will result in a model-not-found error.
Store your base config (API key and base URL) in a shared dictionary or factory function so you can instantiate multiple ChatOpenAI objects without repeating yourself. This makes it easy to switch all your chains to a different provider by updating one variable.