Skip to content

"API Usage Billing" shown when ANTHROPIC_BASE_URL points to a gateway that authenticates with a claude setup-token token #105663

Open

Description

@ecarrara-araujo

What's wrong?

Claude Code (Linux guest) runs with these managed settings:

{"env": {"ANTHROPIC_BASE_URL": "http://<local gateway>/anthropic", "ANTHROPIC_AUTH_TOKEN": "<placeholder>"}}

A local gateway sets the real auth on the way to api.anthropic.com: a long-lived OAuth token created with claude setup-token (Team plan). There is no API key anywhere in the setup.

The startup header says <model> · API Usage Billing, which reads as if the session were billed as metered API usage. As far as we can tell it isn't: the API's responses to these requests carry the subscription's unified rate-limit headers, matching what /usage shows for the account:

anthropic-ratelimit-unified-5h-utilization: 0.16       (= /usage "Current session 16%")
anthropic-ratelimit-unified-7d-utilization: 0.04       (= /usage "Current week 4%")
anthropic-ratelimit-unified-overage-utilization: 0.0
anthropic-ratelimit-unified-representative-claim: five_hour

I assume the label comes from Claude Code seeing ANTHROPIC_AUTH_TOKEN rather than a subscription login.

What should happen?

When ANTHROPIC_BASE_URL points to a custom endpoint, Claude Code can't know how requests are billed, so the header shouldn't assert API billing. It could say something like "custom endpoint", or show no billing line. Since the responses already carry anthropic-ratelimit-unified-* headers, those could also tell Claude Code it's on a plan.

Steps to reproduce

  1. Create a token with claude setup-token.
  2. Run a small proxy that forwards to https://api.anthropic.com and replaces the Authorization header with Bearer <that token>.
  3. Start Claude Code with ANTHROPIC_BASE_URL pointing at the proxy and ANTHROPIC_AUTH_TOKEN set to any placeholder.
  4. The header shows "API Usage Billing"; requests succeed and the responses carry the plan's unified rate-limit headers.

Related

#57812 (same wrong label on Bedrock, fixed in 2.1.141), #93168 (label asserted while signed out).

Environment

  • Claude Code 2.1.308
  • Ubuntu guest under Lima on macOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions