PL Log inOpen Studio
Preview version. Model catalog, prices, calculator and docs are live. Generation goes live at launch.

Point Claude Code at Kadraris - ANTHROPIC_BASE_URL, Token and Models

Set a custom ANTHROPIC_BASE_URL so Claude Code bills a prepaid Kadraris balance. Env vars, settings.json, model mapping, VS Code, CI and error fixes.

Claude Code needs exactly two environment variables to talk to Kadraris instead of Anthropic directly: ANTHROPIC_BASE_URL=https://kadraris.com and ANTHROPIC_AUTH_TOKEN=sk-kd-.... With those set, every request goes to the Anthropic-compatible /v1/messages endpoint on kadraris.com and is paid from your prepaid balance, not from a subscription or a separate Anthropic Console account. /status inside Claude Code shows whether it took effect.

This is the setup I run every day. Below: the shell commands for each system, a curl test, how to make it permanent, how model names map, the VS Code and CI variants, and a table of errors with fixes.

What changes and what does not

Claude Code is only a client for the Anthropic Messages API, and ANTHROPIC_BASE_URL tells it where that API lives. Anthropic's documentation calls this using an LLM gateway. The CLI, its tools and its commands behave the same; only the destination of the calls moves.

Why I send Claude Code through Kadraris:

  • Prepaid, no plan. I load a balance from $10 and it stays until I use it. No monthly fee and no minimum.
  • One balance for all of it. The key that pays for Claude in the terminal also pays for image and video jobs in my scripts and for chat models in my apps.
  • Rates you can read. Claude Opus 5.5 is $3.78 / $18.90 per 1M tokens and Claude Sonnet 5 is $3.24 / $16.20 per 1M tokens, both on the pricing page.
  • Your code is not training data. Prompts and results are not used to train models.

Test the key with curl first

Create an account, add funds and make a key in the dashboard. Kadraris keys begin with sk-kd-.

Before involving Claude Code at all, send one request by hand. If this works, any later problem is in the Claude Code config, not in the key or the balance:

bash
export ANTHROPIC_BASE_URL=https://kadraris.com
export ANTHROPIC_AUTH_TOKEN=sk-kd-...

curl -sS -w '\n%{http_code}\n' -X POST \
  "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 64,
    "messages": [{"role": "user",
                  "content": "Reply with the word ok."}]
  }'

You want a JSON reply and 200 on the final line. Notice the base URL ends at the domain, with no /v1. Claude Code appends /v1/messages by itself, so a base URL of https://kadraris.com/v1 produces a doubled, broken path.

Set the variables for one session

macOS and Linux

bash
export ANTHROPIC_BASE_URL=https://kadraris.com
export ANTHROPIC_AUTH_TOKEN=sk-kd-...
claude

Launch claude from that same shell so it picks the variables up.

Windows PowerShell

powershell
$env:ANTHROPIC_BASE_URL = "https://kadraris.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-kd-..."
claude

Bearer token or x-api-key

Claude Code knows two credential variables, and each one fills a different header:

VariableHeaderNote
ANTHROPIC_AUTH_TOKENAuthorization: Bearer ...my choice for Kadraris
ANTHROPIC_API_KEYx-api-key: ...Kadraris accepts it too

Kadraris reads either header. I stick with ANTHROPIC_AUTH_TOKEN because it overrides a stored claude.ai login right away, whereas ANTHROPIC_API_KEY makes you approve the key once in interactive mode.

Confirm it inside Claude Code

Type:

text
/status

On the Status tab look at two entries:

  • Anthropic base URL must read https://kadraris.com.
  • Auth token must point to ANTHROPIC_AUTH_TOKEN.

Then send any prompt. A normal answer means the whole chain works.

Keep it after the terminal closes

Exported variables disappear with the shell. For a permanent setup, write them into your user settings file:

  • macOS and Linux: ~/.claude/settings.json
  • Windows: %USERPROFILE%\.claude\settings.json
json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://kadraris.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-kd-..."
  }
}

When the shell and this file set the same variable, the file takes priority.

One rule I give everyone: the key does not belong in a project's .claude/settings.json. That file normally gets committed, and from then on every clone of the repo carries your key.

Map the model names

Kadraris serves Claude under fixed ids such as claude-opus-5.5, claude-sonnet-5 and claude-haiku-4.5. Pin them in the same env block so Claude Code never asks for an id the catalog does not have:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://kadraris.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-kd-...",
    "ANTHROPIC_MODEL": "claude-sonnet-5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5.5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4.5"
  }
}

The role of each line:

  • ANTHROPIC_MODEL is the model a new session opens with.
  • ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL set what the Opus and Sonnet entries of the /model menu point to.
  • ANTHROPIC_DEFAULT_HAIKU_MODEL also covers background jobs such as naming the session. With claude-haiku-4.5 those small calls stay on a low rate.

/model still switches models in the middle of a session.

A model for each kind of task

TaskModelReason
routine edits, tests, small refactorsClaude Sonnet 5quick, a slightly lower input and output rate, but no cache rate
big refactors, design, stubborn bugsClaude Opus 5.5stronger on long, messy context
background callsClaude Haiku 4.5tiny jobs, low rate

My routine: Sonnet unless it starts going in circles, then /model to Opus, and back once the hard part is done.

VS Code and GitHub Actions

VS Code extension

The extension checks for credentials before it starts, so the variables go into VS Code's own user settings (Preferences: Open User Settings (JSON)):

json
{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL",
      "value": "https://kadraris.com" },
    { "name": "ANTHROPIC_AUTH_TOKEN",
      "value": "sk-kd-..." }
  ]
}

GitHub Actions

For the Claude Code action, put the base URL and token in the workflow env, and also pass the key as anthropic_api_key, which the action insists on before it runs:

yaml
env:
  ANTHROPIC_BASE_URL: https://kadraris.com
  ANTHROPIC_AUTH_TOKEN: ${{ secrets.KADRARIS_API_KEY }}

steps:
  - uses: anthropics/claude-code-action@v1
    with:
      anthropic_api_key: ${{ secrets.KADRARIS_API_KEY }}

Watch the balance while you work

An agent eats tokens much faster than a chat window. A session that opens a lot of files sends a lot of input. Two habits help:

  1. Check the balance from the terminal:
bash
curl -s https://kadraris.com/v1/balance \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN"
  1. Keep sessions small. Start a fresh session for a new task rather than carrying one giant context, and use Sonnet for routine work.

If the balance runs dry, requests come back with 402. Claude Code prints an error, nothing is charged, and it works again the moment you top up. Preset amounts of $10, $25, $50, $100 and $250 make that two clicks. A step-by-step on what a session costs is in Claude Code cost per token.

When something fails

What you seeProbable causeWhat to do
401 on every calltypo in the key, or a header the endpoint ignorescopy the key again, keep ANTHROPIC_AUTH_TOKEN
404 on callsbase URL ends with /v1use exactly https://kadraris.com
404 mentioning a modelid not in the catalogpin the ids shown above
402balance too lowadd funds on pricing
/status shows an old URLsettings file beats the shelledit ~/.claude/settings.json
auth conflict warning on startan old ANTHROPIC_API_KEY is still setunset ANTHROPIC_API_KEY or /logout
429rate limitpause, then retry

Also note that features tied to a claude.ai identity, such as Remote Control and voice dictation, switch off while a gateway credential is active. That is Claude Code's rule, not a Kadraris one; unset the variables when you need them. Long sessions that hit limits are covered in Claude Code usage limit errors.

Other clients that work the same way

Anything speaking the Anthropic Messages API can use https://kadraris.com, and anything speaking the OpenAI API can use https://kadraris.com/v1. Cursor, n8n and Make all qualify. The OpenAI side is in one OpenAI SDK for every model; the reference pages are Claude Code docs and Anthropic Messages docs.

Questions

Do I need to log out of my claude.ai account first?

Not with ANTHROPIC_AUTH_TOKEN, which takes precedence over a saved login. If Claude Code warns about conflicting credentials, an old ANTHROPIC_API_KEY is usually still set; unset it or run /logout.

Why does Claude Code return 404 although the key is valid?

Two usual causes: a base URL that ends in /v1, or a model id the catalog does not know. Set the base URL to the bare domain and pin the model variables.

Can teammates share one balance with separate keys?

Yes. Create one key per person or per CI job in the dashboard, each with its own monthly cap. All of them draw from the same prepaid balance.

Does the setup work for the Claude Code GitHub Action?

Yes. Put the base URL and the token in the workflow env and pass the same secret as anthropic_api_key, as in the YAML example above.