[DOCS] missing: CLAUDE_CODE_ATTRIBUTION_HEADER - prompt cache with ANTHROPIC_BASE_URL

Status Fixed / completed
Reported on v2.1.112
Maintainer reply None cached
Activity 4 comments · opened Apr 17, 2026 · closed Jun 10, 2026

Documentation Type

Missing documentation (feature not documented)

Documentation Location

https://code.claude.com/docs/en/env-vars

Section/Topic

CC Environment variables

Current Documentation

nothing

What's Wrong or Missing?

CLAUDE_CODE_ATTRIBUTION_HEADER is entirely missing

Not setting CLAUDE_CODE_ATTRIBUTION_HEADER=0
while using ANTHROPIC_BASE_URL=....
-> results in guaranteed cache-misses since the first line in the system-prompt contains a hash of the user-prompt ?!

it appears some API-providers/proxies normalize this away on their end - but it breaks caching for everyone´s who doesn´t.

Suggested Improvement

Not only 1) document it.

But ideally also 2) make users aware...

about this undocumented variable -
and maybe also about ENABLE_PROMPT_CACHING_1H (this one does exist on the docs, but with no hint and neither on the other 2 pages one may find)

Impact

High - Prevents users from using a feature

Additional Context

This means, using any sort of custom ANTHROPIC_BASE_URL has a good chance to make practically anything uncacheable.

"system": [
    {
      "type": "text",
      "text": "x-anthropic-billing-header: cc_version=2.1.112.6ab; cc_entrypoint=cli; cch=00000;"
    },
...
"system": [
    {
      "type": "text",
      "text": "x-anthropic-billing-header: cc_version=2.1.112.kg1; cc_entrypoint=cli; cch=00000;"
    },
...
"system": [
    {
      "type": "text",
      "text": "x-anthropic-billing-header: cc_version=2.1.112.9gt; cc_entrypoint=cli; cch=00000;"
    },

<del>Note that the cch= is nulled correctly,</del>
EDIT: as of 2.1.113 - "cch= started ticking"
but this fingerprint/hash-thing (what is calculated from the first user prompt, so different every time) is still tacked onto the cc_version string

---

https://x.com/cccchuizi/status/2022158897935790585 Let me simply expose the issue where using third-party APIs with claude code leads to reduced cache hit rates.

On February 8th, a user in our after-sales group reported abnormal billing for claude code

---

Where I´d almost like to ask if that is malicious compliance from your end...

https://me.justinl.site/blog/claude-code-cache-hit-bug The attribution header is only emitted on the API key path. The relevant gate looks like this: `` function BA9() { if (disabledByEnv(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER)) return false; return featureFlag("tengu_attribution_header", true); } `` In practice, OAuth users appear to bypass this header entirely

This would mean you are not stripping it for direct users on your server (since you never put it in to begin with)
but inject it for everyone else to trip over?... why?....
but let that be another issue

  • for this one, I´d just like a "if base_url, you may want CLAUDE_CODE_ATTRIBUTION_HEADER=0" to get into the docs at all 😃

View original on GitHub ↗

4 Comments

wadabum · 6 months ago

As of 2.1.113

that the cch= is nulled correctly,

does not appear to be the case anymore:

      "text": "x-anthropic-billing-header: cc_version=2.1.113.244; cc_entrypoint=cli; cch=b29b8;" <- "alive?"
      "text": "x-anthropic-billing-header: cc_version=2.1.113.244; cc_entrypoint=cli; cch=08894;" <- "alive?"
      "text": "x-anthropic-billing-header: cc_version=2.1.113.a4e; cc_entrypoint=cli; cch=c8202;" <- "you here?"

what I guess in some way is nice,
but in another even more so underlines the need of documenting CLAUDE_CODE_ATTRIBUTION_HEADER=0

Since now even the claude "Hello" trick is broken

wadabum · 4 months ago

still relevant in >=2.1.150

wadabum · 4 months ago

1) appears to be somewhat done https://code.claude.com/docs/en/env-vars

CLAUDE_CODE_ATTRIBUTION_HEADER | Set to 0 to omit the attribution block (client version and prompt fingerprint) from the start of the system prompt. Disabling it improves prompt-cache hit rates when routing through an LLM gateway. Anthropic API caching is unaffected

Also 2)c https://code.claude.com/docs/en/llm-gateway has gotten a little section:

Claude Code also prepends a short attribution block to the system prompt containing the client version and a fingerprint derived from the conversation. The Anthropic API strips this block before processing, so it does not affect first-party prompt caching. If your gateway implements its own prompt cache keyed on the full request body, set CLAUDE_CODE_ATTRIBUTION_HEADER=0 to omit it.

Yet I really think that the BASE_URL on the env-page not only deserves a hint to tool_search, but also attribution and 1h-cache...
but since "missing" is fixed im willed to close this as fixed - thanks!

github-actions[bot] · 2 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.