Before you start
You receive three different credentials—use each in the correct place:
- API Key
sk-value used to authenticate API requests.- API endpoint
https://api.buytoken.work. Send every API request here.- Username and password
- Use these to sign in, inspect usage, and change your password. They are not your API key.
Use only https://api.buytoken.work
The console is at https://buytoken.work/console. Open it in a browser to inspect usage, manage keys, and top up. Do not mix the two addresses: https://api.buytoken.work is the API endpoint for clients, https://buytoken.work is the human console and must not be used as a client API endpoint.
Which models you can call depends on this key’s Group:cc group calls Claude models, codex group calls GPT models, kimi-core group calls Kimi, the DeepSeek group calls DeepSeek. Supported providers are listed under Supported models.Prices and group notes are on the Model pricing.
Connect Claude models
Use Claude Code with CC Switch to manage providers. Install CC Switch once; Codex below uses the same app.
-
Install Node.js and Claude Code
Install Node.js 18+ from nodejs.org, then run this in a terminal (PowerShell on Windows, Terminal on Mac/Linux):
npm install -g @anthropic-ai/claude-code -
Install CC Switch
Download the installer for your OS from github.com/farion1231/cc-switch and complete the setup.
-
Add a provider in CC Switch
Open CC Switch, add a provider, choose “Custom configuration”, and fill in:
- Name
- Any name, such as “My relay”
- Endpoint
https://api.buytoken.work(if it does not work, append/v1and retry)- API Key
- Your
sk-key - API format
- Anthropic
Use this model mapping, then save and enable the provider:
- Default
claude-sonnet-5- Opus
claude-opus-5- Haiku
claude-haiku-4-5-20251001
-
Start using it
Run
claudein the terminal to start.VSCode, Cursor, and Trae users can install the Claude Code for VSCode extension—no sign-in or extra setup required.
Connect GPT · Codex
To use gpt-5.6-sol models, follow this section after installing CC Switch above.
-
Install Codex CLI or Codex Desktop
Both clients share one configuration. Install either or both; the CLI requires Node.js 18+:
npm install -g @openai/codexFor a graphical interface, download the official desktop app from openai.com/codex.
-
Add a Codex provider in CC Switch
Open CC Switch, select the Codex tab, add a provider, and choose “Custom configuration”:
- Name
- Any name, such as “buytoken-codex”
- Endpoint
https://api.buytoken.work/v1(/v1 is required)- API Key
- Your
sk-key - API format
- OpenAI
After saving and enabling it, CC Switch writes the endpoint and key to
~/.codex/config.toml; both CLI and desktop use this file. -
Start using it
Run
codexto enter the interactive UI and use/model gpt-5.6-solto switch models. In the desktop app, enter the model ID when creating a conversation.If the client still uses old settings after a CC Switch change, restart it.
Alternative: environment variables
If you prefer the command line, two environment variables are enough.
Mac / Linux
Edit ~/.zshrc (bash users: ~/.bashrc), append two lines, then source and run claude:
export ANTHROPIC_BASE_URL=https://api.buytoken.work
export ANTHROPIC_AUTH_TOKEN=sk-your-key
Windows
Run these two lines in PowerShell (persistent). Close and reopen PowerShell afterward or the changes will not apply.
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.buytoken.work", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-your-key", "User")
OpenAI-compatible clients
OpenAI-compatible tools such as Codex require /v1:
export OPENAI_BASE_URL=https://api.buytoken.work/v1
export OPENAI_API_KEY=sk-your-key
Verify the setup
Enter claude and send any message. A response confirms the setup. You can also use curl; returned JSON means success:
curl -sS https://api.buytoken.work/v1/messages \
-H "x-api-key: sk-your-key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-5","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}'
The gateway supports /v1/messages、/v1/responses and /v1/chat/completions; pass the key with x-api-key or Authorization: Bearer.
Using the console
Open https://api.buytoken.work/console in a browser and sign in with your account credentials to access:
- Overview
- See balance, monthly spend, and recent requests at a glance.
- My Keys
- View, copy, rename, disable, and create keys.
- Usage logs
- Inspect time, model, token counts, and charge for every request; open a row to see the calculation.
- Account settings
- Change your password; we recommend doing this after first sign-in.
After first sign-in, change the initial password, confirm your requests appear in Usage logs, and check your balance. Top up from Wallet using WeChat Pay.
Troubleshooting
401 Unauthorized
The key is not taking effect, usually because another config is still active. Check /status in claude for the gateway Base URL, disable other providers in CC Switch, and look for leftover values in ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json).
403 Your client is not authorized
Run /logout in claude, then start it again.
Insufficient balance, but the console still shows credit
Leftover config from another relay. Delete the config directory and follow this guide again.
# Mac / Linux
rm -rf ~/.claude
# Windows PowerShell
Remove-Item "$env:USERPROFILE\.claude" -Recurse -Force
The model name is correct but the request fails
The group is probably wrong: a Claude-group key cannot call gpt-*, and a Codex-group key cannot call claude-*. Check the group on My Keys or the pricing page. Copy model IDs exactly, including date suffixes—claude-haiku-4-5 fails; use claude-haiku-4-5-20251001.
Unable to connect, or a country restriction
The config did not apply; this service does not need a proxy. Reopen PowerShell after changing Windows environment variables; on Mac/Linux source ~/.zshrc or ~/.bashrc, or open a new terminal.
Windows: scripts are blocked / claude.ps1 cannot load
PowerShell execution policy is blocking it. Run the command below and enter Y or A when prompted.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Windows: claude is not recognized as a command
npm’s global install path is not on PATH. The command below prints the path(usually C:\Users\<Username>\AppData\Roaming\npm),Add it to the system environment variable PATH,then reopen the terminal。
npm config get prefix
Windows: git-bash is required
Install Git for Windows (git-scm.com/downloads/win) with defaults, then close and reopen PowerShell.
The VSCode / Cursor / Trae extension asks me to sign in
No sign-in is required. Reinstall the extension first; if that fails, set the endpoint and key explicitly in the extension settings.json.
{
"claudeCode.preferredLocation": "panel",
"claudeCode.environmentVariables": [
{"name": "ANTHROPIC_BASE_URL", "value": "https://api.buytoken.work"},
{"name": "ANTHROPIC_AUTH_TOKEN", "value": "sk-your-key"}
]
}
400 context_management: Extra inputs are not permitted
The client sent an experimental field the upstream rejects. Add this line in CC Switch env, save, and reopen the terminal.
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
Two reliable fixes
Most setup issues are solved by deleting ~/.claude, reopening the terminal, and following this guide again. Long Claude Code sessions accumulate context; run /clear after each task to clear it.
Still stuck? Contact us: QQ 3963059079。
BuyToken 交流 3 群