Connect Claude Code, OpenClaw, Cline, Roo Code and any Anthropic-protocol client to TokenHub.
TokenHub exposes two protocols simultaneously. The same th- key works on both — billing, usage, spend caps and provider fallback are unified.
| Protocol | Endpoint | Base URL (paste this into the client) | Typical clients |
|---|---|---|---|
| OpenAI-compatible | POST /v1/chat/completions | https://tokenhub.store/api/v1 | openai SDK, LiteLLM, LangChain |
| Anthropic-native | POST /v1/messages | https://tokenhub.store/api | Claude Code, OpenClaw, Cline, Roo Code, anthropic SDK |
Use any of the IDs below as ANTHROPIC_MODEL or the model field. The anthropic/ prefix is optional — TokenHub accepts both forms.
| Model ID | Tier | Input ($/1M) | Output ($/1M) |
|---|---|---|---|
| claude-opus-4-7 | Most capable | $5.00 | $25.00 |
| claude-opus-4-6 | Main flagship | $5.00 | $25.00 |
| claude-sonnet-4-6 | Production default | $3.00 | $15.00 |
| claude-haiku-4-5 | Lightweight, high-QPS | $1.00 | $5.00 |
| claude-opus-4-5 | Main flagship | $5.00 | $25.00 |
| claude-sonnet-4-5 | Production default | $3.00 | $15.00 |
Every supported client boils down to these three values. The rest of this page is just where to put them.
https://tokenhub.store/apiANTHROPIC_API_KEY=""Set ANTHROPIC_API_KEY="" explicitly so the SDK does not fall back to api.anthropic.com# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
# or via npm
npm install -g @anthropic-ai/claude-code# ~/.zshrc or ~/.bashrc
export ANTHROPIC_BASE_URL="https://tokenhub.store/api"
export ANTHROPIC_AUTH_TOKEN="th-your-tokenhub-key"
export ANTHROPIC_MODEL="claude-opus-4-6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
export ANTHROPIC_API_KEY="" # must be empty, otherwise SDK falls back to api.anthropic.com
# then reopen the terminal and run:
cd /path/to/your/project
claude.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://tokenhub.store/api",
"ANTHROPIC_AUTH_TOKEN": "th-your-tokenhub-key",
"ANTHROPIC_MODEL": "claude-opus-4-6",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
"ANTHROPIC_API_KEY": ""
}
}> /status
Auth token: ANTHROPIC_AUTH_TOKEN
Anthropic base URL: https://tokenhub.store/apiIf base URL still shows api.anthropic.com — ANTHROPIC_API_KEY is not empty, the terminal was not restarted, or the VSCode integrated terminal inherited stale env.
curl -sS https://tokenhub.store/api/v1/messages \
-H "x-api-key: th-your-tokenhub-key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-6",
"max_tokens": 128,
"messages": [{"role":"user","content":"say hi"}]
}'curl -N -sS https://tokenhub.store/api/v1/messages \
-H "x-api-key: th-your-tokenhub-key" \
-H "Content-Type: application/json" \
-d '{"model":"claude-opus-4-6","stream":true,"max_tokens":128,"messages":[{"role":"user","content":"count 1 to 3"}]}'Event order: message_start → content_block_start → content_block_delta* → content_block_stop → message_delta → message_stop.
Runs 6 assertions in one shot (non-stream / Bearer / SSE order / auth errors / unsupported model / function calling).
BASE_URL=https://tokenhub.store TOKENHUB_API_KEY=th-xxxx \
bash scripts/test-messages-api.sh| Symptom | Most likely cause | Fix |
|---|---|---|
| 401 / authentication_error | x-api-key not sent, or an Anthropic official key was passed | Use a TokenHub th- key |
| 402 / permission_error | Account balance is 0, or the key's spend cap is exhausted | Top up via Dashboard → Billing, or remove the key's spend cap |
| 400 'model not supported' | Model ID typo / wrong case | Check §2 — bare or anthropic/ prefix both accepted |
| 503 'No upstream API key' | Upstream key for this model is not yet provisioned | Contact support |
| Stream cuts off mid-way | Client HTTP idle timeout too small | Raise idle timeout to ≥ 120s |
| /status still shows api.anthropic.com | ANTHROPIC_API_KEY not unset, or terminal not restarted | Run export ANTHROPIC_API_KEY="" then reopen the terminal |
| Tool call returns plain text | Routed to an upstream with weak tool_use support | Switch to claude-opus-4-6 / claude-sonnet-4-6, or contact support |
If you are calling Claude with the openai SDK, use the OpenAI-compatible guide instead.
Claude API (OpenAI-compatible) →