Skip to content

Claude Code

Claude Code can be configured through environment variables to use any endpoint that is compatible with the Anthropic Messages API. OpenPalmLab provides /v1/messages, so the setup below is all you need.

  • Claude Code is installed (see the official Claude Code documentation).
  • You have a token whose group includes models that support the Anthropic endpoint type. You can filter by endpoint type on the pricing page.

macOS / Linux:

终端窗口
export ANTHROPIC_BASE_URL=https://api.openpalmlab.com
export ANTHROPIC_AUTH_TOKEN=sk-xxxx
claude

Windows PowerShell:

终端窗口
$env:ANTHROPIC_BASE_URL = "https://api.openpalmlab.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-xxxx"
claude

Notes:

  • Do not add /v1 to ANTHROPIC_BASE_URL. Claude Code appends /v1/messages itself.
  • ANTHROPIC_AUTH_TOKEN sends the token in an Authorization: Bearer header. If another tool you use expects ANTHROPIC_API_KEY (sent as x-api-key), that works too; the gateway accepts both. Set only one of the two.

Put the settings in ~/.claude/settings.json so they apply every time, without exporting variables in each terminal:

{
"env": {
"ANTHROPIC_BASE_URL": "https://api.openpalmlab.com",
"ANTHROPIC_AUTH_TOKEN": "sk-xxxx"
}
}

To apply them to a single project only, use .claude/settings.local.json in the project directory. That file is not committed to git by default, but check that it is covered by your .gitignore.

Claude Code uses its own built-in model names by default. If those models are not in your group, set model names from the pricing page:

{
"env": {
"ANTHROPIC_BASE_URL": "https://api.openpalmlab.com",
"ANTHROPIC_AUTH_TOKEN": "sk-xxxx",
"ANTHROPIC_MODEL": "YOUR_MODEL",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "YOUR_SMALL_MODEL"
}
}

ANTHROPIC_MODEL is the main model and ANTHROPIC_DEFAULT_HAIKU_MODEL is the lightweight model used for small background tasks. Variable names follow the official documentation for your version of Claude Code. You can also switch models inside a session with /model.

Start claude and ask it anything. Then open the Logs page in the console. If you see requests from that token, the setup is working.

Symptom Fix
Claude Code asks you to log in It did not pick up the variables. Check that settings.json is valid JSON, or export the variables and start claude in the same terminal.
401 Invalid token The token is wrong, expired or out of quota.
No available channel for model ... That model has no available channel in your group. Choose another model with ANTHROPIC_MODEL, or use a token in a different group.
429 You hit a rate limit or the upstream is busy. Try again later; see Troubleshooting.