Guides

    OpenRouter Claude Code Setup: How to Use GPT, DeepSeek, GLM and More

    How to run Claude Code on OpenRouter, DeepSeek, GLM or Kimi: the exact environment variables, what breaks, what it costs and how to add image and voice models.

    November 18, 202613 min read
    Share:

    Published 18-11-2026. Last verified 18-11-2026: provider endpoints, model names and prices change often, and we re-check this page monthly.

    Quick answer: can you use OpenRouter and other models in Claude Code?

    Yes, with a caveat. Claude Code talks to its model through the Anthropic Messages format, and you can point it at any endpoint that speaks that format by setting a few environment variables. The OpenRouter Claude Code setup takes three variables, and DeepSeek, Z.ai (GLM) and Kimi publish Anthropic-compatible endpoints of their own. The caveat: Anthropic states that it does not support routing Claude Code to non-Claude models, and OpenRouter states that its Claude Code setup is only guaranteed with Anthropic as the provider. This guide is for developers and tech leads who use Claude Code every day and want to run part of that work on cheaper or different models without breaking their workflow. We show each route with the exact variables, what works and what breaks, what it costs per million tokens on 18-11-2026, and how to add image, video and voice models, which is a different job altogether.

    How we checked this

    Our method in three lines: we read Anthropic's Claude Code documentation for what is supported, we read the setup pages of OpenRouter, DeepSeek, Z.ai and Kimi for the exact variables, and we read the top three Google results for "openrouter claude code" to see what developers are told.

    Our gate: we document a route only if the provider publishes Claude Code or Anthropic-format instructions on a page we read on 18-11-2026. Two common answers did not pass as routes of their own. Pointing Claude Code straight at OpenAI's or Google's API failed: the providers we found that publish an Anthropic-format endpoint for Claude Code were OpenRouter, DeepSeek, Z.ai and Kimi, so GPT and Gemini go through OpenRouter or a gateway in this guide. And Qwen got no section of its own, because we did not open a Qwen page with Claude Code instructions today; it is reachable through OpenRouter.

    We did not run these setups for this article. The steps come from each provider's documentation, so they are documented but not tested by us. Test on a throwaway branch before you move a team over.

    Can you use other models in Claude Code?

    Technically yes, officially no. Anthropic's page on other LLM gateways says that any gateway exposing a supported API format works, that Anthropic does not endorse, maintain or audit third-party gateway products, and that it does not support routing Claude Code to non-Claude models through any gateway. The same page warns that Claude Code adds capabilities with each release, and a gateway that does not forward them breaks those features.

    That is the honest frame for everything below. Running Claude Code on DeepSeek or GLM works for many tasks, and many developers do it to save money, but when something breaks you are on your own. Our view: it is a good fit for well-scoped, high-volume work such as tests, refactors and boilerplate, and a poor fit for the hard reasoning and long agentic runs where Claude Code's own models earn their price. Our comparison of the best Claude model for coding covers that side.

    There are two separate questions in this keyword cluster, and we keep them apart. One is swapping the language model that drives Claude Code. The other is giving Claude Code image, video or voice models as tools; that does not replace anything, and we cover it near the end.

    Option 1: OpenRouter

    OpenRouter is the most common route because one key reaches many models. The official OpenRouter guide for Claude Code gives the setup on 18-11-2026. Add these lines to your shell profile, with your own key in place of the text in angle brackets:

    export OPENROUTER_API_KEY="<your-openrouter-api-key>"
    export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
    export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
    export ANTHROPIC_API_KEY=""
    

    The empty ANTHROPIC_API_KEY is deliberate: OpenRouter's guide says it must be explicitly empty so Claude Code does not fall back to Anthropic. Reload your shell, clear any cached Anthropic login, start Claude Code and check that requests show up in your OpenRouter activity dashboard.

    By default this still runs Claude models, now billed through OpenRouter. To run other models, OpenRouter documents one variable per model class: ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_FABLE_MODEL and CLAUDE_CODE_SUBAGENT_MODEL for subagents. Set one to the model ID shown on that model's OpenRouter page, then open /model in Claude Code to confirm. Setting CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 adds a picker with a curated set of models, some of which route to non-Anthropic providers.

    The guide is candid about the limits: it says Claude Code is optimised for Anthropic models and may not work correctly with other providers. What OpenRouter does add, according to the same page, is failover between Anthropic providers, team budgets and usage visibility. To watch prices drift, OpenRouter Cost Watch, free, monitors OpenRouter prices against a baseline and alerts you. Routing and observability skills sit in our LLM ops collection.

    Option 2: the model's own Anthropic-compatible API

    Some providers skip the middleman and speak the Anthropic format themselves. You pay them directly, often at a lower price than through a router.

    DeepSeek

    DeepSeek's guide to using the Anthropic API gives the base URL https://api.deepseek.com/anthropic and the same two-variable setup: ANTHROPIC_BASE_URL plus your DeepSeek key. The useful detail is the model mapping, as documented on 18-11-2026: model names starting with claude-opus map to deepseek-v4-pro, and names starting with claude-sonnet or claude-haiku map to deepseek-flash. So Claude Code's normal model switching keeps working, with DeepSeek models behind it. The same page says the anthropic-beta header is ignored for messages, which is one reason newer Claude Code features may behave differently. deepseek spend audit, free, estimates your DeepSeek spend from local Claude Code transcripts with peak and off-peak pricing.

    GLM (Z.ai)

    Z.ai publishes a Claude Code setup for its GLM Coding Plan. You create an API key under your coding plan, set the environment variables, and by default all three model classes map to GLM-5.3-Flash according to the page on 18-11-2026; the page also explains how to switch to GLM-5.3. Z.ai offers a helper, run with npx @z_ai/coding-helper, that configures it for you. This is a subscription route rather than pay per token, which suits a developer who wants a predictable monthly bill.

    Kimi

    Kimi's API quickstart on platform.kimi.ai, read on 18-11-2026, lists a Messages API you can call with the Anthropic SDK and names Claude Code as a fit for Kimi K3.1 Pro, which it describes as having a 1M-token context window. Set it up the same way: the base URL from Kimi's docs and your Kimi key. We have not verified Kimi's Claude Code page in detail, so treat this as the least documented of the three.

    If you want a local model instead of a hosted one, our guide to OpenClaw with Ollama local models covers that setup, and Give Your Agent a Local Brain (Ollama), $9, configures an agent to think on your own machine with no per-call cost.

    Option 3: an LLM gateway your organisation runs

    For teams, the third route is a gateway: one internal endpoint that holds the provider keys, tracks usage per developer and enforces budgets. Anthropic's gateway page lists those benefits and the trade-off: the gateway becomes infrastructure you operate, and it must be kept up to date as Claude Code changes. It also documents a managed setting that pins every machine to the gateway's ANTHROPIC_BASE_URL. Choose this when more than a handful of developers share keys, or when compliance asks for audit logs. Rollout and infrastructure skills sit in our DevOps and cloud collection, and our Claude Code router guide covers a popular open-source router.

    What works and what doesn't

    What changes when Claude Code runs on another model, based on the providers' own documentation on 18-11-2026:

    FeatureOpenRouter with Claude modelsOpenRouter with other modelsDeepSeek endpointZ.ai GLM endpoint
    Basic coding and file editsSupportedWorks, not guaranteedWorks, not guaranteedWorks, not guaranteed
    Tool usePassed through ("Anthropic Skin")Depends on the modelSupported on both modelsNot documented on the page we read
    Thinking blocksPassed throughDepends on the modelThinking mode is the defaultNot documented on the page we read
    Image inputAs ClaudeDepends on the modeldeepseek-flash yes, v4-pro noNot documented on the page we read
    Newest Claude Code featuresYesMay breakanthropic-beta ignoredMay break
    Who supports itOpenRouter, not AnthropicNobody guarantees itDeepSeek, not AnthropicZ.ai, not Anthropic

    Our reading: the further you move from Claude, the more you test. Run your own test suite on the new model before you trust it with an agentic task that edits many files. Multi-Model Cross-Review and Cheap Delegation, $5, uses cheap models for second opinions with one strong judge settling disagreements, and more review skills sit in our code quality and review collection.

    What it costs

    RouteHow you payExample price, checked 18-11-2026
    OpenRouterProvider list prices, plus a fee when you buy creditsPer model; see the model's OpenRouter page
    DeepSeek, deepseek-flashPay per token$0.30 input (cache miss) and $1.20 output per 1M tokens at peak; off-peak half
    DeepSeek, deepseek-v4-proPay per token$1.32 input (cache miss) and $3.96 output per 1M tokens at peak; off-peak half
    Z.ai GLM Coding PlanSubscriptionPlan price on Z.ai; not checked by us
    Your own gatewayThe upstream provider plus your hostingDepends on the provider

    The DeepSeek prices come from DeepSeek's pricing page, which says peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays and that off-peak rates are half. The OpenRouter billing line comes from our own comparison of Agensi and OpenRouter. Before you switch for cost alone, measure what you spend now: Cut Agent Token Costs: Caching, Routing and Budget Guards, $3 often finds savings in context hygiene and caching before you change models at all.

    A middle way: keep Claude, delegate to cheaper models

    Replacing the model is all or nothing for a session. Delegating is not. Claude Code Model Router: Delegate Work to Cheap Models, $5, keeps Claude in charge and dispatches token-hungry tasks to cheaper subagents such as GLM, Kimi or DeepSeek. This is the route we would try first on a team, because the hard decisions stay with Claude and only the bulk work moves. Subagent and orchestration skills sit in our agents and orchestration collection. If you are weighing other coding agents altogether, our comparisons of Codex and Claude Code and Gemini CLI and Claude Code cover that choice.

    Use image, video and voice models in Claude Code

    Searches such as "nano banana claude" are not about replacing the language model. Claude Code has no image, video or voice model, so you add those as tools through MCP, and Claude keeps doing the coding. Through one connection to Agensi, Claude Code can call image models such as Nano Banana, video models such as Veo and Kling, and voice models such as ElevenLabs, with no API key or account at Google or ElevenLabs. Your agent tells you what each use cost, and a failed use is free.

    Add it once: our setup docs give claude mcp add --transport http agensi https://mcp.agensi.io/mcp/auth, after which you open /mcp and choose Authenticate. Or start from our MCP page. Starting prices on 18-11-2026: Nano Banana 2 at $0.065 per image and Nano Banana Pro at $0.195 on our Nano Banana tools page; ElevenLabs Text to Speech at $0.052 per 1,000 characters on our voice tools page. A developer building a landing page can ask for the hero image, the alt text and the code in one pass. AI Image Generator: On-Brand Images, No API Keys, free, adds a draft-then-final method and uses those image tools. More skills are in our Claude image generation collection.

    To be fair to OpenRouter: our comparison page says plainly that if your app makes images or videos in a code pipeline, calling OpenRouter's API directly fits better. Agensi is built for using those models from inside an agent.

    Troubleshooting

    Claude Code still uses your Anthropic account. ANTHROPIC_API_KEY is probably set. OpenRouter's guide says to set it to an empty string and to clear a cached Anthropic login.

    The new variables seem to do nothing. Reload your shell or open a new terminal; OpenRouter's guide warns that otherwise you keep testing the old environment.

    A model class is missing in /model. On OpenRouter, Fable is not offered by default; the guide says setting ANTHROPIC_DEFAULT_FABLE_MODEL is the only way to make it selectable.

    Tool calls fail or come back malformed. The model behind the endpoint may not handle Claude Code's tool format well. Switch that model class back to a Claude model or a model the provider documents for tool use. Debugging skills sit in our testing and debugging collection.

    A new Claude Code feature does not work. Gateways and compatible endpoints lag behind releases. Anthropic's gateway page names this as the main trade-off.

    Your next step

    We sell skills and pay-per-call tools that your agent uses through one MCP connection, and we name ours above. No vendor paid to be listed.

    If cost is the reason, start with the Claude Code Model Router skill and keep Claude in charge for a week; switch the whole session to DeepSeek or GLM only for work your tests cover. If you came here for images or voice, connect Agensi once and ask Claude Code for one image. Either way, try it on a branch before your team relies on it.

    Written by Samuel Rose, Founder of Agensi. Next scheduled review: 18-12-2026.