How to connect Claude Code to the Tokenator API

Claude Code can talk to any Anthropic-compatible endpoint. Below is the full setup through Tokenator: two environment variables, picking a model from the catalog, and the errors people hit most often.

What you end up with

Once configured, Claude Code stops talking to its default provider and sends every request to Tokenator. Billing comes out of your key's token limit, and the list of available models is defined by the key rather than by the tool.

ToolClaude Code
ProtocolAnthropic-compatible
Base URLhttps://api.tokenator.top/anthropic
Keysk-your-tokenator-key

Requirements and supported operating systems

  • Windows 10/11, macOS 12+, or a modern 64-bit Linux.
  • Outbound HTTPS access to the Tokenator domain.
  • A Tokenator API key that looks like sk-your-tokenator-key.

Installing via npm requires Node.js LTS. Codex CLI also ships standalone binaries, in which case Node is not required.

Installing Claude Code

Install via npm
npm install -g @anthropic-ai/claude-code

Verify the binary is on your PATH: claude --version.

Setting up Tokenator

  1. Register in your account and buy a token bundle.
  2. The key appears in the account right after the payment is confirmed — copy it whole, including the prefix.
  3. The examples below use the placeholder sk-your-tokenator-key. Never publish a real key in repositories or screenshots.

Configuration through settings.json

Claude Code reads its settings from settings.json: the Tokenator address and the key are written there once, and the tool picks them up on every launch — nothing has to be typed into the terminal.

macOS and Linux: ~/.claude/settings.json — Windows: %USERPROFILE%\.claude\settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tokenator.top/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-tokenator-key",
    "ANTHROPIC_MODEL": "claude-opus-4-6"
  }
}

If the file does not exist yet, create it together with the .claude folder in your home directory. A ready-made settings.json with your key and model list can be downloaded from the key page, which opens from your account. If you have already signed in to Claude Code with an Anthropic subscription, the key from the file takes precedence; remove the env block to go back to the subscription.

Your first request

Before starting the tool it helps to confirm that the key and the model both work. A single curl request answers both questions.

Anthropic endpoint check
curl https://api.tokenator.top/anthropic/v1/messages \
  -H "x-api-key: sk-your-tokenator-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "ping"}]
  }'
Starting the agent
cd /path/to/project
claude

A successful response means the key is valid, the model is allowed for it and the upstream is reachable. Usage appears in your account right after the request.

Switching models

The model comes from ANTHROPIC_MODEL. Set a new value and restart the agent to switch.

Examples of model IDs available right now:

  • claude-haiku-4-5
  • claude-opus-4-6
  • claude-opus-4-7
  • claude-sonnet-4-6
  • gpt-5.5
  • deepseek-v4-pro

Current IDs and specs live in the AI model catalog, which also shows which models are available right now. The model comparison helps choose between close options.

Configuring reasoning

The key's reasoning level is switched in your account and applied on the Tokenator side — Claude Code needs no separate setting for it. With reasoning disabled for the key, requests are handled without extended thinking.

Note that thinking is billed as output tokens: the higher the level, the faster the key limit is consumed.

Common errors and how to fix them

SymptomCauseFix
The agent still calls AnthropicThe settings.json file is in the wrong folder, has a syntax error, or a saved Anthropic login overrides it.Check the file path and that the JSON is valid, then sign out of the subscription with /logout and start claude again.
401 or an invalid-key messageThe key was copied with stray spaces, was revoked, has expired, or landed in the wrong config field.Check the key in your account and make sure the tool reads the very config file you pasted it into.
403The model is not in the key's allowed-model list.Check the key's model list in your account and pick an ID from the model catalog.
429The per-minute or per-hour request limit, or the concurrent-stream limit for the key, was exceeded.Lower the agent's concurrency and retry with exponential backoff. Key limits are visible in your account.
Model not found / not supportedThe request used an ID that is not in the catalog, or an alias unavailable to this key.Copy the exact API ID from the model page — case and dots matter.
The request hangs or breaks on a long answerThe client closed the connection on its own timeout before the model finished generating.Turn on streaming (stream: true) and raise the client timeout: with long reasoning answers the first token can take a while.
A bare "Request error" with no detailsThe upstream provider returned an error. Its text is not passed through to the client.Retry: Tokenator fails over to the next provider for the model on its own. If it persists, contact support.

FAQ

Do I need a Claude Code subscription or a separate provider account?

No. The tool talks to Tokenator, and billing comes from your Tokenator key's tokens.

Where do I see usage after connecting?

In your account: it shows requests, spent tokens and the key's remaining limit.

Can one key be used in several tools?

Yes. The limits are the key's own: requests per minute and hour, plus the number of concurrent streams.

What happens if tokens run out mid-session?

Requests start returning an error. Topping up the same key restores the limit — no need to reinstall the tool.

How do I switch back to the previous provider?

Remove the settings you added — the provider block or the Tokenator key in the tool's config file. The tool reverts to its default behaviour.

Can non-Claude models be used through this endpoint?

Yes: Tokenator converts protocols, so the Anthropic-compatible endpoint accepts other catalog models too. Claude models remain the most compatible option.

Where can I read about the API format itself?

In the Tokenator API documentation and on the OpenAI-compatible API page.