claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] claude code is setting anthropic-beta header on requests to vertexai count-tokens

Open ts-shu opened this issue 2 months ago • 6 comments

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

ts-shu avatar Nov 06 '25 23:11 ts-shu