How do I use LiteLLM with Claude Code?
Run the LiteLLM proxy with a config.yaml that lists your models, then point ANTHROPIC_BASE_URL at it with a LiteLLM virtual key; LiteLLM adds no token fee, so you pay each provider's list price.
# Each model_name is what Claude Code asks for
model_list:
- model_name: claude-sonnet-5-5
litellm_params:
model: anthropic/claude-sonnet-5-5
api_key: os.environ/ANTHROPIC_API_KEY
- model_name: gpt-6-luna
litellm_params:
model: openai/gpt-6-luna
api_key: os.environ/OPENAI_API_KEY
Shell exports last for one terminal; put the same values in the env block of ~/.claude/settings.json to keep them. Run /status in Claude Code to check the base URL.
Gotchas in LiteLLM's own docs
| Issue | What happens | What to do |
|---|---|---|
| /model picker | It lists Anthropic's own IDs; choosing one fails with Invalid model name passed in | Name your models in config.yaml and set ANTHROPIC_MODEL, or turn on gateway model discovery |
| ANTHROPIC_API_KEY set | It overrides the virtual key | Unset it |
| Key limited to some models | Other models return 403 The requested model is not available for this API key | Add the model to the key, or pick an allowed one |
| Budgets | On a deployment without a database, budgets cap nothing | Run LiteLLM with Postgres before you rely on max_budget |
| Claude Pro or Max | Since v1.81.14 LiteLLM forwards the subscription token; your virtual key goes in x-litellm-api-key | Budgets then count at API list prices, as usage caps in API-equivalent dollars |
| Non-Anthropic models | Any provider in your model_list works through the Messages format | Test tool calls on a real task; quality varies by model |
From docs.litellm.ai Claude Code pages, checked October 13, 2026.
What a request costs through LiteLLM
LiteLLM's beta complexity router can send easy requests to a cheap model, but you assign each tier's model yourself and keep the mapping current as models change.
The catch
Anthropic does not support Claude Code through third-party gateways, and its docs warn that a gateway that does not forward new features can break them after an update. With LiteLLM that update is yours to test, because you also upgrade the proxy.
Where Standard Compute fits
Nothing to host: point the same variables at api.stdcmpt.com and keep Claude Code's own model names, and smart routing picks a model per request, sending routine steps to efficient models. A flat plan from $19 includes the compute and stops at its budget. If you already run LiteLLM, add Standard Compute to its model_list as an OpenAI-compatible provider instead.
FAQ
What base URL does Claude Code use with LiteLLM?
Your proxy's address with no /v1, for example http://localhost:4000. Claude Code adds /v1/messages itself, and LiteLLM serves the Anthropic Messages format there.
Can I use my Claude Max subscription through LiteLLM?
Yes, since v1.81.14. LiteLLM forwards Claude Code's subscription token to Anthropic and reads your virtual key from the x-litellm-api-key header, so you keep budgets and logs. It applies to Pro, Max, Team and Enterprise plans.
Can Claude Code use GPT or Gemini through LiteLLM?
Yes. Add the model to your model_list and set ANTHROPIC_MODEL to its model_name; LiteLLM translates the Messages request for the provider.
Does LiteLLM work with Codex CLI?
Yes. LiteLLM serves the Responses API at /v1/responses; set wire_api = "responses" and base_url to your proxy's /v1 address.