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 on Windows

PowerShell
$env:ANTHROPIC_BASE_URL = "https://api.tokenator.top/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-tokenator-key"
$env:ANTHROPIC_MODEL = "claude-opus-4-6"
claude
Persistently, for the current user (cmd)
setx ANTHROPIC_BASE_URL "https://api.tokenator.top/anthropic"
setx ANTHROPIC_AUTH_TOKEN "sk-your-tokenator-key"
setx ANTHROPIC_MODEL "claude-opus-4-6"

After setx, open a new terminal window — the current one will not pick the variables up.

Configuration on macOS and Linux

One-off, in the current shell
export ANTHROPIC_BASE_URL="https://api.tokenator.top/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-your-tokenator-key"
export ANTHROPIC_MODEL="claude-opus-4-6"
claude
Persistently, in ~/.zshrc or ~/.bashrc
echo 'export ANTHROPIC_BASE_URL="https://api.tokenator.top/anthropic"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-your-tokenator-key"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-opus-4-6"' >> ~/.zshrc
source ~/.zshrc

If you already sign in to Claude with an Anthropic subscription, ANTHROPIC_AUTH_TOKEN takes precedence — remove the variables 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-flash

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.

Usage restriction on Claude models

Claude models are provided for software development and writing code only. Any other use may lead to the key being blocked without compensation for unused tokens — see the terms of service for the exact wording.

Common errors and how to fix them

SymptomCauseFix
The agent still calls AnthropicThe environment variables were set in a different process, or a saved login overrides them.Launch claude from the same terminal where you ran export/setx and verify ANTHROPIC_BASE_URL.
401 or an invalid-key messageThe key was copied with stray spaces, was revoked, has expired, or landed in the wrong environment variable.Check the key in your account and make sure the environment variable actually reached the process running the tool.
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 environment variables or the provider block in the config. 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.