[BUG] claude code is setting anthropic-beta header on requests to vertexai count-tokens
Resolved 💬 20 comments Opened Nov 6, 2025 by ts-shu Closed Apr 27, 2026
💡 Likely answer: A maintainer (ant-kurt, collaborator)
responded on this thread — see the highlighted reply below.
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
claude code sends the anthropic-beta header with beta values to vertex's count-tokens "model" which fails with an invalid request error
This was sorta fixed but is now broken again as the web-search-2025-03-05 value started being added in 2.0.31
This never works with sonnet[1m]
What Should Happen?
when doing a count-tokens call, don't send anthropic-beta header at all as it doesn't seem to like any values there
Error Messages/Logs
{"type":"error","error":{"type":"invalid_request_error","message":"Unexpected value(s) `context-1m-2025-08-07`, `web-search-2025-03-05` for the `anthropic-beta` header. Please consult our documentation at docs.anthropic.com or try again without the header."},"request_id":"req_vrtx_011CUsThdzFzwi3LL7cCKtcw"}
Steps to Reproduce
- run claude configured against a vertex endpoint with debug logging
- see that anthropic-beta header with some values are sent to count-tokens, which fails
Claude Model
Not sure / Multiple models
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.0.30
Claude Code Version
2.0.35
Platform
Google Vertex AI
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
20 Comments
Same here, any update on this?
same issue with me, any update?
the same, just now hit the wall
any update to this?still getting this
This should be fixed for Web Search in the next release - we're still working on the fix for Sonnet 1m
still doesn't seem to be working
Same here, error message still occurs on version 2.1.2.
This issue is occurring again in v2.1.19 with a new beta header:
Error occurs on Vertex AI (us-east5 region). Appears to be triggered by server-side feature flag rollout for tool search.
Request ID example:
req_vrtx_011CXWNxvuR59xcMwVdaYyY1Same issue appears in v2.1.23.
Workaround:
Had the same issue; reverting to
2.1.18fixed it (any version later had the issue)That's odd, 2.1.22 works for me
I am getting this error as well now all of the sudden:
I'm on Claude Code
v2.1.80.Still an issue for me. 2.1.22 does work.
The same issue for me, 2.1.119 (Claude Code)
Same here on 2.1.112 (Claude Code + Vertex AI)
Same here on 2.1.91 (Claude Code + Vertex AI)
Same here on Vertex AI, triggered specifically by the
/effortslash command in v2.1.121. Adds a third beta value to the failing list — the issue keeps recurring with each new beta Claude Code introduces.Investigated the rejection pattern across Vertex's Anthropic-managed models (region
global):| Model |
effort-2025-11-24|web-search-2025-03-05||-----------------------------|---------------------|-------------------------|
|
claude-opus-4-7@default| accepted | accepted ||
claude-sonnet-4-6@default| accepted | accepted ||
claude-haiku-4-5@20251001| rejected | accepted |Trigger from debug logs:
When the proper count-tokens endpoint returns null, Claude Code falls back to a Haiku call carrying the same beta headers. Vertex's Haiku 4.5 backend hasn't had
effort-2025-11-24rolled out yet, so the fallback fails. Same root cause as the previousstructured-outputs-2025-12-15,tool-search-tool-2025-10-19,redact-thinking-2026-02-12recurrences in this thread — every new beta added by Claude Code re-triggers it until Vertex catches up on every model.The OP's proposed fix (don't attach
anthropic-betato count-tokens calls at all) would resolve this structurally rather than waiting on per-beta Vertex rollouts.@mhegazy any more info to share other than just closing as completed?
Fix merged. it missed the cut, so will likely be in v2.1.122
I was getting a similar API Error message:
API Error: 400 vertex-ai error: Unexpected value(s)thinking-token-count-2026-05-13for the "anthropic-beta" header. Please consult our documentation at docs.anthropic.com or try again without the header.and the solution was to set the following env variable CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1Environment: WSL2 Ubuntu 22.04.5 LTS.