Connect Claude Code to TokenCode to call any large language model via the Anthropic protocol.
Claude Code is Anthropic's official command-line AI coding assistant, which natively uses the Anthropic Messages API protocol. With TokenCode's automatic protocol conversion, you can call OpenAI, Gemini, and other models in Claude Code without any OpenAI interface adaptation work.
Set the following environment variables in your terminal:
export ANTHROPIC_API_KEY="sk-your-api-key"
export ANTHROPIC_BASE_URL="https://tokencode.dev"
Then run Claude Code directly:
claude
Edit ~/.claude/settings.json and add:
{
"env": {
"ANTHROPIC_API_KEY": "sk-your-api-key",
"ANTHROPIC_BASE_URL": "https://tokencode.dev"
}
}
Create .claude/settings.json in your project root:
{
"env": {
"ANTHROPIC_API_KEY": "sk-your-api-key",
"ANTHROPIC_BASE_URL": "https://tokencode.dev"
}
}
Once configured, you can specify models using the --model parameter:
# Use Claude Sonnet
claude --model claude-sonnet-4-6
# Use GPT-4o (automatic protocol conversion)
claude --model gpt-5.5
# Use Gemini 2.5 Pro (automatic protocol conversion)
claude --model gemini-2.5-pro
# Use DeepSeek (automatic protocol conversion)
claude --model deepseek-chat
Run the following command to verify your configuration:
claude --model claude-sonnet-4-6 -p "Hello, verifying connection"
If you receive a normal response, the connection is configured successfully.
If you encounter a connection timeout, check:
If you receive a model not found error:
If Claude Code cannot parse the response: