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.
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: environment variables
Section titled “Option 1: environment variables”macOS / Linux:
export ANTHROPIC_BASE_URL=https://api.openpalmlab.comexport ANTHROPIC_AUTH_TOKEN=sk-xxxxclaudeWindows PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.openpalmlab.com"$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 2: settings.json (recommended)
Section titled “Option 2: settings.json (recommended)”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.
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.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.
Check it works
Section titled “Check it works”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.
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. |