📖 查看中文版 →
Prerequisites #
- Claude Code installed — claude.ai/code
- A WoAiToken account with credits — to.woaitoken.com
- Your sub2api API key (get it in Step 1)
Step 1 — Get Your API Key #
1. Open the console
Visit to.woaitoken.com/console and sign in.
2. Create a token
Go to 令牌 (Tokens) → Add Token. Give it a name (e.g. "Claude Code"), set no expiration, then click Submit.
3. Copy the key
Copy the generated key — it starts with sk-. Save it immediately; it is only shown once.
Step 2 — Configure Claude Code #
Claude Code uses two environment variables to connect to a custom API endpoint:
ANTHROPIC_BASE_URL = "https://to.woaitoken.com"
ANTHROPIC_API_KEY = "sk-your-key-here"
Choose one method:
Method A — settings.json (Recommended) #
Edit or create ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://to.woaitoken.com",
"ANTHROPIC_API_KEY": "sk-your-key-here"
}
}
Save the file. Run claude immediately — no restart needed.
Method B — Shell profile (Permanent) #
macOS / Linux — add to ~/.zshrc or ~/.bashrc:
export ANTHROPIC_BASE_URL="https://to.woaitoken.com"
export ANTHROPIC_API_KEY="sk-your-key-here"
Then reload:
source ~/.zshrc
Windows PowerShell:
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL","https://to.woaitoken.com","User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY","sk-your-key-here","User")
Open a new terminal window after running.
Method C — One-time session (Testing only) #
ANTHROPIC_BASE_URL="https://to.woaitoken.com" \
ANTHROPIC_API_KEY="sk-your-key-here" \
claude
> ⚠ Only active for the current terminal session. Use Method A or B for permanent setup.
Step 3 — Verify #
Run the built-in health check:
claude doctor
A green ✓ next to API connectivity means everything is working.
Alternatively, run claude and send a short message like "hi" — a response confirms success.
Troubleshooting #
401 Unauthorized Check your API key is complete (including the sk- prefix) with no extra spaces.
Connection timeout Confirm ANTHROPIC_BASE_URL is exactly https://to.woaitoken.com — no trailing slash, no /v1 suffix. Claude Code appends path segments automatically.
429 Too Many Requests Your account credits are used up. Top up at woaitoken.com.
settings.json not taking effect Confirm the file is at ~/.claude/settings.json (not inside a project folder). Check for JSON syntax errors — a missing comma breaks the whole file.