Claude Code
Use Anthropic Claude Code CLI with Token101 as the API backend.
Claude Code Integration Guide
Claude Code is Anthropic's official AI coding assistant. Token101 fully supports Claude Code via the Anthropic Messages API (/api/v1/messages), so you can use your own API key budget, model routing, and usage tracking while working with Claude Code.
Token101 is an Anthropic-compatible gateway. Claude Code works with Token101 without any modifications — just set two environment variables.
Prerequisites
- Node.js 20 or later (nodejs.org)
- A Token101 API Key — subscription users can create one directly; free users need to complete API activation first at token.ppthub.shop/settings/apikeys
- Claude Code installed (see Step 1 below)
Step 1 — Install Claude Code
Windows Installation (Windows 11 Example)
Visit claude.com/product/claude-code to download Claude Code.

Open PowerShell on Windows and run:
irm https://claude.ai/install.ps1 | iex
You can see the installation was successful, with a prompt: "Native installation exists but C:\Users\ameureka.local\bin is not in your PATH. Add it by opening: System Properties > Environment Variables > Edit User PATH > New > Add the path above. Then restart your terminal."
The local installation exists, but C:\Users\ameureka\.local\bin is not in your PATH environment variable. Follow the steps below to add it: open System Properties > Environment Variables > Edit User PATH > New > Add the path above, then restart your terminal.
Running claude --version shows the error below, indicating the Claude Code executable hasn't been added to the system environment variables yet. If you don't see an error, you can skip ahead — otherwise, let's fix this.

Key Step: Add the Path to Environment Variables (PATH)
You need to add the installation path, e.g. C:\Users\ameureka\.local\bin, to your system PATH.
1. Open Environment Variables Settings
User > System > Advanced System Settings > Advanced

2. Edit the Path Variable
- In the popup window, look at the upper section for the "Environment Variables" list.

- Find the variable named
Path, select it, and click "Edit" below.
3. Add a New Path
- In the edit window that appears, click "New" on the right.
- Copy and paste the following path:
%USERPROFILE%\.local\binNote: use your actual path, e.g.C:\Users\ameureka\.local\bin

- Click "OK" through all setting windows to close them.
4. Restart the Terminal (Most Critical Step)
After modifying environment variables, you must close the current PowerShell window.
- Close it, then open a new PowerShell window.
- Test again with:
claude --version
This time the system will successfully recognize and display the version number.
macOS Installation
Visit claude.com/product/claude-code to download Claude Code.

curl -fsSL https://claude.ai/install.sh | bash
Verify the installation:
claude --versionStep 2 — Configure Environment Variables (Background Knowledge, Can Skip)
Claude Code connects to the API backend via these two environment variables:
| Variable | Value |
|---|---|
ANTHROPIC_BASE_URL | https://token.ppthub.shop/api |
ANTHROPIC_AUTH_TOKEN | Your Token101 API Key (starts with sk-) |
Token101 accepts two auth variables and you only need one. ANTHROPIC_AUTH_TOKEN makes Claude Code send Authorization: Bearer ... and matches what the one-command install script writes, so it is the recommended choice. ANTHROPIC_API_KEY makes Claude Code send X-Api-Key: ... and is equally accepted — if you already use it, you can keep it. Just don't set both at once, or the header Claude Code actually sends becomes version-dependent.
Windows — Permanently Set User Environment Variables
Run the following commands in PowerShell to persist the variables to user environment (they persist after restart):
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://token.ppthub.shop/api", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-xxxx...your-api-key", "User")
To also make them effective in the current PowerShell session, you can temporarily set:
$env:ANTHROPIC_BASE_URL = "https://token.ppthub.shop/api"
$env:ANTHROPIC_AUTH_TOKEN = "sk-xxxx...your-api-key"macOS / Linux — Permanently Write to Config File (~/.zshrc)
echo 'export ANTHROPIC_BASE_URL="https://token.ppthub.shop/api"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-xxxx...your-api-key"' >> ~/.zshrc
source ~/.zshrcThe third source command reloads the config file, making the environment variables you just added take effect immediately — no need to close and reopen the terminal.
Replace sk-xxxx...your-api-key with your actual API Key. Note that the Anthropic SDK Base URL uses /api (not /api/v1).
Step 3 — Configure Claude Code
On first launch, type claude in PowerShell or your terminal. Claude Code will guide you through the initial configuration:

Select the default Dark Mode, press Enter.


Select continue, press Enter.

Step 4 — Quick One-Line Setup for Token101 API with Claude Code
For details, see One-Line Setup.
Run the following command to quickly connect to Token101:
macOS / Linux
bash <(curl -fsSL https://token.ppthub.shop/scripts/setup-token101-claude-code-mac-hub.sh)

Windows (PowerShell)
powershell -ExecutionPolicy Bypass -Command "& { Invoke-WebRequest -Uri 'https://token.ppthub.shop/scripts/setup-token101-claude-code-win-hub.ps1' -OutFile 'setup-token101-claude-code-win-hub.ps1'; ./setup-token101-claude-code-win-hub.ps1 }"Or download first, then execute:
Invoke-WebRequest -Uri 'https://token.ppthub.shop/scripts/setup-token101-claude-code-win-hub.ps1' -OutFile 'setup-token101-claude-code-win-hub.ps1'
powershell -ExecutionPolicy Bypass -File ./setup-token101-claude-code-win-hub.ps1Interactive mode (recommended) — the script will walk you through model mapping, launch options, and more:
powershell -ExecutionPolicy Bypass -File ./setup-token101-claude-code-win-hub.ps1Non-interactive mode — pass your API Key as a parameter, using recommended defaults throughout without manual selection:
powershell -ExecutionPolicy Bypass -File ./setup-token101-claude-code-win-hub.ps1 -ApiKey sk-your-keyIf you encounter a "script execution is disabled" error, first run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser


Tip: Restart your terminal — after setup is complete, close and reopen PowerShell to ensure the environment variables take effect.

Step 5 — Use Claude Code in Your Project
Navigate to your project directory and start using Claude Code:
cd ~/my-project
# Ask a question about your project
claude -p "What does this project do?"
# Interactive mode
claude
# Run with elevated permissions (skips permission prompts, suitable for personal dev environments)
claude --dangerously-skip-permissionsSupported Models
In Claude Code, switch between model slots to access different Token101 API routes:
| Slot | Model ID | Best For |
|---|---|---|
sonnet | claude-sonnet-4-5-20250929 | Daily driver — coding, balanced performance |
opus | claude-opus-4-6 | Flagship reasoning, deep analysis |
haiku | claude-haiku-4-5-20251001 | Lightweight background tasks |
subagent | claude-haiku-4-5-20251001 | Parallel execution |
| Custom | gpt-5.3-codex | Code-specialized alternative |
See Supported Models for the complete list.
How It Works
Claude Code communicates using the Anthropic Messages API format. When you set ANTHROPIC_BASE_URL to Token101:
- Claude Code sends requests to
https://token.ppthub.shop/api/v1/messages - Token101 validates your API key and enforces rate limits and billing
- Token101 routes the request to the appropriate AI model
- The response (including streamed tokens) returns through the same pipeline
Token101 preserves the full Anthropic Messages API contract: system messages, multi-turn conversations, tool use, and streaming all work as expected.
Counting Tokens
Claude Code automatically calls POST /api/v1/messages/count_tokens before sending a request to estimate the prompt size. You can call it directly with the same API key you use for /api/v1/messages — it is free and does not use any of your credits.
curl https://token.ppthub.shop/api/v1/messages/count_tokens \
-H "Authorization: Bearer sk-xxxx...your-api-key" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [{"role": "user", "content": "Hello"}]
}'The response returns the input token count:
{ "input_tokens": 8 }Token counting is available for Claude (Anthropic-compatible) models only. Other models return a 400 error.
Troubleshooting
Error: Missing API key or Invalid API key
- Check that
ANTHROPIC_AUTH_TOKEN(orANTHROPIC_API_KEY, if that is the one you set) is present:echo $ANTHROPIC_AUTH_TOKEN - Verify the key is active at token.ppthub.shop/settings/apikeys
- Confirm the key starts with
sk-
Base URL Format Issues
Claude Code (Anthropic SDK) uses /api as the base URL, not /api/v1:
# Correct
export ANTHROPIC_BASE_URL="https://token.ppthub.shop/api"
# Wrong — this is for OpenAI SDK / Codex CLI
export ANTHROPIC_BASE_URL="https://token.ppthub.shop/api/v1"Error: 429 Too Many Requests
You've hit the rate limit. See Rate Limits for details.
Claude Code Works but Returns the Wrong Model
Check that the model alias you're using is supported. Use claude -p "what model are you?" to confirm which model is responding.
Next Steps
- One-Line Setup — configure Claude Code with a single command
- Supported Models — view all available models
- Rate Limits — understand your request quotas
- Billing — track and manage your usage
- Codex CLI Integration — setup instructions if you also use Codex CLI