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.
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)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,
});