Run Claude Code on Stav
Point Claude Code at Stav with two environment variables, pick a model that runs on EU compute, and avoid the two settings that trip up non-Claude models.
Claude Code is Anthropic's coding agent for the terminal. It reads your code, edits files and runs commands. It can send its model traffic to any gateway that speaks the Anthropic Messages API, so it runs on Stav with configuration only.
Point it at Stav and every turn is billed to your Stav credits, shows up in your request log, and follows your workspace policy. Pick a model that is not a Claude model and the work runs where that model's Inference Provider runs — for example in France.
Tested with Claude Code 2.1.296 on macOS.
Before you start
- A Stav API key. See Authentication.
- Claude Code installed. See the Claude Code quickstart.
Set it up
Add an env block to ~/.claude/settings.json. It applies to every project and to Claude Code's background agents:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.stav.ai",
"ANTHROPIC_AUTH_TOKEN": "sk_stav_live_...",
"ANTHROPIC_MODEL": "zai-org/glm-5-2"
}
}
Or, for one terminal session:
export ANTHROPIC_BASE_URL="https://api.stav.ai"
export ANTHROPIC_AUTH_TOKEN="sk_stav_live_..."
export ANTHROPIC_MODEL="zai-org/glm-5-2"
- Write the base URL without
/v1. Claude Code adds/v1/messagesitself. - Use
ANTHROPIC_AUTH_TOKEN, notANTHROPIC_API_KEY. It sends your key asAuthorization: Bearerand takes effect at once. (ANTHROPIC_API_KEYalso works, but Claude Code asks you to approve it first.) - Never put the key in a project's
.claude/settings.json. That file is committed to your repository.
Start claude and run /status. The Anthropic base URL line should show https://api.stav.ai, and Auth token should name ANTHROPIC_AUTH_TOKEN.
Stav credits pay for it. While the key is set, Claude Code does not use your Claude subscription. Every turn is charged to your Stav credits.
Pick a model
Set ANTHROPIC_MODEL to any chat model in the Stav catalogue, by its full slug.
| Model value | What happens |
|---|---|
An open-weights model, such as zai-org/glm-5-2 | Stav translates each request to the provider and the answer back. Tested end to end: served in France by Scaleway |
auto | Your workspace's default Router picks a model for each request. It follows the Router's rules, so it can pick a US-served model unless your policy blocks that |
A Claude model, such as claude-haiku-5-5 | Forwarded to Anthropic as sent. You get Stav's logging, spend limits and key controls — not EU compute |
A named model can be served by more than one Inference Provider, and they are not all in the EU. To keep every request in Europe, set a sovereignty floor or a compute region for your workspace. See Keep traffic sovereign.
Model auto sends the request to your workspace's default router, which the Smart Router drives. It has nothing to do with Claude Code's own "auto mode", which is a permission setting.
What works
Tested on zai-org/glm-5-2:
| Feature | Result |
|---|---|
| Streaming | Works |
| Tool calls (read, edit, run commands) | Works |
| A full agent task (fix a bug, run the file) | Works |
Prompt caching (cache_control) | Left out, named in the X-Stav-Dropped-Params response header |
Effort level (/effort, CLAUDE_CODE_EFFORT_LEVEL) | Sent to the model as its reasoning level. If the model cannot take it, it is named in X-Stav-Dropped-Params |
/model picker (gateway model discovery) | Not listed — see Tips |
A Claude model gets the request exactly as Claude Code sent it, so Claude Code's features behave as they do on Anthropic's own API. We tested one streamed turn on claude-haiku-5-5.
Tips
- Output limits are handled for you. Claude Code asks for up to 32,000 output tokens per turn. Where an Inference Provider allows fewer, Stav sends the provider's own limit and names it in
X-Stav-Clamped-Params(for examplemax_tokens=16384on GLM-5.2). To choose a lower ceiling yourself, setCLAUDE_CODE_MAX_OUTPUT_TOKENS. - Tell Claude Code the real context window. Claude Code does not know non-Claude models and assumes 200,000 tokens. For a model with a larger window, set
CLAUDE_CODE_MAX_CONTEXT_TOKENS, for example"1000000"for GLM-5.2. The model page in the catalogue shows the window. - The warning about an unknown model is harmless. Claude Code prints that the model "isn't described by this version's model catalog". It is Claude Code's own list, not an API error. The run continues.
- Model discovery only finds Claude models. With
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, Claude Code reads Stav's/v1/models, but keeps only names that containclaudeoranthropic. Set other models withANTHROPIC_MODELor/model <slug>. - Some traffic does not go through Stav. Claude Code still sends telemetry and update checks to Anthropic and others. To turn that off, add
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"to theenvblock. This also turns off auto-updates. - The VS Code extension reads its own settings. Put the same variables in
claudeCode.environmentVariablesin VS Code's user settings. See Configure each surface.
Troubleshooting
| What you see | Cause | Fix |
|---|---|---|
Failed to authenticate. API Error: 401 Invalid or revoked API key. | The key is wrong, revoked or expired | Create a new key in Your workspace → Connect → API keys and update ANTHROPIC_AUTH_TOKEN |
404 on every request | The base URL ends in /v1, so Claude Code calls /v1/v1/messages | Use https://api.stav.ai |
| Claude Code asks you to log in | It found no key before its first-run setup | Put the key in ~/.claude/settings.json or a shell export, not in a project settings file |
/status shows a claude.ai login, not the token | The variable did not reach Claude Code | Start claude from the shell where you exported it, or use the settings file |
For Stav's error codes, see Errors.
Check it worked
Open Your workspace → Monitor → Request log. Each turn is one row, with the model, Inference Provider, country and cost. A short task is usually 3–5 rows. See Request log and prompt capture.