integrations/framework/LangChain
LC

LangChain + AIgateway

ChatOpenAI + AIgateway base URL = every model, zero new code.

LangChain's ChatOpenAI class accepts a custom base URL. With AIgateway in front, every chain, agent, retriever, and tool that LangChain supports works against any of our 100+ models.

LangChain homepage →
Setup

Three steps or fewer.

STEP 01

Python

Drop in ChatOpenAI with the AIgateway base URL.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="anthropic/claude-opus-4.7",
    base_url="https://api.aigateway.sh/v1",
    api_key="sk-aig-...",
)
print(llm.invoke("hello").content)
STEP 02

JavaScript

Same shape on the JS side via @langchain/openai.

import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "moonshot/kimi-k2.6",
  configuration: { baseURL: "https://api.aigateway.sh/v1" },
  apiKey: process.env.AIGATEWAY_API_KEY,
});
More integrations

Same key. Every other tool.