[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 😃
4 Comments
As of
2.1.113does not appear to be the case anymore:
what I guess in some way is nice,
but in another even more so underlines the need of documenting
CLAUDE_CODE_ATTRIBUTION_HEADER=0Since now even the
claude "Hello"trick is brokenstill relevant in >=2.1.150
1)appears to be somewhat done https://code.claude.com/docs/en/env-varsAlso
2)chttps://code.claude.com/docs/en/llm-gateway has gotten a little section:Yet I really think that the
BASE_URLon 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!
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.