Claude Code · Facts verified 2026-10-13

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.

config.yamlyour proxy
# 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

IssueWhat happensWhat to do
/model pickerIt lists Anthropic's own IDs; choosing one fails with Invalid model name passed inName your models in config.yaml and set ANTHROPIC_MODEL, or turn on gateway model discovery
ANTHROPIC_API_KEY setIt overrides the virtual keyUnset it
Key limited to some modelsOther models return 403 The requested model is not available for this API keyAdd the model to the key, or pick an allowed one
BudgetsOn a deployment without a database, budgets cap nothingRun LiteLLM with Postgres before you rely on max_budget
Claude Pro or MaxSince v1.81.14 LiteLLM forwards the subscription token; your virtual key goes in x-litellm-api-keyBudgets then count at API list prices, as usage caps in API-equivalent dollars
Non-Anthropic modelsAny provider in your model_list works through the Messages formatTest tool calls on a real task; quality varies by model

From docs.litellm.ai Claude Code pages, checked October 13, 2026.

Every way to run other models in Claude Code

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.

Cost per 100 requests, US dollars
Claude
Claude Opus 5.5$10.66
Claude Sonnet 5.5$5.33
Efficient model, for comparison
GPT-6 Luna$0.41
79,301 coding-agent requests on our gateway, September 13 to October 12, 2026, averaging 133K input and 698 output tokens, 87% of input from cache. Provider list prices on October 13; hosting not included. Claude Code was not in the sample; its requests follow the same pattern of large cached context, so read these as relative costs.

LiteLLM pricing, free vs Enterprise

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.

Related guides