Use Claude Code with TokenMaster
Claude Code is Anthropic's terminal coding agent. TokenMaster speaks the Anthropic Messages API, so Claude Code runs on your TokenMaster balance with two environment variables — and can also drive GPT, Gemini, DeepSeek and other models.
You will need
- An API key starting with tm- (Console → API keys) — Get an API key
- Base URL:
https://tokenmaster.store - A model ID, e.g.
anthropic/claude-sonnet-5.5(see the model list)
Setup
- Install Claude Code if you have not already (see Anthropic's instructions), and create a
tm-…key in the TokenMaster console. - Add the
envblock below to~/.claude/settings.json(your user settings — not a project's.claude/settings.json, which is often committed to git). The base URL has no/v1: Claude Code adds/v1/messagesitself. - Make sure
ANTHROPIC_API_KEYis not set in your shell — if it is, Claude Code uses it instead of the TokenMaster key. - Run
claudein your project. The default Opus / Sonnet / Haiku models map to the newest Claude of the same family on TokenMaster; the optionalANTHROPIC_DEFAULT_*_MODELlines pin a model, including other vendors' models.
{
"env": {
"ANTHROPIC_BASE_URL": "https://tokenmaster.store",
"ANTHROPIC_AUTH_TOKEN": "tm-xxxxxxxx",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-5.5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-5.5"
}
}Good to know
- Using a non-Claude model: set e.g.
"ANTHROPIC_DEFAULT_SONNET_MODEL": "openai/gpt-6-sol". Tool use works with any model that supports function calling; results vary by model. - Billing is per token at TokenMaster prices, shown in the console. Claude Code's own
/costestimate uses Anthropic list prices, so it will not match. - Web search (the WebSearch tool) runs through TokenMaster web search and is billed per search. Extended-thinking blocks are not returned, and PDF attachments are not supported — paste the text instead.
- Set a daily or monthly spending limit on the key in the console (API keys → Limit) — agents can run many requests in a row.
- Not available through TokenMaster: image generation, speech, rerank, the Assistants API, and OpenAI-hosted tools. Chat Completions, the Responses API (stateless), the Anthropic Messages API and embeddings are available.
Checked against Claude Code 2.x on 2026-10-19. Menu names can change between versions.
Troubleshooting
- 401 / invalid API key — check the key was copied in full and has not been deleted in the console.
- 404 — the base URL is wrong. It must end in /v1 unless the guide says otherwise.
- Model not found / not available — use the exact ID from the model list (vendor/model, lowercase). Some vendors are not available in every region.
- Errors mentioning /responses — the tool is using OpenAI's Responses API. TokenMaster accepts it, but statelessly (no previous_response_id) and without OpenAI-hosted tools; if the tool relies on those, switch it to Chat Completions as noted above.
- 402 / insufficient balance — top up in the console; requests are refused rather than run up a debt.