Skip to content

Anthropic Base URL and Auth Token: Setup Guide

Updated · TokenomixAI

The Anthropic base URL is the endpoint Claude Code sends every request to, and ANTHROPIC_AUTH_TOKEN is the credential it uses there. Both go in the env block of ~/.claude/settings.json. This guide explains what each variable does, which value to use, and how to verify the key.

ANTHROPIC_BASE_URL decides where Claude Code sends requests and ANTHROPIC_AUTH_TOKEN decides the credential; for the TokenomixAI gateway you set the base URL without /v1, because Claude Code adds that path itself.

What Is the anthropic base url and Auth Token?

Claude Code doesn't hardcode a server address. It reads ANTHROPIC_BASE_URL from the environment every time a session starts. If the variable is empty, Claude Code falls back to Anthropic's default endpoint.

ANTHROPIC_AUTH_TOKEN is the credential sent to that address. Its value is a plain token string, and for TokenomixAI it starts with sk-tkx-. The two variables work as a pair: the base URL decides where a request goes, the auth token decides who is sending it.

Base URL here means the root of the address, not the full endpoint. Claude Code appends /v1/messages itself, so you only fill in the gateway domain with no path at all.

Where to Set Both Variables in Claude Code

In Claude Code, both variables go in the env block of ~/.claude/settings.json. On Windows the file is %USERPROFILE%\.claude\settings.json. If the file doesn't exist yet, create it with content like this:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tokenomixai.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-tkx-..."
  }
}

If the file already holds other settings, add the two keys to the existing env object. Don't overwrite the rest of the file, because Claude Code keeps using the settings you configured earlier.

The documented TokenomixAI path is the env block in that file. If you set environment variables some other way, check the precedence rules first in the docs.

The Correct anthropic base url for a Gateway

For the TokenomixAI gateway the correct value is https://api.tokenomixai.com, with no /v1 at the end. This is the exception among the supported tools, because Claude Code appends /v1/messages on its own.

If you write https://api.tokenomixai.com/v1, requests land on the wrong path and the server answers with an error. The symptom is usually a 404 or an endpoint-not-found message, not a message about the token.

What you needValue to set
ANTHROPIC_BASE_URL for Claude Codehttps://api.tokenomixai.com
ANTHROPIC_AUTH_TOKENAPI key in sk-tkx-... format
Base URL for OpenAI-compatible SDKshttps://api.tokenomixai.com/v1

This difference trips people up when they run Claude Code and OpenCode side by side. Both can use the same key, but the base URL values are not identical. The longer walkthrough of running other models through the gateway is in Claude Code different model.

ANTHROPIC_AUTH_TOKEN itself needs no URL or extra prefix. Just the key string, without quotes if you fill it in through the installer.

Automatic Setup With a One-Command Installer

Instead of editing the file by hand, you can use the one-command installer. The script writes ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN into the env block of the Claude Code settings file.

Run this in a macOS or Linux terminal:

bash <(curl -fsSL https://tokenomixai.com/install/claude.sh)

On Windows, run it in PowerShell:

irm https://tokenomixai.com/install/claude.ps1 | iex

The script asks for the API key first, and the key is never put in a URL. It makes a backup before writing and keeps the other settings already in the file.

If you want to read the script before running it, start from the Claude Code setup page.

How to Check Key Quota and Rate Limits

Once both variables are set, the first thing worth checking isn't Claude Code, it's the key. The quota endpoint returns the remaining tokens and the key status:

curl https://api.tokenomixai.com/v1/quota -H "Authorization: Bearer sk-tkx-..."

The fields that matter: status is active or exhausted, remainingTokens and maxTokens show what's left and the ceiling, usagePercent is how much you've spent, expiresAt is the expiry time, and low is true at 10% or less.

Quota is counted in tokens, not time windows, so there's no 5-hour cap. The key keeps working while tokens remain and before it expires. A rate limit does apply: 600 requests per minute per account, shared by all its keys, and above that the API returns 429 with a Retry-After header.

If Claude Code rejects a request but the quota endpoint answers normally, look at the base URL. Check for a stray /v1 and make sure the token wasn't truncated when you copied it. When quota comes back after it runs out is covered in Claude Code limit reset.

Switching Back to the Anthropic Endpoint

To go back to Anthropic's default endpoint, run restore. On macOS or Linux:

bash <(curl -fsSL https://tokenomixai.com/install/claude.sh) --restore

On Windows PowerShell, set RESTORE first:

$env:RESTORE="1"; irm https://tokenomixai.com/install/claude.ps1 | iex

Restore returns the settings to the state before the installer ran. If you set the two variables by hand, just delete both keys from the env block and save the file. Other restore details are in the documentation.

Frequently asked questions

Does ANTHROPIC_BASE_URL need a trailing /v1?

No. Claude Code appends /v1/messages itself, so for TokenomixAI the value is just https://api.tokenomixai.com. If you add /v1 the path doubles up and the request fails. Check the quota endpoint first to confirm the key is healthy before blaming the base URL.

Does changing the base URL also change the Claude Code model?

No. The base URL only moves the endpoint; the model is whatever model name you use in the session. The list of available models and the names to write live on /en/docs, because the list changes.

How do I know my token is still enough?

Call the quota endpoint with your key, then read status, remainingTokens and usagePercent. If low is true, you're at 10% or less. A top-up adds tokens to the existing quota and the key stays the same.

Can one key be used in Claude Code and other tools?

Yes. One sk-tkx- key works across many models and many tools, including OpenCode, Cline, Cursor, n8n and plain scripts. Fill the base URL without /v1 for Claude Code, and with /v1 for OpenAI-compatible SDKs. The 600 requests per minute limit applies per account and is shared by all its keys.

Does the gateway store my prompts?

No. Only request metadata is logged: model, token count, time and status. Prompt and completion content is not stored.

More articles