Claude Code Integration
Use GPT-5, Gemini, or any model with Claude Code. Three environment variables, full cost tracking.
Claude Code is locked to Anthropic's API by default. With LLM Gateway, you can point it at any model—GPT-5, Gemini, Llama, or 180+ others—while keeping the same Anthropic API format Claude Code expects.
Three environment variables. No code changes. Full cost tracking in your dashboard.
Using DevPass? This integration also works with a DevPass plan key. Use root model IDs without a provider prefix (
claude-sonnet-4-5, notanthropic/claude-sonnet-4-5) — provider-pinned routing is not available on coding plans; the gateway picks the provider for you.
Video Tutorial
Set up Claude Code with LLM Gateway in under 2 minutes:
Quick Start
Configure Claude Code to use LLM Gateway with these environment variables:
1export ANTHROPIC_BASE_URL=https://api.llmgateway.io2export ANTHROPIC_AUTH_TOKEN=llmgtwy_your_api_key_here3# optional: specify a model, otherwise it uses the default Claude model4export ANTHROPIC_MODEL=gpt-5 # or any model from our catalog5
6# now run claude!7claude1export ANTHROPIC_BASE_URL=https://api.llmgateway.io2export ANTHROPIC_AUTH_TOKEN=llmgtwy_your_api_key_here3# optional: specify a model, otherwise it uses the default Claude model4export ANTHROPIC_MODEL=gpt-5 # or any model from our catalog5
6# now run claude!7claudeWhy This Works
LLM Gateway's /v1/messages endpoint speaks Anthropic's API format natively. We handle the translation to each provider behind the scenes. This means:
- Use any model — GPT-5, Gemini, Llama, or Claude itself
- Keep your workflow — Claude Code doesn't know the difference
- Track costs — Every request appears in your LLM Gateway dashboard
- Automatic caching — Repeated requests hit cache, saving money
Choosing Models
You can use any model from the models page. Popular options for Claude Code include:
Use OpenAI's Latest Models
1# Use the latest GPT model2export ANTHROPIC_MODEL=gpt-53
4# Use a cost-effective alternative5export ANTHROPIC_MODEL=gpt-5-mini1# Use the latest GPT model2export ANTHROPIC_MODEL=gpt-53
4# Use a cost-effective alternative5export ANTHROPIC_MODEL=gpt-5-miniUse Google's Gemini
1export ANTHROPIC_MODEL=gemini-3.1-pro-preview1export ANTHROPIC_MODEL=gemini-3.1-pro-previewUse Anthropic's Claude Models
1export ANTHROPIC_MODEL=anthropic/claude-3-5-sonnet-202410221export ANTHROPIC_MODEL=anthropic/claude-3-5-sonnet-20241022Predefining Models in a Settings File
Environment variables are read once at startup, so changing ANTHROPIC_MODEL means restarting Claude Code. To switch models mid-session instead, put the configuration in ~/.claude/settings.json (user-wide) or .claude/settings.json (per project) and use /model to switch on the fly:
1{2 "env": {3 "ANTHROPIC_BASE_URL": "https://api.llmgateway.io",4 "ANTHROPIC_AUTH_TOKEN": "llmgtwy_your_api_key_here"5 },6 "model": "claude-sonnet-5"7}1{2 "env": {3 "ANTHROPIC_BASE_URL": "https://api.llmgateway.io",4 "ANTHROPIC_AUTH_TOKEN": "llmgtwy_your_api_key_here"5 },6 "model": "claude-sonnet-5"7}model sets the model a new session starts on. /model overrides it for the running session and saves your choice as the new default.
Restricting the Model List
availableModels limits which models the /model picker offers — useful for keeping a team on an approved, budget-appropriate set:
1{2 "availableModels": ["claude-sonnet-5", "claude-haiku-4-5"],3 "fallbackModel": ["claude-haiku-4-5"]4}1{2 "availableModels": ["claude-sonnet-5", "claude-haiku-4-5"],3 "fallbackModel": ["claude-haiku-4-5"]4}fallbackModel names the models to try when the primary one is unavailable, capped at three.
availableModels only filters the rows Claude Code already has — it never creates new ones. To put a non-Claude model in the picker, see Adding Non-Claude Models to the Picker below.
Fetching Models From LLM Gateway
Claude Code can populate its /model picker directly from our catalog instead of you hardcoding IDs. Set the discovery flag alongside the base URL:
1export ANTHROPIC_BASE_URL=https://api.llmgateway.io2export ANTHROPIC_AUTH_TOKEN=llmgtwy_your_api_key_here3export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=11export ANTHROPIC_BASE_URL=https://api.llmgateway.io2export ANTHROPIC_AUTH_TOKEN=llmgtwy_your_api_key_here3export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1On startup Claude Code calls our /v1/models endpoint and adds what it returns to the picker, labeled From gateway. Entries are cached in ~/.claude/cache/gateway-models.json and refreshed on each launch, so a failed lookup falls back to the previous list rather than breaking your session. Requires Claude Code v2.1.129 or later.
The LLM Gateway CLI can apply this whole setup (base URL, auth token, and the discovery flag) to your ~/.claude/settings.json in one command:
1npx @llmgateway/cli configure claude1npx @llmgateway/cli configure claudeHeads up: Claude Code drops discovered models whose ID does not start with
claudeoranthropic, before they ever reach the picker — the cache it writes to~/.claude/cache/gateway-models.jsoncontains only the surviving entries. Discovery therefore surfaces just the Claude models in our catalog. GPT-5, Gemini, and custom models are filtered out by the client, not by the gateway.
Adding Non-Claude Models to the Picker
The /model picker is a Claude-model list. Its own header says so: "Switch between Claude models… For other/previous model names, specify with --model." Neither gateway discovery nor availableModels adds a non-Claude row — availableModels filters the rows Claude Code already has rather than creating new ones.
ANTHROPIC_CUSTOM_MODEL_OPTION is the one setting that adds a non-Claude row:
1export ANTHROPIC_CUSTOM_MODEL_OPTION=gemini-3.5-flash2export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="Gemini 3.5 Flash"3export ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION="Routed through LLM Gateway"1export ANTHROPIC_CUSTOM_MODEL_OPTION=gemini-3.5-flash2export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="Gemini 3.5 Flash"3export ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION="Routed through LLM Gateway"The entry appears at the bottom of the picker under your chosen name. Only one is supported at a time, so it suits a single alternate model rather than a menu. If you also set availableModels, include this ID there or it will be filtered back out.
Selecting Any Other Model
For everything else — including custom models — name the model directly. These paths accept any ID our gateway routes, with no picker row involved:
1export ANTHROPIC_MODEL=gemini-3.5-flash # session default2claude --model gemini-3.5-flash # single session1export ANTHROPIC_MODEL=gemini-3.5-flash # session default2claude --model gemini-3.5-flash # single sessionTo rotate between several non-Claude models, keep a per-project .claude/settings.json with the model you want for that repo.
Environment Variables
When configuring Claude Code, you can use these environment variables:
ANTHROPIC_MODEL
Specifies the main model to use for primary requests.
1export ANTHROPIC_MODEL=gpt-51export ANTHROPIC_MODEL=gpt-5Complete Configuration Example
1export ANTHROPIC_BASE_URL=https://api.llmgateway.io2export ANTHROPIC_AUTH_TOKEN=llmgtwy_your_api_key_here3export ANTHROPIC_MODEL=gpt-54export ANTHROPIC_SMALL_FAST_MODEL=gpt-5-nano1export ANTHROPIC_BASE_URL=https://api.llmgateway.io2export ANTHROPIC_AUTH_TOKEN=llmgtwy_your_api_key_here3export ANTHROPIC_MODEL=gpt-54export ANTHROPIC_SMALL_FAST_MODEL=gpt-5-nanoMaking Manual API Requests
If you want to test the endpoint directly, you can make manual requests:
1curl -X POST "https://api.llmgateway.io/v1/messages" \2 -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "gpt-5",6 "messages": [7 {"role": "user", "content": "Hello, how are you?"}8 ],9 "max_tokens": 10010 }'1curl -X POST "https://api.llmgateway.io/v1/messages" \2 -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "gpt-5",6 "messages": [7 {"role": "user", "content": "Hello, how are you?"}8 ],9 "max_tokens": 10010 }'Response Format
The endpoint returns responses in Anthropic's message format:
1{2 "id": "msg_abc123",3 "type": "message",4 "role": "assistant",5 "model": "gpt-5",6 "content": [7 {8 "type": "text",9 "text": "Hello! I'm doing well, thank you for asking. How can I help you today?"10 }11 ],12 "stop_reason": "end_turn",13 "stop_sequence": null,14 "usage": {15 "input_tokens": 13,16 "output_tokens": 2017 }18}1{2 "id": "msg_abc123",3 "type": "message",4 "role": "assistant",5 "model": "gpt-5",6 "content": [7 {8 "type": "text",9 "text": "Hello! I'm doing well, thank you for asking. How can I help you today?"10 }11 ],12 "stop_reason": "end_turn",13 "stop_sequence": null,14 "usage": {15 "input_tokens": 13,16 "output_tokens": 2017 }18}What You Get
- Any model in Claude Code — GPT-5 for heavy lifting, GPT-4o Mini for routine tasks
- Cost visibility — See exactly what each coding session costs
- One bill — Stop managing separate accounts for OpenAI, Anthropic, Google
- Response caching — Repeated requests (like linting the same file) hit cache
- Discounts — Check discounted models for savings up to 90%
Get Started
- Sign up free — no credit card required
- Copy your API key from the dashboard
- Set the environment variables above, or drop them into
~/.claude/settings.json - Run
claudeand start coding — switch models any time with/model
Questions? Check our docs or join Discord.