Use CheapLLM with LangChain
Point LangChain.js (or Python langchain-openai) ChatOpenAI at the CheapLLM OpenAI-compatible gateway.
1. Install the packages
Install @langchain/openai and @langchain/core in your JavaScript/TypeScript project (or pip install langchain-openai in Python).
Terminal
pnpm add @langchain/openai @langchain/core
2. Provide the API key
Export CHEAPLLM_API_KEY in your runtime environment before starting the app so secrets never appear in source control.
Bash or Zsh
export CHEAPLLM_API_KEY="sk-clm-YOUR_API_KEY"
3. Configure ChatOpenAI
Pass any CheapLLM model ID (such as claude-opus-5-5, gpt-6.2-sol, or deepseek-v4.1-flash-1017), your key, and https://api.cheapllm.app/v1 under configuration.baseURL.
model.ts
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
model: "claude-opus-5-5",
apiKey: process.env.CHEAPLLM_API_KEY,
configuration: {
baseURL: "https://api.cheapllm.app/v1",
},
});
4. Send a request
Invoke the model with model.invoke() or bind tools as usual. ChatOpenAI routes standard Chat Completions requests through CheapLLM with full streaming and tool-calling support.
model.ts
const answer = await model.invoke("Explain in one sentence what an API is.");
console.log(answer.content);
Top models to run in LangChain
All 49+ models →| Model | Official (in / out) | CheapLLM (in / out) | Savings |
|---|---|---|---|
| Claude Opus 5.5 | $2.80 / $14.00 | −30% | |
| GPT-6.1 Sol | $1.40 / $7.00 | −30% | |
| Gemini 4 Argon | $1.40 / $7.00 | −30% | |
| DeepSeek V4 Pro 0813 | $0.078 / $3.11 | −30% |