[BUG] CLAUDE_DISABLE_PROMPT_CACHING environment variable not working in v2.1.23

Resolved 💬 3 comments Opened Jan 29, 2026 by trend-marion-mora Closed Feb 2, 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?

Environment
Claude Code Version: 2.1.23
Platform: macOS (Darwin 25.1.0)
API Endpoint: Custom enterprise endpoint
Problem Description
The CLAUDE_DISABLE_PROMPT_CACHING environment variable is set to "1" but Claude Code v2.1.23 still sends the anthropic-beta: prompt-caching-scope-2026-01-05 header in API requests.

This breaks compatibility with custom enterprise API endpoints that don't support the beta header.

What Should Happen?

When CLAUDE_DISABLE_PROMPT_CACHING=1 is set, the anthropic-beta: prompt-caching-scope-2026-01-05 header should NOT be sent in API requests.

Error Messages/Logs

The header is sent regardless of the environment variable, causing API errors:

API Error: 400 {"error":{"message":"{"type":"error","error":{"type":"invalid_request_error","message":"Unexpected value(s) `prompt-caching-scope-2026-01-05` for the `anthropic-beta` header. Please consult our documentation at docs.anthropic.com or try again without the header."},...}}

Steps to Reproduce

Steps to Reproduce
Configure Claude Code with a custom ANTHROPIC_BASE_URL pointing to an enterprise endpoint
Set CLAUDE_DISABLE_PROMPT_CACHING=1 in ~/.claude/settings.json:
{
"env": {
"CLAUDE_DISABLE_PROMPT_CACHING": "1",
"ANTHROPIC_BASE_URL": "https://api.enterprise.example.com/",
...
}
}
Start a new Claude Code session
Send any message

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.23

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Root Cause Analysis
The environment variable appears to be loaded correctly (visible in env), but the code that adds the anthropic-beta header is not checking this variable before sending the header.

Suggested Fix
In the API client code that adds the anthropic-beta header, add a check:

if (!process.env.CLAUDE_DISABLE_PROMPT_CACHING) {
headers['anthropic-beta'] = 'prompt-caching-scope-2026-01-05';
}
Impact
This affects all users with custom enterprise API endpoints that don't support the new prompt caching beta header. The workaround of downgrading to 2.1.20 works, but prevents users from getting other bug fixes and features in newer versions.

Additional Context
Version 2.1.20 works correctly (no prompt caching header sent)
Version 2.1.21, 2.1.22, and 2.1.23 all have this issue
The bug likely appeared when prompt caching scope support was added between 2.1.20 and 2.1.21
Thank you for looking into this! Happy to provide any additional information needed.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗