If you do not have an API Key yet, read Get API Key. To confirm available model names, check Chat models.
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:- An AiToEarn account.
- AiToEarn API Key.
- 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.
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:Windows
Open PowerShell as administrator, then run:claude command is not found after installation, add Claude Code to your PATH:
- Press
Win + Xand choose System. - Click Advanced system settings.
- Click Environment Variables.
- Under System variables, select
Pathand click Edit. - Click New and add
C:\Users\YourUsername\.claude\bin. - Click OK to save.
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.
Method 1: Permanent Configuration (Recommended)
macOS and Linux
If you use Zsh, add these lines to~/.zshrc:
~/.bashrc or ~/.bash_profile, then run the matching source command.
Windows PowerShell
China site:Windows Command Prompt
China site:Method 2: Temporary Configuration
Temporary configuration only applies to the current terminal session. It is useful for quick testing. macOS and Linux:ANTHROPIC_BASE_URL to https://aitoearn.ai/api/ai.
Method 3: Claude Code Settings File
Create or edit~/.claude/settings.json:
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:
Save and enable the provider, then start Claude Code to test.
Verify the Setup
After starting Claude Code, enter:Anthropic base URL points to your AiToEarn URL, the base configuration is active.
You can also send a test message:
Troubleshooting
Invalid API Key
- Confirm the key comes from AiToEarn API Key.
- Make sure you are not using
ANTHROPIC_AUTH_TOKENas 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_URLto/api/ai/v1/messages.
Claude Code Not Found
macOS and Linux:~/.claude/bin is in PATH.
Windows:
Confirm PATH includes:
claude --version again.
