Run Claude Code with a different model provider: the variables per vendor, what CC Switch and magpie write, and what breaks Claude Code 2.1.299 can be pointed at non-Anthropic model providers in about ten minutes by setting ANTHROPIC_BASE_URL to a vendor's Anthropic-compatible endpoint, putting the vendor key in ANTHROPIC_AUTH_TOKEN, and mapping all four model tiers, according to vendor documentation compiled on 14 October 2026. Anthropic's gateway docs state it does not support routing Claude Code to non-Claude models, so failures must be resolved through each vendor's docs and issue tracker; Claude Code 2.1.268 or later is required because versions 2.1.265 to 2.1.267 sent a tool schema that Z.ai and DeepSeek rejected on every interactive request (issue #92964). Run Claude Code with a different model provider: the variables per vendor, what CC Switch and magpie write, and what breaks To run Claude Code https://stackness.dev/tools/claude-code on another vendor's model, you set ANTHROPIC BASE URL to the vendor's Anthropic-compatible endpoint, put the vendor's key in ANTHROPIC AUTH TOKEN and map all four model tiers to the vendor's models, which takes about ten minutes. The steps below are copied from each vendor's docs on 14 October 2026, when Claude Code 2.1.299 was the latest release; some vendors last tested older versions. Anthropic's gateway docs https://code.claude.com/docs/en/llm-gateway say it does not support routing Claude Code to non-Claude models, so when something breaks, the vendor's docs and issue tracker are where the fix is. The harness lock-in post https://stackness.dev/blog/deepseek-harness-vs-claude-code-which-harnesses-lock-you-to-one-model-and-what-breaks-when-you-switc covers what you leave behind in plugins, hooks and sessions. This one is the setup. What you need - Claude Code 2.1.268 or later. Versions 2.1.265 to 2.1.267 sent a tool schema that Z.ai and DeepSeek rejected on every interactive request issue 92964 https://github.com/anthropics/claude-code/issues/92964 . - A key for the vendor. At Kimi, pay-as-you-go keys and the coding plan are separate products with different endpoints, and MiniMax's endpoint below takes an M Plan key. - For a local model, Ollama https://stackness.dev/tools/ollama , with its context length set to 64k or more. | Vendor | Endpoint for ANTHROPIC BASE URL | Model the vendor's docs put on the top tiers | |---|---|---| | DeepSeek API | https://api.deepseek.com/anthropic | deepseek-flash 1m | | Kimi API | https://api.moonshot.ai/anthropic | kimi-k3 1m | | Kimi Code plan | https://api.kimi.ai/coding/ | k3-256k or k3 1m | | Z.ai GLM Coding Plan | https://api.z.ai/api/anthropic | glm-5.3 1m | | MiniMax M Plan | https://api.minimax.io/anthropic | MiniMax-M3.1-Flash-Preview 1m | | OpenRouter https://stackness.dev/tools/openrouter | https://openrouter.ai/api | ~anthropic/claude-sonnet-latest 1m , or any model with CLAUDE CODE ENABLE GATEWAY MODEL DISCOVERY=1 | | Ollama | http://localhost:11434 | Any local model | Sources: DeepSeek https://api-docs.deepseek.com/quick start/agent integrations/claude code , Kimi API https://platform.kimi.ai/docs/guide/claude-code-kimi.md , Kimi Code https://www.kimi.com/code/docs/en/third-party-tools/claude-code.html , Z.ai https://docs.z.ai/devpack/tool/claude , MiniMax https://platform.minimax.io/docs/m-plan/claude-code.md , OpenRouter https://openrouter.ai/docs/guides/guides/claude-code-integration , Ollama https://docs.ollama.com/integrations/claude-code . 1. Test the endpoint with curl first Testing the endpoint before Claude Code starts separates a wrong URL or key from a Claude Code problem. Anthropic's connection guide https://code.claude.com/docs/en/llm-gateway-connect gives this request: curl -sS -w '\n%{http code}\n' -X POST "$ANTHROPIC BASE URL/v1/messages" \ -H "Authorization: Bearer $ANTHROPIC AUTH TOKEN" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{"model": "claude-sonnet-4-6", "max tokens": 1, "messages": {"role": "user", "content": "."} }' An error naming an unknown model still means the URL and key work. A 401 means the key was rejected. The base URL ends before /v1 : adding /v1 yourself produces /v1/v1/messages . 2. Set all four model tiers in settings.json Claude Code calls four model tiers, not one: Opus, Sonnet and Fable for the main work, Haiku for background calls, plus a separate model for subagents. Kimi's docs warn that setting only some of them makes the rest fail silently. DeepSeek's snippet does not set the Fable tier ANTHROPIC DEFAULT FABLE MODEL , and DeepSeek maps any model name it does not support to deepseek-flash . DeepSeek's setup, moved into the env block of ~/.claude/settings.json : { "env": { "ANTHROPIC BASE URL": "https://api.deepseek.com/anthropic", "ANTHROPIC AUTH TOKEN": "