Loading...

Docs · Integrations

Claude Code with TopxAI: ANTHROPIC_BASE_URL and the key

Point Claude Code at https://ai.topxea.com with two environment variables and pick claude-sonnet-5-5, claude-opus-5-5 or claude-fable-5-1 as its model.

Claude Code talks to the Anthropic Messages API, which TopxAI serves at https://ai.topxea.com/v1/messages. Two environment variables set the endpoint and key; the model variables select a catalogue model.

Setup

export ANTHROPIC_BASE_URL=https://ai.topxea.com
export ANTHROPIC_AUTH_TOKEN=sk-...        # a TopxAI key on the Claude or Auto route
export ANTHROPIC_MODEL=claude-sonnet-5-5    # optional: the default model
claude

ANTHROPIC_AUTH_TOKEN sends the key as a Bearer token; ANTHROPIC_API_KEY sends it as x-api-key. TopxAI accepts both, so use whichever your shell already has. The base URL is the origin without /v1: Claude Code adds /v1/messages itself.

To make it permanent, put the same values under env in ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai.topxea.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-...",
    "ANTHROPIC_MODEL": "claude-sonnet-5-5"
  }
}

Claude Code also reads ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL for the models it switches between; set them to catalogue ids (claude-opus-5-5, claude-sonnet-5-5) so a switch never asks for a model TopxAI does not sell.

Moving from Sonnet 5

Change any saved ANTHROPIC_MODEL or ANTHROPIC_DEFAULT_SONNET_MODEL value from claude-sonnet-5 to claude-sonnet-5-5. The old ID is retired without a forwarding alias. Keep the same endpoint and unrestricted key; if the key has an allowed-model list, edit it to include the new ID. Start a fresh conversation so old model-bound thinking blocks are not replayed into Sonnet 5.5.

Token and cache prices stay the same. Adaptive thinking defaults to high effort; TopxAI translates legacy disabled-thinking requests to between_tools at low effort. Custom clients that force a tool must switch to automatic tool selection, and Anthropic-native computer-use clients must adopt the new toolset format. The Sonnet 5.5 migration post covers these settings and links to Anthropic's migration guide.

Which key

A key on the Auto route sends each request to the lowest-priced route that serves the model, the shared pool first. A key on the Claude official line pins the provider's own line at 90% of list. Both are created on the API keys page; the routes page explains the difference.

CC Switch

If you keep several endpoints, the CC Switch entry in a key's row menu on the keys page opens a ccswitch:// import with the endpoint, the key and the model already filled in.

What Claude Code sends

Claude Code sends its own system prompt and tool definitions with every request; those tokens are billed as input like any other. Prompt caching applies at the cache-read and cache-write prices on the model's page, and the usage log shows the cached and uncached counts separately.

If it fails

During the October 2 supplier checks, some between_tools requests returned 502, including medium on both routes and OpenAI none on the official route. Adaptive mode with explicit low effort passed on both routes: use thinking: {"type":"adaptive"} with output_config: {"effort":"low"} for Messages, or reasoning_effort: "low" for Chat Completions, when it fits your task. Adaptive mode can still think before answering, and those tokens are billed as output. TopxAI preserves the requested mode rather than silently substituting another one.

Models: claude-sonnet-5-5, claude-opus-5-5 · Models & pricing

Related

Previous: API reference: every endpoint, with an OpenAPI specification · Next: Codex CLI custom model provider: model_providers in config.toml for TopxAI

Other languages: 简体中文