claude-code - 💡(How to fix) Fix Standard API keys get generic 400 on 4.x models without undocumented billing header [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46476Fetched 2026-04-11 06:19:18
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Standard Console API keys (sk-ant-api03-*) from workspace-restricted accounts receive a generic 400 invalid_request_error with message "Error" when calling 4.x models (claude-sonnet-4-6, claude-opus-4-6). Older models (claude-haiku-4-5-20251001) work fine with the same key and request.

Related: #35269 (similar symptoms with OAuth tokens on Max plan)

Error Message

Standard Console API keys (sk-ant-api03-*) from workspace-restricted accounts receive a generic 400 invalid_request_error with message "Error" when calling 4.x models (claude-sonnet-4-6, claude-opus-4-6). Older models (claude-haiku-4-5-20251001) work fine with the same key and request. 3. Response: {"type":"error","error":{"type":"invalid_request_error","message":"Error"}} 2. Unhelpful error message - "Error" gives no indication of what is wrong. A message like "This API key does not have access to this model" or "Missing required billing attribution" would save significant debugging time.

Root Cause

Standard Console API keys (sk-ant-api03-*) from workspace-restricted accounts receive a generic 400 invalid_request_error with message "Error" when calling 4.x models (claude-sonnet-4-6, claude-opus-4-6). Older models (claude-haiku-4-5-20251001) work fine with the same key and request.

Related: #35269 (similar symptoms with OAuth tokens on Max plan)

Fix Action

Workaround

Adding x-anthropic-billing-header as the first block of the system array makes 4.x models work:

{
  "model": "claude-sonnet-4-6",
  "system": [
    {"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.83.c50; cc_entrypoint=cli; cch=00000;"},
    {"type": "text", "text": "Your actual system prompt"}
  ],
  "messages": [{"role": "user", "content": "hi"}],
  "max_tokens": 50
}

This was discovered by capturing a working Claude Code CLI request via Proxyman and diffing it against our failing request. The billing header in the system body was the only structural difference.

Code Example

curl -s 'https://api.anthropic.com/v1/messages' \
  -H 'anthropic-version: 2023-06-01' \
  -H 'x-api-key: sk-ant-api03-...' \
  -H 'Content-Type: application/json' \
  -d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"hi"}],"max_tokens":50}'

---

{
  "model": "claude-sonnet-4-6",
  "system": [
    {"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.83.c50; cc_entrypoint=cli; cch=00000;"},
    {"type": "text", "text": "Your actual system prompt"}
  ],
  "messages": [{"role": "user", "content": "hi"}],
  "max_tokens": 50
}
RAW_BUFFERClick to expand / collapse

Summary

Standard Console API keys (sk-ant-api03-*) from workspace-restricted accounts receive a generic 400 invalid_request_error with message "Error" when calling 4.x models (claude-sonnet-4-6, claude-opus-4-6). Older models (claude-haiku-4-5-20251001) work fine with the same key and request.

Related: #35269 (similar symptoms with OAuth tokens on Max plan)

Steps to Reproduce

  1. Create an API key from a workspace in the Anthropic Console
  2. Send a minimal Messages API request to claude-sonnet-4-6 or claude-opus-4-6:
curl -s 'https://api.anthropic.com/v1/messages' \
  -H 'anthropic-version: 2023-06-01' \
  -H 'x-api-key: sk-ant-api03-...' \
  -H 'Content-Type: application/json' \
  -d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"hi"}],"max_tokens":50}'
  1. Response: {"type":"error","error":{"type":"invalid_request_error","message":"Error"}}
  2. The same request with claude-haiku-4-5-20251001 succeeds

Workaround

Adding x-anthropic-billing-header as the first block of the system array makes 4.x models work:

{
  "model": "claude-sonnet-4-6",
  "system": [
    {"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.83.c50; cc_entrypoint=cli; cch=00000;"},
    {"type": "text", "text": "Your actual system prompt"}
  ],
  "messages": [{"role": "user", "content": "hi"}],
  "max_tokens": 50
}

This was discovered by capturing a working Claude Code CLI request via Proxyman and diffing it against our failing request. The billing header in the system body was the only structural difference.

Issues

  1. Undocumented requirement - the billing header is not mentioned anywhere in the API docs. There is no way to discover this without reverse-engineering Claude Code traffic.
  2. Unhelpful error message - "Error" gives no indication of what is wrong. A message like "This API key does not have access to this model" or "Missing required billing attribution" would save significant debugging time.
  3. Inconsistent behavior - Haiku works without the header while Sonnet/Opus don't, making it appear like a model-specific bug rather than an auth/billing issue.

Environment

  • API key type: sk-ant-api03-* (standard Console key, not OAuth)
  • Workspace: restricted workspace within an organization
  • Claude Code version used for traffic capture: 2.1.83
  • OS: macOS (Darwin 25.4.0)

extent analysis

TL;DR

To fix the 400 invalid_request_error when calling 4.x models with standard Console API keys from workspace-restricted accounts, add the x-anthropic-billing-header to the system array in the request body.

Guidance

  • Verify that the issue is specific to 4.x models (claude-sonnet-4-6, claude-opus-4-6) and that older models (claude-haiku-4-5-20251001) work with the same API key.
  • Add the x-anthropic-billing-header as the first block of the system array in the request body, as shown in the provided workaround example.
  • Test the modified request to confirm that it resolves the invalid_request_error.
  • Consider reporting the undocumented requirement and unhelpful error message to the API maintainers to improve the overall developer experience.

Example

{
  "model": "claude-sonnet-4-6",
  "system": [
    {"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.83.c50; cc_entrypoint=cli; cch=00000;"},
    {"type": "text", "text": "Your actual system prompt"}
  ],
  "messages": [{"role": "user", "content": "hi"}],
  "max_tokens": 50
}

Notes

The provided workaround was discovered by capturing and diffing a working Claude Code CLI request, highlighting the importance of inspecting successful requests for differences.

Recommendation

Apply the workaround by adding the x-anthropic-billing-header to the system array, as it has been shown to resolve the invalid_request_error for 4.x models.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING