Claude Code
Run Claude Code on GreenTokens with two environment variables.
Set up
Claude Code talks to the Anthropic Messages API, which GreenTokens serves. Point it at GreenTokens with two environment variables, and map its model slots to GreenTokens model IDs:
export ANTHROPIC_BASE_URL="https://api.greentokens.io"
export ANTHROPIC_AUTH_TOKEN="sk-gt-…"
# Map Claude Code's model slots to GreenTokens model IDs
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
claudeUse
https://api.greentokens.io without /v1: Claude Code adds the path itself.Make it permanent
To avoid exporting the variables in every shell, put them in Claude Code's settings file. Use .claude/settings.json inside a project to apply them to that project only.
~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.greentokens.io",
"ANTHROPIC_AUTH_TOKEN": "sk-gt-…",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5"
}
}Choosing models
- Switch models inside a session with
/model. The Opus, Sonnet and Haiku choices use the IDs you mapped above. - Any Claude model from the models page works: swap the IDs in the variables to change which one each slot uses.
- Claude Code uses the Haiku slot for small background tasks, so pointing it at a cheaper model saves money without affecting your main conversation.
Keeping costs in check
- Create a dedicated key for Claude Code with a daily spend limit on the API Keys page. Agentic sessions can use a lot of tokens.
- Claude Code reuses long prompts between turns, which GreenTokens bills at the lower cached-input price.
- Every call appears in the dashboard's Requests log with its model, tokens and cost.