Skip to content
English

Switch theme

// How-to · Switch models: your own key, Chinese or local models

Use Claude Code with other models (Chinese models, your own gateway)

Claude Code can send requests to any Anthropic-compatible endpoint set via environment variables. Many model vendors offer Anthropic-compatible APIs, and gateways such as LiteLLM or claude-code-router can translate formats.

verified 2026-10-103 official sources

Scenario: Switch models: your own key, Chinese or local models →

Symptoms

  • You want Claude Code to use a company gateway or another vendor’s model

Common causes

  • By default requests go straight to Anthropic

How to fix

  1. Check that the vendor’s official docs offer an Anthropic-compatible API and get the base URL and key they provide
  2. Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN (or put them under env in Claude Code’s settings.json) and set the model name as the vendor documents
  3. If the vendor only offers the OpenAI format, translate with LiteLLM or claude-code-router
  4. Use a tool such as cc-switch to switch between configurations
  5. Test tool calling and long context on small tasks first; tool-calling quality varies a lot between models

Notes

  • Use only official or compliant endpoints, never unknown relays or shared accounts

Official references

Compiled from official documentation and public discussions on 2026-10-10; not yet reproduced in our own environment. Follow the official docs if they differ.

Data updated: Problems & errors