Integrations

LangChain (Python)

ChatOpenAI from the langchain-openai package. Step-by-step setup with Laras Router.

On this page

This guide connects LangChain (Python) to Laras Router. Every step was checked against the LangChain (Python) documentation.

You need an API key (lr_live_…) and a topped-up balance. New to Laras Router? Start with the Quickstart.

Set up

Install the package

Install the integration package.

Shell
pip install -U langchain-openai

Set your API key

Put your key in an environment variable.

Shell
export LARAS_API_KEY="lr_live_your_key_here"

Create the model

Create ChatOpenAI with the Laras Router base URL.

Python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-flash",
    base_url="https://api.larasrouter.com/v1",
    api_key=os.environ["LARAS_API_KEY"],
    use_responses_api=False,
)

message = llm.invoke("Hello!")
print(message.text)

Good to know

  • use_responses_api=False keeps ChatOpenAI on Chat Completions. Some parameters and built-in tools otherwise switch it to the Responses API, which Laras Router does not implement.
  • LangChain documents that ChatOpenAI follows the official OpenAI specification and does not keep non-standard response fields such as reasoning_content.

Settings and screens can change between versions. If something looks different, check the LangChain (Python) documentation. For other tools, see all integrations.