Tool setup
Claude Code
Point Anthropic's CLI at the gateway with two environment variables.
Claude Code is Anthropic's terminal coding agent. It talks the Anthropic Messages API, which the gateway serves natively — so pointing it here takes two environment variables.
What you get
- Claude Code running against any Claude model the gateway exposes, billed to your project's sponsor budget.
- No Anthropic account or
ANTHROPIC_API_KEYof your own.
Prerequisites
-
Your project access key and base URL from your project control panel. This guide writes them as
YOUR_PROJECT_KEYandhttps://v1.opentokenmarket.dev. -
Claude Code installed:
npm install -g @anthropic-ai/claude-code
Configure
Set these in your shell (add them to ~/.zshrc / ~/.bashrc to make them stick):
export ANTHROPIC_BASE_URL="https://v1.opentokenmarket.dev"
export ANTHROPIC_AUTH_TOKEN="YOUR_PROJECT_KEY"
ANTHROPIC_AUTH_TOKEN (not ANTHROPIC_API_KEY) is what Claude Code sends as the bearer
token to a custom endpoint.
To scope this to one project instead of your whole shell, put it in that project's
.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://v1.opentokenmarket.dev",
"ANTHROPIC_AUTH_TOKEN": "YOUR_PROJECT_KEY"
}
}
Run
Pick a model from the model catalog and pass it with --model:
claude --model claude-sonnet-4-6
Set a default for the session instead of typing it each time:
export ANTHROPIC_MODEL="claude-sonnet-4-6"
claude
If the gateway maps a 1M-context variant, request it with the [1m] suffix:
claude --model 'claude-sonnet-4-6[1m]'
Verify
Before launching the agent, confirm the gateway answers:
curl https://v1.opentokenmarket.dev/v1/messages \
-H "x-api-key: YOUR_PROJECT_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":64,"messages":[{"role":"user","content":"Say hi in 3 words."}]}'
A JSON response with a content array means you're connected.
Troubleshooting
401/invalid x-api-key— you setANTHROPIC_API_KEYinstead ofANTHROPIC_AUTH_TOKEN, or the key is wrong. Re-copy it from your project control panel.404on/v1/messages—ANTHROPIC_BASE_URLhas a trailing/v1. It should be the bare origin (https://v1.opentokenmarket.dev); Claude Code appends/v1/messagesitself.budget has been exceeded— the project's funded balance is spent. Ask your sponsor to top up.- Model not found — the name isn't on this gateway. Check the model catalog for the exact string.
Which model names to use
Use the Model name column from the model catalog verbatim — e.g.
claude-sonnet-4-6, not anthropic/claude-....