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.

Install Claude Code first, then follow the steps below to connect it to the gateway.

macOS / Linux / WSL (the officially recommended native installer):

终端窗口
curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

终端窗口
irm https://claude.ai/install.ps1 | iex

You can also use a package manager: brew install --cask claude-code on macOS, or winget install Anthropic.ClaudeCode on Windows. Or use npm (requires Node.js 22 or later; do not use sudo):

终端窗口
npm install -g @anthropic-ai/claude-code@latest

Verify the installation:

终端窗口
claude --version

If it prints a version number, you are set. For system requirements, other install methods and troubleshooting, see the official setup guide.

  • 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.

Option 1: generate the config in the console

Section titled “Option 1: generate the config in the console”

The console can build the config in your browser; your token never leaves it.

  1. Open the console API Keys page, choose Terminal Commands in the action menu of the token you want, and pick the Claude Code tab.
  2. Pick a model and your system (macOS / Linux, Windows CMD or PowerShell).
  3. The dialog gives you two blocks; use either one:
    • A terminal command that sets the environment variables for the current session only.
    • File content to save as ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json), merged with what is there.

The generated variables are (ANTHROPIC_MODEL is left out when the model field is empty):

Variable Value
ANTHROPIC_BASE_URL https://api.openpalm.ai (no /v1)
ANTHROPIC_AUTH_TOKEN sk-xxxx
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 1 (turns off non-essential network traffic)
ANTHROPIC_MODEL the model you picked

The settings.json content is the same set of variables under env. The file contains your token, so do not commit it to a repository.

macOS / Linux:

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

Windows PowerShell:

终端窗口
$env:ANTHROPIC_BASE_URL = "https://api.openpalm.ai"
$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.openpalm.ai",
"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.openpalm.ai",
"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 Usage 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.

Similar clients: Codex CLI, Gemini CLI, OpenCode. To switch configurations in a GUI, use CC Switch.