[BUG] Setting DISABLE_PROMPT_CACHING Environment Variable Causes 401 Unauthorized Errors
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?
When the environment variable DISABLE_PROMPT_CACHING is set, the Claude Code extension fails to authenticate, resulting in a 401 Unauthorized error. Unsetting this environment variable immediately resolves the issue.
This behavior is unexpected because a feature flag for caching should not interfere with the authentication flow. Furthermore, this environment variable appears to be undocumented, making the issue difficult to diagnose.
What Should Happen?
Setting DISABLE_PROMPT_CACHING=true should disable prompt caching as intended, without affecting the user's authentication status. All commands should execute normally after a successful login.
Error Messages/Logs
API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not
supported."},"request_id":"req_011CTgM7o63aV9K39BERJn7c"} ยท Please run /login
The Debug log is below.
[ERROR] SyntaxError: SyntaxError: JSON Parse error: Unexpected identifier "API"
at <parse> (:0)
at parse (unknown)
at <anonymous> (/$bunfs/root/claude:568:9937)
at W (/$bunfs/root/claude:534:13292)
at tFG (/$bunfs/root/claude:896:37032)
at processTicksAndRejections (native:7:39)
[ERROR] Error in non-streaming fallback: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"req_011CTgLuT9f6gsMsASFAMVqk"}
[ERROR] Error: Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"req_011CTgLuT9f6gsMsASFAMVqk"}
at new W5 (unknown:1:28)
at new _Y (/$bunfs/root/claude:716:20515)
at new jv (unknown:1:28)
at generate (/$bunfs/root/claude:716:21006)
at makeRequest (/$bunfs/root/claude:871:5359)
at processTicksAndRejections (native:7:39)
Steps to Reproduce
In your terminal, set the environment variable:
export DISABLE_PROMPT_CACHING=true
Launch or restart Claude code from the same terminal session to ensure it inherits the environment variable.
Attempt to use any Claude Code command that requires authentication (e.g., /edit, /fix, or starting a new chat).
Observe the 401 Unauthorized error.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
1.0.88
Claude Code Version
2.0.1
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Warp
Additional Information
You can just check the command "unset" and then it works. 404 error is not important.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/6078
- https://github.com/anthropics/claude-code/issues/7855
- https://github.com/anthropics/claude-code/issues/4187
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and ๐ the existing issue instead
- To prevent auto-closure, add a comment or ๐ this comment
๐ค Generated with Claude Code
Are you still seeing this issue?
Which model are you using? Are you using first-party or Bedrock?
Also - we're updating our documentation around the prompt caching environment variables. We have added DISABLE_PROMPT_CACHING_HAIKU, DISABLE_PROMPT_CACHING_SONNET, and DISABLE_PROMPT_CACHING_OPUS, which can be useful for older models that may not support this setting.
I have the same issue - setting DISABLE_PROMPT_CACHING=true will cause a 401 error when restarting Claude and trying any prompt. The model setting is default (Sonnet 4.5), so that doesn't seem related.
@ant-kurt
Are you still seeing this issue?
Which model are you using? Are you using first-party or Bedrock?
It is okay now with first-party when I unset all the variables that I used to use with Bedrock. As @eladroz said, this issue doesn't seem to be related to specific models.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
@ant-kurt Hi! Just checking in - are there any updates on this issue? Happy to help test or provide more details if needed.