Skip to content

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:

bash
npm install -g @anthropic-ai/claude-code

Or use the official install script on macOS / Linux:

bash
curl -fsSL https://claude.ai/install.sh | sh

Create the Claude Code config directory:

bash
mkdir -p ~/.claude

Edit ~/.claude/settings.json:

bash
vim ~/.claude/settings.json

Add the following configuration and replace YOUR_EXCHANGETOKEN_API_KEY with your ExchangeToken API Key:

json
{
  "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:

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

bash
source ~/.zshrc

On 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.

ScenarioModel IDNotes
High performanceclaude-opus-4-7Best for complex reasoning, architecture, and long-context tasks
Standard codingclaude-sonnet-4-6Balanced choice for day-to-day coding, refactoring, and debugging
Cost efficientgemini-2.5-proGood for general development tasks and cost-sensitive workloads

Example configuration using another model:

json
{
  "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:

bash
cd /path/to/your/project
claude

After 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:

text
> /status
Auth token: ANTHROPIC_API_KEY
Base URL: https://api.exchangetoken.ai
Model: claude-sonnet-4-6

You 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:

text
https://api.exchangetoken.ai

Also 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:

bash
node -v

400 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:

bash
npm install -g @anthropic-ai/claude-code@latest