[BUG] ENABLE_PROMPT_CACHING_1H is not working (API key user)
Resolved 💬 5 comments Opened Apr 16, 2026 by kevingosse Closed May 4, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The ENABLE_PROMPT_CACHING_1H environment variable (which opts into 1-hour prompt cache TTL) has no effect. Cache entries are always created with 5-minute TTL regardless of the setting.
By intercepting the raw HTTP traffic between Claude Code and the Anthropic API, I confirmed that:
- The client correctly sends
cache_control: {"type":"ephemeral","ttl":"1h","scope":"global"}on system blocks andcache_control: {"type":"ephemeral","ttl":"1h"}on message blocks - The
anthropic-betaheader includesprompt-caching-scope-2026-01-05 - The server responds with
ephemeral_5m_input_tokens: 7025, ephemeral_1h_input_tokens: 0— all cache creation goes into the 5-minute bucket, none into the 1-hour bucket
This is reproducible on both an enterprise/organization API key and a personal API key.
What Should Happen?
When ENABLE_PROMPT_CACHING_1H=1 is set, cache entries should be created with a 1-hour TTL. The server response should show ephemeral_1h_input_tokens > 0 and ephemeral_5m_input_tokens: 0 for the cache creation.
Error Messages/Logs
**Request (client → server):**
POST https://api.anthropic.com/v1/messages?beta=true
anthropic-beta: claude-code-20250219,context-1m-2025-08-07,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advisor-tool-2026-03-01,advanced-tool-use-2025-11-20,effort-2025-11-24,afk-mode-2026-01-31
System block cache_control: {"type":"ephemeral","ttl":"1h","scope":"global"}
Message block cache_control: {"type":"ephemeral","ttl":"1h"}
**Response (server → client):**
{
"input_tokens": 3,
"cache_creation_input_tokens": 7025,
"cache_read_input_tokens": 12112,
"cache_creation": {
"ephemeral_5m_input_tokens": 7025,
"ephemeral_1h_input_tokens": 0
}
}
The server creates cache entries (7025 tokens) but places them all in the 5-minute bucket despite the client requesting 1-hour TTL.
Steps to Reproduce
- Set
ENABLE_PROMPT_CACHING_1H=1(either as environment variable or insettings.jsonunderenv) - Start Claude Code
- Send a message
- Observe usage stats —
ephemeral_1h_input_tokensis always 0
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.110 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗