Use Redline with LangChain

LangChain's ChatOpenAI takes a custom base_url. One flag matters: turn the Responses API off, or LangChain may call an endpoint Redline does not serve.

Python

# pip install -U langchain-openai
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek/deepseek-chat-v3.1",
    api_key="rl-...",
    base_url="https://redline-gateway.pages.dev/v1",
    use_responses_api=False,
)
print(llm.invoke("Hello").content)
Keep use_responses_api False With a custom base URL LangChain can switch to the Responses API, which returns 404 on Redline. Set use_responses_api=False. If streaming usage misbehaves, it is off by default on a custom base URL, which is fine.

JavaScript

// npm install @langchain/openai @langchain/core
import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "deepseek/deepseek-chat-v3.1",
  apiKey: process.env.REDLINE_API_KEY,
  configuration: { baseURL: "https://redline-gateway.pages.dev/v1" },
});
console.log((await llm.invoke("Hello")).content);

Related guides