Skip to content

fix(anthropic): add billing header for OAuth plan-tier routing (#48176) - #48202

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-48176
Closed

fix(anthropic): add billing header for OAuth plan-tier routing (#48176)#48202
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-48176

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Fixes #48176. Anthropic's server-side billing gate requires an x-anthropic-billing-header system block with cc_entrypoint=sdk-cli to route OAuth requests to the subscription plan. Without it, Pro/Max/Team requests are treated as third-party and rejected with HTTP 400 'extra usage, not plan limits'. This adds the billing block as system[0] on the OAuth path in build_anthropic_kwargs().

…NousResearch#48176)

Anthropic's server-side billing gate routes OAuth requests to the
subscription plan only when the request carries the x-anthropic-billing-header
system block with cc_entrypoint=sdk-cli. Without it, Pro/Max/Team OAuth
requests are attributed as third-party and rejected with HTTP 400
"extra usage, not plan limits".

Prepend the billing block as system[0] on the OAuth path in
build_anthropic_kwargs(), ahead of the existing Claude Code identity block.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools P1 High — major feature broken, no workaround duplicate This issue or pull request already exists labels Jun 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #48177 — both fix #48176 by prepending an x-anthropic-billing-header block (cc_entrypoint=sdk-cli) as system[0] on the OAuth path in agent/anthropic_adapter.py, using the same mechanism. #48177 was opened first (~1.5h earlier) and is the canonical fix. Marking this as duplicate; reviewers can compare and pick one.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Adds billing header for OAuth plan-tier routing in the Anthropic adapter. Clean, targeted change.

Looks Good

  • Single-file change, minimal scope
  • Correct header key added

Reviewed by Hermes Agent

@teknium1

Copy link
Copy Markdown
Contributor

Closing alongside the issue this addresses — working as intended, won't implement.

This change is in service of making Claude Pro/Max/Team OAuth credentials bill on-plan for programmatic traffic. As of Anthropic's mid-June 2026 change, that traffic is metered as extra usage by design. The only way to restore on-plan billing is to present as the first-party Claude CLI/Agent-SDK surface — exactly the spoof filter Anthropic enforces against — which puts users at real risk of account suspension. We won't ship a mitigation whose mechanism is evading the provider's usage-attribution filter.

For Anthropic API access, use a standard x-api-key API key (ANTHROPIC_API_KEY). Thanks for the work and the detailed tracing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P1 High — major feature broken, no workaround provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OAuth Pro/Max/Team requests rejected with HTTP 400 "third-party / extra usage" (missing x-anthropic-billing-header system block)

4 participants