Amux

Claude Code

Last updated August 26, 2026

Point Claude Code at Amux with two environment variables, then use any compatible model in it.

Claude Code uses the Anthropic Messages protocol, which Amux implements natively. Once configured, Claude Code can use any compatible model, not just Claude; switching models only changes the model name.

CC Switch supports Claude Code — add a provider with https://gateway.amux.ai as the Base URL, and map the three model tiers to whatever you want from its UI.

Claude Code supports hot switching: flip it in CC Switch and the current session picks it up, with no terminal restart. None of the other tools manage that.

The manual route is below.

1. Install Claude Code

npm / pnpm installs are no longer recommended; the official path is a native installer:

# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash

# Homebrew
brew install --cask claude-code
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

If you installed it through npm, run claude install to migrate to the native build. Then run claude doctor to check the installation.

2. Create an Amux key

Create one on the keys page in the console. The key remains viewable there after creation, so you do not need to rotate it just to retrieve it again.

3. Set the environment variables

macOS / Linux / WSL

Terminal

export ANTHROPIC_BASE_URL=https://gateway.amux.ai
export ANTHROPIC_AUTH_TOKEN=your Amux key
export ANTHROPIC_API_KEY=

Put those in ~/.zshrc or ~/.bashrc so you do not export them every time.

Windows PowerShell

PowerShell

$env:ANTHROPIC_BASE_URL = "https://gateway.amux.ai"
$env:ANTHROPIC_AUTH_TOKEN = "your Amux key"
$env:ANTHROPIC_API_KEY = ""

For these to persist, put them in your PowerShell profile (the file $PROFILE points at).

What each variable does

VariablePurpose
ANTHROPIC_BASE_URLThe gateway address. No /v1 — the client appends /v1/messages itself
ANTHROPIC_AUTH_TOKENYour Amux key
ANTHROPIC_API_KEYLeave it empty. With both set, this one wins, so the request carries an official key to us and fails authentication — while ANTHROPIC_AUTH_TOKEN looks perfectly correct

Optional: two variables worth setting

export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
export API_TIMEOUT_MS=600000
  • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 turns off traffic unrelated to inference
  • API_TIMEOUT_MS widens the timeout. The default is tight for long contexts on strong reasoning models, where the first token takes a while; a timeout there looks like "it spun for ages and then failed"

4. Start it

Open a new terminal — an old one will not see variables you just wrote to a config file — and go to your project:

cd my-project
claude

5. Check it works

Inside Claude Code, run:

/status

Look at two lines: the auth method should read as an auth token (not an official login), and the base URL should be https://gateway.amux.ai. If they do not match, the variables were not picked up — go back and make sure you opened a new terminal.

Choosing models

export ANTHROPIC_MODEL=anthropic/claude-opus-5

You can also set the three tiers separately and let Claude Code pick by task complexity:

export ANTHROPIC_DEFAULT_HAIKU_MODEL=anthropic/claude-haiku-4-5
export ANTHROPIC_DEFAULT_SONNET_MODEL=anthropic/claude-sonnet-5
export ANTHROPIC_DEFAULT_OPUS_MODEL=anthropic/claude-opus-5

The tiers do not have to be Claude. Protocol and model are two separate things — openai/gpt-5.6 and deepseek/deepseek-v3.2 both work, and Claude Code carries on as usual. What matters is that the model's upstream can serve the Anthropic protocol, which each model's page states.

Switch with /model once it is running.

Pinning a provider or choosing a strategy

A model often has several providers at different prices and speeds. To pin one, append a colon:

export ANTHROPIC_MODEL=anthropic/claude-opus-5:anthropic

Without a pinned provider you can pick the ordering for the call instead — :@price for cheapest first, :@latency for lowest latency. Full details in the API reference.

Troubleshooting

404s

ANTHROPIC_BASE_URL has an extra /v1. Claude Code builds the path itself, so the request lands on /v1/v1/messages. Drop that segment.

Authentication failures

In order:

  1. Is ANTHROPIC_API_KEY still set? It takes precedence over ANTHROPIC_AUTH_TOKEN
  2. Was the key copied in full? Leading or trailing whitespace is the usual culprit
  3. Is the key still enabled in the console, and does the workspace have balance?
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN

Odd behavior after switching from another platform

Claude Code caches the previous login. Delete the credential cache under ~/.claude/, start it again, and confirm with /status.

Model unavailable

Model IDs need the vendor prefix (anthropic/claude-opus-5, not claude-opus-5). Also, not every model supports every protocol — Claude Code speaks Anthropic, so pick a model whose upstream serves it; each model's page says so. Asking for an unsupported combination fails with a clear error rather than degrading silently.

claude not found on Windows

With an npm install, the npm global directory is not on PATH. Either switch to the native installer above, or add the path from npm config get prefix to PATH.

PowerShell refuses to run scripts

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

RemoteSigned only requires signatures on downloaded scripts and leaves local ones alone — safer than Unrestricted.

Variables in the PowerShell profile are ignored

Test-Path $PROFILE   # does the file exist
Get-Content $PROFILE # is the content right

If the profile is saved in a non-UTF-8 encoding, non-ASCII comments can break parsing and the file is skipped silently. Save it as UTF-8.

Slow responses or timeouts

A long context on a strong reasoning model is slow to the first token by nature. Widen API_TIMEOUT_MS, or try a faster tier. The :@latency suffix also tells routing to prefer low-latency providers.