# Switch Claude Code to Other WanAPIs Models

> Once Claude Code is connected to WanAPIs, switch it to DeepSeek, GPT, Gemini and other models. Covers the CLI, the VS Code extension and the desktop app, plus the background small model and common pitfalls.

Web page: https://wanapi.ai/docs/claude-code-switch-model

Claude Code speaks the Anthropic protocol, but it passes the model name straight through — if the gateway recognizes it, it works. Once ANTHROPIC_BASE_URL points at WanAPIs, the same key can switch to DeepSeek, GPT, Gemini or any other model, with no new tool and no change to your workflow. This guide uses deepseek-v4.1-flash as the example and covers the CLI, the VS Code extension and the desktop app.

## Setup steps

### 1. Make sure you're connected to WanAPIs

This guide assumes you've already set the gateway URL and key as in the Claude Code setup guide. Switching models only changes the model name — the gateway URL and key stay the same.

**shell**

```
export ANTHROPIC_BASE_URL="https://api.wanapis.com"
export ANTHROPIC_AUTH_TOKEN="sk-xxx"
```

### 2. CLI: switch for one session

Launch with --model to use a model for this session only — ideal for trying one out. Inside a running session, type /model to switch on the spot.

**shell**

```
claude --model deepseek-v4.1-flash
```

### 3. CLI: switch permanently

Add ANTHROPIC_MODEL to ~/.zshrc or ~/.bashrc. Mind the precedence: the --model flag > the ANTHROPIC_MODEL environment variable > the model key in the settings file. If a settings-file change doesn't take effect, an environment variable is almost always overriding it.

**~/.zshrc**

```
export ANTHROPIC_MODEL="deepseek-v4.1-flash"
```

### 4. VS Code extension / desktop app: use the settings file

Apps launched from the Dock, Launchpad or Start menu don't inherit the exports in your ~/.zshrc — the most common reason something "works in the terminal but not in the extension or desktop app". (Launching VS Code from a terminal with code . does inherit them, which is why it can seem to work only sometimes.) The reliable fix is the env block in ~/.claude/settings.json: Claude Code reads it itself regardless of how the app was launched, so it works in all three environments. Restart VS Code or the desktop app afterwards.

**~/.claude/settings.json**

```
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.wanapis.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
    "ANTHROPIC_MODEL": "deepseek-v4.1-flash",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4.1-flash"
  }
}
```

### 5. Don't forget the background small model

Besides the main model, Claude Code uses a haiku-tier small model for background chores (session titles, file summaries and so on). If you only change ANTHROPIC_MODEL, that part is still billed at Claude prices. To move everything to a cheaper model, set ANTHROPIC_DEFAULT_HAIKU_MODEL as well (the config above already does). The old variable ANTHROPIC_SMALL_FAST_MODEL is deprecated — don't use it.

### 6. Verify

Send any message, then open the Usage Logs page in the WanAPIs console and check the model name on the latest entry. If it shows deepseek-v4.1-flash, the switch worked — and you can see the token count and charge for that call too.

## FAQ

### Isn't Claude Code limited to Claude models?

The model name is passed through to the upstream, and Claude Code doesn't enforce an allowlist. WanAPIs translates Anthropic-protocol requests into whatever format the target model needs, so DeepSeek, GPT and Gemini all work directly.

### Why does the response name the model deepseek-flash?

The response echoes the upstream's own model name, while billing and usage logs use the public name you requested (deepseek-v4.1-flash). Your bill isn't affected.

### I changed the config but nothing happened?

Check in order of precedence: the --model flag wins, then the ANTHROPIC_MODEL environment variable, and only then the model key in settings.json. Also, the VS Code extension and desktop app can't see terminal exports — use the env block in settings.json and restart the app.

### Which models can I switch to?

Any text model on WanAPIs — copy the model name from the model marketplace. Switching models doesn't need a new key, and it's all one balance.

---

Generated by the WanAPIs website and kept in sync with the web page. All guides in Markdown: https://wanapi.ai/docs/index.md
