Skip to content

[Bug] Claude Code 2.1.37 random cch in x-anthropic-billing-header causes severe prompt-cache miss on third-party upstreams #1592

Description

@IIXINGCHEN

Is it a request payload issue?
[ x ] Yes, this is a request payload issue. I am using a client/cURL to send a request payload, but I received an unexpected error.
[ ] No, it's another issue.

If it's a request payload issue, you MUST know
Attached below are reproducible payload/cURL examples.
I verified that the payload is identical except for cch=... in x-anthropic-billing-header.

Describe the bug
After upgrading Claude Code to 2.1.37 (observed since 2026-02-08), prompt cache hit rate dropped sharply when routing to third-party Anthropic-compatible upstreams.
Before upgrade, cache hit rate was usually above 90%.
After upgrade, cache hit rate dropped to around 30%-40%, and in some cases near 0%.

The only unstable part we found is in system[].text:
x-anthropic-billing-header:cc_version=2.1.37.3a3; cc_entrypoint=claude-vscode; cch=<random>;

cch changes per request, which causes cache key instability on cache-sensitive upstreams.

CLI Type
claude code

Model Name
claude-3-5-sonnet-20240620
(also observed on claude-sonnet-4 variants)

LLM Client
claude code (cc_entrypoint=claude-vscode observed in payload)

Request Information
Two requests with same model, same messages, same system content except cch.

Request A:

curl -sS -X POST "http://127.0.0.1:8080/api/provider/anthropic/v1/messages" \
  -H "Authorization: Bearer <LOCAL_API_KEY>" \
  -H "Content-Type: application/json" \
  --data-raw '{
    "model":"claude-3-5-sonnet-20240620",
    "system":[{"type":"text","text":"x-anthropic-billing-header:cc_version=2.1.37.3a3; cc_entrypoint=claude-vscode; cch=AAA111;"}],
    "messages":[{"role":"user","content":[{"type":"text","text":"Please say hello."}]}],
    "max_tokens":64
  }'

Request B:

curl -sS -X POST "http://127.0.0.1:8080/api/provider/anthropic/v1/messages" \
  -H "Authorization: Bearer <LOCAL_API_KEY>" \
  -H "Content-Type: application/json" \
  --data-raw '{
    "model":"claude-3-5-sonnet-20240620",
    "system":[{"type":"text","text":"x-anthropic-billing-header:cc_version=2.1.37.3a3; cc_entrypoint=claude-vscode; cch=BBB222;"}],
    "messages":[{"role":"user","content":[{"type":"text","text":"Please say hello."}]}],
    "max_tokens":64
  }'

In our environment, this difference alone significantly reduces prompt-cache hit rate.

Expected behavior
For otherwise identical requests, prompt caching should remain stable.
Volatile cch should not cause cache key churn.
A practical mitigation in proxy layer is to normalize/strip volatile cch before forwarding to upstream cache-sensitive backends.

Screenshots
Cache hit-rate before/after upgrade and request-log snippets can be provided (sanitized).

OS Type

- OS: Windows
- Version: Microsoft Windows 10.0.26200.7840

Additional context

- Repository: github.com/router-for-me/CLIProxyAPI/v6
- Branch: main
- Commit tested: ae1e8a5
- This looks different from #1562 and #1366:
    - #1562 is primarily about cache usage reporting.
    - #1366 is primarily about prompt cache_control handling.
    - This issue is payload volatility caused by random cch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions