Use in Claude Code
Overview
Claude Code is Anthropic's official command-line AI coding assistant. By pointing Claude Code to ExchangeToken, you can use one API gateway to access Claude, GPT, Gemini, and other supported models.
Requirements
- Node.js 18 or later
- An ExchangeToken API Key from the console token management page
- npm, or access to the macOS / Linux install script
Security note
Do not commit API keys to public repositories. For team projects, prefer local environment variables or a local Claude Code settings file.
Setup
Install Claude Code
Install with npm:
npm install -g @anthropic-ai/claude-codeOr use the official install script on macOS / Linux:
curl -fsSL https://claude.ai/install.sh | shUse a Settings File (Recommended)
Create the Claude Code config directory:
mkdir -p ~/.claudeEdit ~/.claude/settings.json:
vim ~/.claude/settings.jsonAdd the following configuration and replace YOUR_EXCHANGETOKEN_API_KEY with your ExchangeToken API Key:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.exchangetoken.ai",
"ANTHROPIC_API_KEY": "YOUR_EXCHANGETOKEN_API_KEY",
"ANTHROPIC_MODEL": "claude-sonnet-4-6"
}
}TIP
Keep ANTHROPIC_BASE_URL set to https://api.exchangetoken.ai. To switch models, update only ANTHROPIC_MODEL.
Use Environment Variables
If you prefer shell-based configuration, add these variables to ~/.bashrc, ~/.zshrc, or your shell profile:
export ANTHROPIC_BASE_URL="https://api.exchangetoken.ai"
export ANTHROPIC_API_KEY="YOUR_EXCHANGETOKEN_API_KEY"
export ANTHROPIC_MODEL="claude-sonnet-4-6"Restart your terminal, or reload the relevant profile, for example:
source ~/.zshrcOn Windows, set the same variables in system environment variables and reopen Command Prompt or PowerShell.
Switch Models
Change ANTHROPIC_MODEL to switch the model used by Claude Code.
| Scenario | Model ID | Notes |
|---|---|---|
| High performance | claude-opus-4-7 | Best for complex reasoning, architecture, and long-context tasks |
| Standard coding | claude-sonnet-4-6 | Balanced choice for day-to-day coding, refactoring, and debugging |
| Cost efficient | gemini-2.5-pro | Good for general development tasks and cost-sensitive workloads |
Example configuration using another model:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.exchangetoken.ai",
"ANTHROPIC_API_KEY": "YOUR_EXCHANGETOKEN_API_KEY",
"ANTHROPIC_MODEL": "gemini-2.5-pro"
}
}TIP
Prefer models with Tool Calling support. You can check model capabilities, pricing, and availability in the ExchangeToken model page.
Start a Session
Open your project directory and start Claude Code:
cd /path/to/your/project
claudeAfter the configuration takes effect, Claude Code requests will be routed through the ExchangeToken API gateway.
Verify Configuration
Run /status inside Claude Code to check the auth token source, Base URL, and model:
> /status
Auth token: ANTHROPIC_API_KEY
Base URL: https://api.exchangetoken.ai
Model: claude-sonnet-4-6You can also check usage or billing records in the ExchangeToken console to confirm requests are reaching the platform.
Troubleshooting
API Error: Connection error
Check that ANTHROPIC_BASE_URL is exactly:
https://api.exchangetoken.aiAlso confirm your network can reach the ExchangeToken API and that your proxy, firewall, or corporate network policy is not blocking the request.
Invalid auth token or 401
Make sure ANTHROPIC_API_KEY is an ExchangeToken API Key and that the key has not been deleted, disabled, or limited by quota.
env: node: No such file or directory
Claude Code requires Node.js. Install Node.js 18 or later and confirm node is available in the current terminal:
node -v400 tools.*.custom.input_examples: Extra inputs are not permitted
This is usually related to Claude Code version or model tool-calling compatibility. Upgrade Claude Code first:
npm install -g @anthropic-ai/claude-code@latest