Claude Code
Run Claude Code against Top Billing models.
npx @topbilling/cli claude and it writes everything below for you. See Set up your tools.Claude Code talks the Anthropic Messages protocol, so it works against https://api.topbilling.in with a live key. Set these environment variables before starting it:
export ANTHROPIC_BASE_URL=https://api.topbilling.in # no /v1 suffix; the client appends paths
export ANTHROPIC_AUTH_TOKEN=tb_live_... # sent as Authorization: Bearer
# or: export ANTHROPIC_API_KEY=tb_live_... # sent as x-api-key
export ANTHROPIC_MODEL=<model-id> # a Top Billing model id from /models
# Optional per-tier overrides (confirm current names in Claude Code's model-config docs):
# ANTHROPIC_DEFAULT_OPUS_MODEL / ANTHROPIC_DEFAULT_SONNET_MODEL / ANTHROPIC_DEFAULT_HAIKU_MODEL
Model naming
Top Billing model IDs are neutral (tb-…). Claude Code’s optional gateway model discovery only lists IDs containing claude or anthropic, so our models will not appear in its /model picker: set ANTHROPIC_MODEL explicitly as above.
Translated-lane models
Some models are served through a translation layer rather than an Anthropic-format upstream (each model’s page in Model Square marks these). Claude Code sends a few beta features those upstreams cannot honour; set the flags below so it does not surface them as errors:
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 # context management / beta tool schemas are not auto-retried by Claude Code
export CLAUDE_CODE_ATTRIBUTION_HEADER=0 # recommended when a gateway reshapes system content
export CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1 # only if the model lacks the reasoning capability
On the translated lane, cache_control hints are accepted and ignored (reported in the tb-dropped-hints header), thinking signatures are scoped to the route that produced them, and capability rejections carry a capability_rejected: token so Claude Code can recover by retrying without the feature.
Costs
Every Claude Code request is billed like any other API request and shows up in Usage with its session id, so you can see what a coding session cost.
tb_ key: the gateway rejects non-Top-Billing credentials with 401 and never forwards them.