[BUG] Vertex AI 413 - can't count tokens

Resolved 💬 8 comments Opened Jun 25, 2025 by Dasio Closed Jan 8, 2026

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [X] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.33
  • Operating System: macOS 15.5
  • Terminal: iTerm2

Bug Description

When using Claude through Vertex AI, requests intermittently fail with a 413 "prompt is too long" error.
Endpoint count-tokens:rawPredict returns a 400 error, preventing accurate token counting and causing the 413 error (assumption).

It seems that issue is with field

"cache_control": {
    "type": "ephemeral"
  }

If I try to make same call without this cache_control, I received 200 OK. And in response I can see

{
    "input_tokens": 252461
}

So that's the reason for 413.

Steps to Reproduce

  1. Analyze big codebase
  2. It sends request with >200k tokens and fails

Expected Behavior

Chunk it to smaller requests

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗