[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

  1. run claude configured against a vertex endpoint with debug logging
  2. 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_

View original on GitHub ↗

20 Comments

mohamedGamalAbuGalala · 8 months ago

Same here, any update on this?

dcohendumani-experio · 8 months ago

same issue with me, any update?

innoratu · 8 months ago

the same, just now hit the wall

dominicdev · 7 months ago

any update to this?still getting this

ant-kurt collaborator · 7 months ago

This should be fixed for Web Search in the next release - we're still working on the fix for Sonnet 1m

dcieslak19973 · 6 months ago

still doesn't seem to be working

maphilipps · 6 months ago

Same here, error message still occurs on version 2.1.2.

AnveshJarabani-WellSky · 5 months ago

This issue is occurring again in v2.1.19 with a new beta header:

Unexpected value(s) `tool-search-tool-2025-10-19` for the `anthropic-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_011CXWNxvuR59xcMwVdaYyY1

kaibeu229 · 5 months ago

Same issue appears in v2.1.23.
Workaround:

  • Install v2.1.22
  • Keep Claude Code from auto updating to latest version via settings.json:
{
  "autoUpdatesChannel": "stable",
  "minimumVersion": "2.1.22"
}
wpapsco-apex · 5 months ago

Had the same issue; reverting to 2.1.18 fixed it (any version later had the issue)

kaibeu229 · 5 months ago
Had the same issue; reverting to 2.1.18 fixed it (any version later had the issue)

That's odd, 2.1.22 works for me

bmitc · 3 months ago

I am getting this error as well now all of the sudden:

API Error: 400 {"error":{"message":"vertex-ai error: Unexpected value(s) `context-1m-2025-08-07`,
     `redact-thinking-2026-02-12` for the `anthropic-beta` header. Please consult our documentation at docs.anthropic.com or
     try again without the header.","type":"invalid_request_error","param":null,"code":null},"provider":"vertex-ai"}

I'm on Claude Code v2.1.80.

JamesSaxon · 3 months ago

Still an issue for me. 2.1.22 does work.

FrankieCheng · 2 months ago

The same issue for me, 2.1.119 (Claude Code)

nicolas-vivot · 2 months ago

Same here on 2.1.112 (Claude Code + Vertex AI)

kalyan-arepalle · 2 months ago

Same here on 2.1.91 (Claude Code + Vertex AI)

this-fifo · 2 months ago

Same here on Vertex AI, triggered specifically by the /effort slash 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:

countTokensWithFallback: API returned null, trying haiku fallback (18 tools)
[ERROR] Error in non-streaming fallback: 400 {"...effort-2025-11-24..."} req_vrtx_…

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-24 rolled out yet, so the fallback fails. Same root cause as the previous structured-outputs-2025-12-15, tool-search-tool-2025-10-19, redact-thinking-2026-02-12 recurrences 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-beta to count-tokens calls at all) would resolve this structurally rather than waiting on per-beta Vertex rollouts.

this-fifo · 2 months ago

@mhegazy any more info to share other than just closing as completed?

mhegazy contributor · 2 months ago

Fix merged. it missed the cut, so will likely be in v2.1.122

liviutomoiaga · 1 month ago

I was getting a similar API Error message: API Error: 400 vertex-ai error: Unexpected value(s) thinking-token-count-2026-05-13 for 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=1

Environment: WSL2 Ubuntu 22.04.5 LTS.