Skip to content

Claude Code ​

Claude Code is Anthropic's official command-line coding assistant. TokOne supports the Anthropic protocol, so you can use Claude models with the config below.

Install ​

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

Verify:

bash
claude --version

Configure ​

Claude Code uses two environment variables: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.

Base URL without /v1

Claude Code appends /v1/messages and similar paths itself. Set the Base URL to https://api.tokone.ai — without /v1, or you'll get a 404.

Temporary (current session)

bash
export ANTHROPIC_BASE_URL="https://api.tokone.ai"
export ANTHROPIC_AUTH_TOKEN="sk-xxx"
powershell
$env:ANTHROPIC_BASE_URL = "https://api.tokone.ai"
$env:ANTHROPIC_AUTH_TOKEN = "sk-xxx"

This only affects the current terminal session; new terminals need it set again.

Permanent

bash
echo 'export ANTHROPIC_BASE_URL="https://api.tokone.ai"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-xxx"' >> ~/.zshrc
source ~/.zshrc
bash
echo 'export ANTHROPIC_BASE_URL="https://api.tokone.ai"' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-xxx"' >> ~/.bashrc
source ~/.bashrc
powershell
# Persist as user-level environment variables
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.tokone.ai", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-xxx", "User")
# Close all terminals and reopen for it to take effect

Verify ​

In any code directory, run:

bash
claude "Reply with OK"

A reply means the config works.

FAQ ​

401 even though the key is correct ​

The two most common causes:

  • Wrong variable name: it must be ANTHROPIC_AUTH_TOKEN, not OPENAI_API_KEY or CLAUDE_API_KEY.
  • Base URL has /v1: Claude Code builds the path itself, so the Base URL should be the root domain only.

Env vars don't take effect ​

Only newly opened terminals pick up new environment variables. For permanent config, double-check the export statements in ~/.zshrc / ~/.bashrc have no syntax errors.

Switching from OAuth login to an API key ​

Claude Code prefers the OAuth token. Run claude logout first, then set the environment variables.

Next steps ​

  • Models — available Claude models and context
  • API Endpoints — Anthropic-compatible protocol notes