[DOCS] missing: CLAUDE_CODE_ATTRIBUTION_HEADER - prompt cache with ANTHROPIC_BASE_URL
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...
- in the description of
ANTHROPIC_BASE_URLin that very same list on that page https://code.claude.com/docs/en/env-vars - https://code.claude.com/docs/en/third-party-integrations
- https://code.claude.com/docs/en/llm-gateway
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 😃
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗