Reference
SDK recipes
Runnable templates for each supported SDK. Drop the gateway base URL into an existing project, set one env var, run the snippet. The response carries the gateway's X-Request-Id header so you can correlate any result back to the routing decision in your dashboard.
OpenAI · Python
Drop-in OpenAI(base_url=...) swap with X-Request-Id correlation.
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.fairmeter.in/v1",
api_key="gw_live_xxxxxxxx",
)
resp = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Summarise this contract."}],
)
print(resp.id, resp.model)OpenAI · Node
TypeScript client config with the gateway base URL plus retry config.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://gateway.fairmeter.in/v1",
apiKey: process.env.FAIRMETER_API_KEY,
maxRetries: 2,
});
const resp = await client.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "Summarise this contract." }],
});Anthropic · Python
Anthropic SDK with base_url swap; pinned claude-haiku-4-5.
from anthropic import Anthropic
client = Anthropic(
base_url="https://gateway.fairmeter.in",
api_key="gw_live_xxxxxxxx",
)
message = client.messages.create(
model="claude-haiku-4-5",
max_tokens=256,
messages=[{"role": "user", "content": "Say hi."}],
)Anthropic · Node
@anthropic-ai/sdk config with the gateway origin and Haiku pin.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://gateway.fairmeter.in",
apiKey: process.env.FAIRMETER_API_KEY,
});
const message = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 256,
messages: [{ role: "user", content: "Say hi." }],
});curl
Two-flag swap: Authorization: Bearer plus the gateway origin.
curl https://gateway.fairmeter.in/v1/chat/completions \
-H "Authorization: Bearer gw_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"model":"auto","messages":[{"role":"user","content":"hi"}]}'LangChain · Python
ChatOpenAI and ChatAnthropic configured against the gateway.
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
llm = ChatOpenAI(
base_url="https://gateway.fairmeter.in/v1",
api_key="gw_live_xxxxxxxx",
model="auto",
)
claude = ChatAnthropic(
anthropic_api_url="https://gateway.fairmeter.in",
anthropic_api_key="gw_live_xxxxxxxx",
model="claude-haiku-4-5",
)Cursor
OpenAI Base URL Override field in Cursor’s Models settings panel.
Open Cursor Settings → Models → OpenAI API Key, set the key to your gw_live_ token, and set “OpenAI Base URL” (under Override) to https://gateway.fairmeter.in/v1. Cursor’s own model picker keeps working; every request now routes through the gateway, and a concrete model id sent by Cursor triggers the family lock described in Routing.
Codex CLI
Custom model_provider in ~/.codex/config.toml pointed at the gateway.
# ~/.codex/config.toml [model_providers.fairmeter] name = "Fairmeter" base_url = "https://gateway.fairmeter.in/v1" env_key = "FAIRMETER_API_KEY" model_provider = "fairmeter" model = "auto"
Claude Code
ANTHROPIC_BASE_URL plus ANTHROPIC_AUTH_TOKEN; family-lock keeps Anthropic.
export ANTHROPIC_BASE_URL="https://gateway.fairmeter.in" export ANTHROPIC_AUTH_TOKEN="gw_live_xxxxxxxx" claude
Claude Code always sends a concrete Anthropic model id, so the family lock in Routing keeps every step of the session on the Anthropic ladder while still routing each step to the tier the classifier picks.
gw_live_ key from /keys and the response carries an X-Request-Id header you can look up at /requests/<id>.