Setup guide
Use the Anthropic SDK with a custom base URL
Yes. Anthropic SDK works with Token Supply. Keep the Anthropic SDK. Change the API key and base URL. Claude Code uses the same host; do not add /v1 to ANTHROPIC_BASE_URL.
Application code or a terminal
Create account Calculate savings
Key, host, messages
Create a Claude-plan key
Copy ts_live_... once from API Keys.
Set base_url
Use https://api.token-supply.com. The SDK appends /v1/messages.
Enable thinking
Set thinking budget tokens when you want higher reasoning effort.
Check Usage
Send a short Messages request, then confirm the debit on the dashboard.
Who this is for
Apps on the Anthropic SDK that can set base_url. Claude Code uses the same host and must not add /v1.
Anthropic SDK
Use a Claude-plan key. Claude models in this catalog use a 1,000,000 token context window. This example uses claude-sonnet-5. claude-haiku-4.5 is the Haiku id.
Claude Fable 5.1 (claude-fable-5-1), Opus 5.5 (claude-opus-5-5), and Haiku 5.5 (claude-haiku-5-5) can only be used inside the Claude Code CLI via Token Supply, due to Anthropic security settings.
The Anthropic SDK accepts the gateway URL with or without /v1; use the URL shown in API Keys. The direct API path is /v1/messages.
import anthropic
client = anthropic.Anthropic(
api_key="ts_live_...",
base_url="https://api.token-supply.com",
)
msg = client.messages.create(
model="claude-sonnet-5", # claude-haiku-4.5 is the Haiku id
max_tokens=32000,
thinking={"type": "enabled", "budget_tokens": 16000},
messages=[{"role": "user", "content": "hi"}],
)
Why this works: The Messages client is unchanged except base_url.
Anthropic-compatible curl
Messages also accept x-api-key.
curl https://api.token-supply.com/v1/messages \
-H "x-api-key: ts_live_..." \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-5","max_tokens":32000,"thinking":{"type":"enabled","budget_tokens":16000},"messages":[{"role":"user","content":"hi"}]}'
Why this works: The path is /v1/chat/completions, which matches the OpenAI-compatible contract.
- Use a model that belongs to the group attached to your key. gpt-6.1-sol, gpt-6-sol, gpt-6-luna, and gpt-6.1-terra are OpenAI ids. This example stays gpt-5.6-sol. gpt-6.1-sol reasoning effort is low, medium, high, xhigh, or max.
- Claude Fable 5.1 (claude-fable-5-1), Opus 5.5 (claude-opus-5-5), and Haiku 5.5 (claude-haiku-5-5) can only be used inside the Claude Code CLI via Token Supply, due to Anthropic security settings. This example uses claude-sonnet-5. claude-haiku-4.5 is the Haiku id.
- Do not log requests containing prompts or keys.
Related clients
Claude Code uses the same host through ANTHROPIC_BASE_URL. OpenCode's Anthropic preset expects /v1 in baseURL.
Details
- Does Anthropic SDK work with Token Supply?
- Yes. Apps on the Anthropic SDK that can set base_url. Claude Code uses the same host and must not add /v1.
- Should I add /v1 to the SDK base URL?
- Prefer the host without /v1. The SDK appends /v1/messages. OpenCode Anthropic is the exception and expects /v1.
- Which header carries the key?
- Authorization: Bearer works. Anthropic Messages also accept x-api-key.
- How do I raise reasoning effort?
- Enable thinking with a budget_tokens value, or use Claude Code's --effort / /effort controls.
Related
- Claude Code custom endpoint — ANTHROPIC_BASE_URL, auth token, and settings.json.
- OpenCode custom provider — OpenAI, Anthropic, Gemini, and Grok presets.
- OpenAI SDK custom base URL — Point the OpenAI client at Token Supply.
- Track AI API token usage — Prepaid wallet, usage dashboard, and per-key spend.
- Reduce coding-agent API costs — Keep your client and lower token spend on the same workload.