Claude Code Setup

Switch Claude Code to TokenLink and use any model

Claude Code is Anthropic's official command-line AI coding tool. With TokenLink, you can use Claude Code to call any model — not just the Claude family.

Environment variable setup

Add the following to ~/.zshrc or ~/.bashrc, then run source ~/.zshrc to apply:

# TokenLink Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL="https://tokenlink.stelarx.ai/anthropic"

# API Key (created in the TokenLink console)
export ANTHROPIC_AUTH_TOKEN="sk-xxxxxxxxxxxxxxxx"

# Default model (auto = automatically pick the best model)
export ANTHROPIC_MODEL="auto"

# Specify per model tier
export ANTHROPIC_DEFAULT_OPUS_MODEL="auto"
export ANTHROPIC_DEFAULT_SONNET_MODEL="auto"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="auto"

# Model used by sub-agents
export CLAUDE_CODE_SUBAGENT_MODEL="auto"

# Reasoning effort (low / medium / high / max)
export CLAUDE_CODE_EFFORT_LEVEL="max"

auto model selection

When all *_MODEL environment variables are set to auto, TokenLink automatically picks the best model based on your quota and available models — no manual selection needed. If you want a specific tier to always use a specific model, replace auto with a concrete model ID, e.g. export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro".

Configuration reference

Environment variableDescription
ANTHROPIC_BASE_URLTokenLink Anthropic-compatible endpoint
ANTHROPIC_AUTH_TOKENAPI Key, created in the console
ANTHROPIC_MODELDefault model, auto recommended
ANTHROPIC_DEFAULT_OPUS_MODELModel used when Claude Code requests the Opus tier
ANTHROPIC_DEFAULT_SONNET_MODELModel used when Claude Code requests the Sonnet tier
ANTHROPIC_DEFAULT_HAIKU_MODELModel used when Claude Code requests the Haiku tier
CLAUDE_CODE_SUBAGENT_MODELModel used for sub-agent tasks
CLAUDE_CODE_EFFORT_LEVELReasoning effort: low / medium / high / max

Verify the switch worked

After starting Claude Code, send a message:

> What model are you using right now?

If the returned model name matches the model you configured in TokenLink, the switch was successful.

Switching models

To switch models in Claude Code:

/model qwen3.7-plus

TokenLink automatically converts Claude Code's Anthropic-format request to Gemini format and sends it upstream.