NewEco lane now on 91 models: the same model at a lower price

Currency

You always top up in euro. Other currencies are shown at today's ECB rate. ECB reference rates

Sign inGet started

Docsv1

Docs menuLangChain

LangChain

Use Nexrouting models in LangChain for Python and JavaScript through the OpenAI integration.

LangChain's OpenAI integration works with Nexrouting. Set the base URL to https://api.nexrouting.com/v1, use your Nexrouting key, and pass any chat model ID, from any provider.

Python

Shell
pip install langchain-openai
Python
import osfrom langchain_openai import ChatOpenAI llm = ChatOpenAI(    model="anthropic/claude-sonnet-5.5",    base_url="https://api.nexrouting.com/v1",    api_key=os.environ["NEXROUTING_API_KEY"],)print(llm.invoke("Hello").content)

JavaScript

Shell
npm install @langchain/openai
Node
import { ChatOpenAI } from "@langchain/openai"; const llm = new ChatOpenAI({  model: "openai/gpt-6-astra",  apiKey: process.env.NEXROUTING_API_KEY,  configuration: { baseURL: "https://api.nexrouting.com/v1" },});const reply = await llm.invoke("Hello");console.log(reply.content);

Embeddings

Turn off check_embedding_ctx_length, so LangChain sends plain text instead of token IDs counted with an OpenAI tokenizer.

Python
import osfrom langchain_openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings(    model="openai/text-embedding-3-small",    base_url="https://api.nexrouting.com/v1",    api_key=os.environ["NEXROUTING_API_KEY"],    check_embedding_ctx_length=False,)vector = embeddings.embed_query("Hello")

Streaming, tool calling and structured output work as with OpenAI, for models that support them.