Skip to main content
This guide shows how to configure Claude Code CLI to use AiToEarn’s Anthropic compatible endpoint. After setup, you can call language models available on AiToEarn from your terminal through Claude Code.
If you do not have an API Key yet, read Get API Key. To confirm available model names, check Chat models.
AiToEarn uses ANTHROPIC_API_KEY, not ANTHROPIC_AUTH_TOKEN. If you are adapting another third-party guide, make sure the authentication variable is ANTHROPIC_API_KEY.

What Is Claude Code?

Claude Code is Anthropic’s official command-line interface tool. It brings an AI assistant into your terminal and coding workflow. By configuring AiToEarn’s Anthropic compatible endpoint, you can keep the Claude Code workflow while sending requests through your AiToEarn API Key.

Prerequisites

Before you start, make sure you have:
  1. An AiToEarn account.
  2. AiToEarn API Key.
  3. Access to Terminal, PowerShell, or Command Prompt.

Choose a Base URL

AiToEarn API Keys are bound to the site where they were created. ANTHROPIC_BASE_URL must match the site of your API Key.
SiteANTHROPIC_BASE_URL
China sitehttps://aitoearn.cn/api/ai
International sitehttps://aitoearn.ai/api/ai
Do not append /v1/messages to ANTHROPIC_BASE_URL. Claude Code sends Anthropic Messages style requests, which will be routed to AiToEarn’s Anthropic messages endpoint.

Install

Choose the instructions for your operating system.

macOS and Linux

Open Terminal and run:
curl -fsSL https://claude.ai/install.sh | sh
Verify the installation:
claude --version

Windows

Open PowerShell as administrator, then run:
irm https://claude.ai/install.ps1 | iex
If the claude command is not found after installation, add Claude Code to your PATH:
  1. Press Win + X and choose System.
  2. Click Advanced system settings.
  3. Click Environment Variables.
  4. Under System variables, select Path and click Edit.
  5. Click New and add C:\Users\YourUsername\.claude\bin.
  6. Click OK to save.
Restart your terminal and verify:
claude --version

Configure Environment Variables

Claude Code reads two environment variables:
  • ANTHROPIC_API_KEY: your AiToEarn API Key.
  • ANTHROPIC_BASE_URL: AiToEarn’s Anthropic compatible base URL, selected by site.

macOS and Linux

If you use Zsh, add these lines to ~/.zshrc:
export ANTHROPIC_API_KEY="your AiToEarn API Key"
export ANTHROPIC_BASE_URL="https://aitoearn.cn/api/ai"
If you use an international API Key, change the second line to:
export ANTHROPIC_BASE_URL="https://aitoearn.ai/api/ai"
Apply the changes:
source ~/.zshrc
If you use Bash, add the same lines to ~/.bashrc or ~/.bash_profile, then run the matching source command.

Windows PowerShell

China site:
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'your AiToEarn API Key', 'User')
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://aitoearn.cn/api/ai', 'User')
International site:
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'your AiToEarn API Key', 'User')
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://aitoearn.ai/api/ai', 'User')
Restart your terminal after setting the variables.

Windows Command Prompt

China site:
setx ANTHROPIC_API_KEY "your AiToEarn API Key"
setx ANTHROPIC_BASE_URL "https://aitoearn.cn/api/ai"
International site:
setx ANTHROPIC_API_KEY "your AiToEarn API Key"
setx ANTHROPIC_BASE_URL "https://aitoearn.ai/api/ai"
Restart your terminal after setting the variables.

Method 2: Temporary Configuration

Temporary configuration only applies to the current terminal session. It is useful for quick testing. macOS and Linux:
export ANTHROPIC_API_KEY="your AiToEarn API Key"
export ANTHROPIC_BASE_URL="https://aitoearn.cn/api/ai"
Windows PowerShell:
$env:ANTHROPIC_API_KEY="your AiToEarn API Key"
$env:ANTHROPIC_BASE_URL="https://aitoearn.cn/api/ai"
Windows Command Prompt:
set ANTHROPIC_API_KEY=your AiToEarn API Key
set ANTHROPIC_BASE_URL=https://aitoearn.cn/api/ai
International site users should change ANTHROPIC_BASE_URL to https://aitoearn.ai/api/ai.

Method 3: Claude Code Settings File

Create or edit ~/.claude/settings.json:
{
  "env": {
    "ANTHROPIC_API_KEY": "your AiToEarn API Key",
    "ANTHROPIC_BASE_URL": "https://aitoearn.cn/api/ai"
  }
}
International site users should change ANTHROPIC_BASE_URL to https://aitoearn.ai/api/ai.

Method 4: CC Switch

If you use CC Switch to manage multiple Claude Code providers, add an AiToEarn provider:
FieldValue
Provider nameAiToEarn
NotesAiToEarn
Websitehttps://aitoearn.cn or https://aitoearn.ai
API KeyYour AiToEarn API Key
Request URLChina site: https://aitoearn.cn/api/ai; international site: https://aitoearn.ai/api/ai
API formatAnthropic Messages or Anthropic-compatible
Model nameCopy an available model name from Chat models
Save and enable the provider, then start Claude Code to test.

Verify the Setup

After starting Claude Code, enter:
/status
If Anthropic base URL points to your AiToEarn URL, the base configuration is active. You can also send a test message:
claude "Hi"
Check environment variables: macOS and Linux:
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_API_KEY
Windows PowerShell:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_API_KEY

Troubleshooting

Invalid API Key

  • Confirm the key comes from AiToEarn API Key.
  • Make sure you are not using ANTHROPIC_AUTH_TOKEN as the authentication variable.
  • Check for leading or trailing spaces in the API Key.
  • Confirm the API Key site matches ANTHROPIC_BASE_URL.

Connection Failed

  • Confirm your network can access the site you selected.
  • China site uses https://aitoearn.cn/api/ai.
  • International site uses https://aitoearn.ai/api/ai.
  • Do not set ANTHROPIC_BASE_URL to /api/ai/v1/messages.

Claude Code Not Found

macOS and Linux:
which claude
If it is not found, make sure ~/.claude/bin is in PATH. Windows: Confirm PATH includes:
C:\Users\YourUsername\.claude\bin
Restart your terminal and run claude --version again.