TTodAPI

Claude Code

Connect Claude Code to TodAPI

Claude Code talks to an Anthropic-compatible gateway through two environment variables. On TodAPI the base URL is the site root — not the OpenAI-compatible /v1 path. This page only describes what the public guide already documents, plus the mistakes that usually break the first session.

Create an account if you do not have one yet, then top up — you must top up before the first API call; signing up does not include free usage. Create or configure a key when you are ready. The general OpenAI path is in the integration guide.

Before you set any variables

  1. Open API keys and create a key.
  2. Assign that key to an Anthropic group. The guide states that a key from the wrong group will fail when you call a model that group does not serve.
  3. Open the model plaza (no trailing slash), find that group, and copy the model ID exactly. Do not type a Claude marketing name from memory.

The two values Claude Code needs

VariableValue on TodAPIWhy
ANTHROPIC_BASE_URLhttps://todapi.workClaude Code appends /v1/messages itself. If you add /v1 here, the request becomes /v1/v1/messages and fails.
ANTHROPIC_AUTH_TOKENyour sk-… keySent as Authorization: Bearer. This is the form the public guide uses.
ANTHROPIC_MODEL (optional, useful)the plaza model IDStops Claude Code from calling a default id that is not in your group.

This is different from OpenAI-compatible clients, which must use https://todapi.work/v1. One key can be used for both protocols only if its group actually serves the models you call.

Shell (try this first)

export ANTHROPIC_BASE_URL="https://todapi.work"
export ANTHROPIC_AUTH_TOKEN="sk-xxxxxxxx"
export ANTHROPIC_MODEL="your-plaza-model-id"
claude

Exports last only for that terminal. An editor started from a dock or Start menu will not see them. If the session looks right, move the same values into a settings file.

Persistent settings.json

User-level file: ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json). Do not put the key in a project .claude/settings.json that may be committed.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://todapi.work",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxxxxxxx",
    "ANTHROPIC_MODEL": "your-plaza-model-id"
  }
}

If a shell export and the settings file both set the same variable, Claude Code’s current documentation says the settings file wins. Check with /status.

How to tell it worked

  1. You can also list models first with a regular request: curl https://todapi.work/v1/models -H "Authorization: Bearer sk-xxxxxxxx". A list means the key and group already match. This uses the OpenAI-compatible path and does not replace a Claude Code session test.
  2. In Claude Code, run /status. You want an Anthropic base URL of https://todapi.work and an auth line that names ANTHROPIC_AUTH_TOKEN.
  3. Send a short prompt. A normal reply is the real check. If it fails, read the status code against the guide’s error table (401 key, 403 group mismatch, model 404, 429 rate or balance, 5xx upstream).

Usual failure points

What happensLikely cause
404 on the first messageBase URL includes /v1, or the model ID is not in that group.
401Wrong or truncated key, or ANTHROPIC_API_KEY was set instead of ANTHROPIC_AUTH_TOKEN when the gateway expects a Bearer token.
403 or “model not found”The key’s group is not the Anthropic group (or does not include that model). Switch group, or copy the ID again from the plaza.
Claude Code still uses a claude.ai loginThe environment did not reach the process. Prefer settings.json, then open a new session and re-check /status.

Price and terms, before you send paid traffic

The console can also generate a Claude Code snippet from the key list (“Use key”). That is a convenience; the values above are the ones that must be correct. A shorter pointer also lives in the guide.