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
Section titled “Install”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 | bashWindows PowerShell:
irm https://claude.ai/install.ps1 | iexYou 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@latestVerify the installation:
claude --versionIf it prints a version number, you are set. For system requirements, other install methods and troubleshooting, see the official setup guide.
Before you start
Section titled “Before you start”- 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.
- Open the console API Keys page, choose Terminal Commands in the action menu of the token you want, and pick the Claude Code tab.
- Pick a model and your system (macOS / Linux, Windows CMD or PowerShell).
- 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.
Option 2: environment variables
Section titled “Option 2: environment variables”macOS / Linux:
export ANTHROPIC_BASE_URL=https://api.openpalm.aiexport ANTHROPIC_AUTH_TOKEN=sk-xxxxclaudeWindows PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.openpalm.ai"$env:ANTHROPIC_AUTH_TOKEN = "sk-xxxx"claudeNotes:
- Do not add
/v1toANTHROPIC_BASE_URL. Claude Code appends/v1/messagesitself. ANTHROPIC_AUTH_TOKENsends the token in anAuthorization: Bearerheader. If another tool you use expectsANTHROPIC_API_KEY(sent asx-api-key), that works too; the gateway accepts both. Set only one of the two.
Option 3: settings.json by hand
Section titled “Option 3: settings.json by hand”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.
Choosing models
Section titled “Choosing models”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.
Check it works
Section titled “Check it works”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.
Common problems
Section titled “Common problems”| 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.