Integrate Claude Code

Connect Claude Code to TokenCode to call any large language model via the Anthropic protocol.

Overview

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.

Configuration

Method 1: Environment Variables

Set the following environment variables in your terminal:

bash
export ANTHROPIC_API_KEY="sk-your-api-key"
export ANTHROPIC_BASE_URL="https://tokencode.dev"

Then run Claude Code directly:

bash
claude

Method 2: Configuration File

Edit ~/.claude/settings.json and add:

json
{
  "env": {
    "ANTHROPIC_API_KEY": "sk-your-api-key",
    "ANTHROPIC_BASE_URL": "https://tokencode.dev"
  }
}

Method 3: Project-Level Configuration

Create .claude/settings.json in your project root:

json
{
  "env": {
    "ANTHROPIC_API_KEY": "sk-your-api-key",
    "ANTHROPIC_BASE_URL": "https://tokencode.dev"
  }
}

Using Different Models

Once configured, you can specify models using the --model parameter:

bash
# 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

Verify Connection

Run the following command to verify your configuration:

bash
claude --model claude-sonnet-4-6 -p "Hello, verifying connection"

If you receive a normal response, the connection is configured successfully.

Troubleshooting

Connection Timeout

If you encounter a connection timeout, check:

  1. Is ANTHROPIC_BASE_URL set to https://tokencode.dev (without /v1)
  2. Is your API Key correct
  3. Can your network access tokencode.dev

Model Unavailable

If you receive a model not found error:

  1. Verify the model name spelling is correct
  2. Visit the homepage to view the full list of available models

Abnormal Response Format

If Claude Code cannot parse the response:

  1. Confirm that the model you're using supports Anthropic protocol conversion
  2. Try switching to a native Claude model to verify if it's a conversion issue
  3. If the problem persists, contact technical support