Integrate TokenRealm in minutes.
Use the same TokenRealm credential for Claude Code and direct API requests. Your upstream provider credentials remain server-side.
Configure two environment variables.
Generate a tr_live_... key in the TokenRealm dashboard, then point Claude Code to the TokenRealm API origin.
export ANTHROPIC_BASE_URL="https://api.tokenrealm.fun"
export ANTHROPIC_API_KEY="tr_live_your_key"
claudeKeep your TokenRealm API key private. Rotate or revoke it from the dashboard if it is exposed.
Send a standard message request.
curl https://api.tokenrealm.fun/v1/messages \
-H "x-api-key: tr_live_your_key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"messages": [
{"role":"user","content":"Explain this repository."}
]
}'POST /v1/messagesGenerate messagesPOST /v1/messages/count_tokensCount request tokensGET /v1/modelsList exposed modelsUse full IDs or aliases.
TokenRealm currently exposes Fable 5.1, Opus 5.5, Sonnet 5.5, and Haiku 5.5. Short aliases resolve to the current model in each family.
"model": "sonnet"
// resolves to:
"model": "claude-sonnet-5-5"See the model comparison →Automatic by default, configurable per key.
Your API key can stay in automatic mode or be pinned to a configured provider from the dashboard. For debugging or advanced workflows, a request can also specify a provider override.
x-tokenrealm-provider: awsProvider options only work when the corresponding upstream integration has been configured by the operator.
Usage is reconciled after each request.
The gateway reserves an estimated amount before an upstream call, records returned usage metadata, then refunds any unused reservation. Recent usage appears in your dashboard.
Input
Prompt tokens and supported cache metadata.
Output
Tokens generated by the model.
Balance
Debited from prepaid TokenRealm credits.
Keep integrations secure and debuggable.
- Store
tr_live_...keys in environment variables or a secrets manager. - Use separate keys for separate machines or applications when possible.
- Revoke an exposed key immediately from the dashboard.
- Inspect HTTP status and returned error bodies before retrying.
- Use idempotent application logic for workflows that may retry automatically.