claude-code - 💡(How to fix) Fix [BUG] Claude Code (non-interactive/headless, OAuth) requires usage credits enabled even when well within plan limits; usage credits toggle turns itself off spontaneously

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

This error occurs even when weekly usage is at 0–3% and the session limit has not been reached. The only workaround is to enable usage credits in claude.ai/settings/usage. No credits are actually charged during these sessions, suggesting the error is a false positive — the system is gating headless Claude Code behind usage credits regardless of actual consumption.

Error Messages/Logs

Observe the error: "Usage credits are required for long context requests."

Fix Action

Fix / Workaround

Bug 1 — Usage credits required when not over limit: Claude Code running in non-interactive/headless mode via OAuth fails with: "Usage credits are required for long context requests." This error occurs even when weekly usage is at 0–3% and the session limit has not been reached. The only workaround is to enable usage credits in claude.ai/settings/usage. No credits are actually charged during these sessions, suggesting the error is a false positive — the system is gating headless Claude Code behind usage credits regardless of actual consumption.

Enable usage credits (workaround for Bug 1) Run Claude Code in non-interactive/headless mode for an extended session At some point during the session, navigate to claude.ai/settings/usage Observe the usage credits toggle is showing Off despite not having been changed Claude Code stops accepting requests at this point Click the toggle to re-enable — a confirmation dialog appears saying "Are you sure you want to turn it Off?" confirming server-side state is still On Dismiss the dialog without changing anything Toggle now correctly shows On Restart Claude Code — resumes working normally with no credits charged

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Platform: Windows, Claude Code non-interactive (headless) mode, OAuth authentication, Max plan

Bug 1 — Usage credits required when not over limit: Claude Code running in non-interactive/headless mode via OAuth fails with: "Usage credits are required for long context requests." This error occurs even when weekly usage is at 0–3% and the session limit has not been reached. The only workaround is to enable usage credits in claude.ai/settings/usage. No credits are actually charged during these sessions, suggesting the error is a false positive — the system is gating headless Claude Code behind usage credits regardless of actual consumption.

Related issue: #61828

Bug 2 — Usage credits toggle turns itself off spontaneously: After enabling usage credits to work around Bug 1, the toggle in claude.ai/settings/usage spontaneously flips to the Off position on its own during active sessions. When this happens, Claude Code stops working immediately.

When navigating to the toggle to re-enable it, a confirmation dialog appears asking "Are you sure you want to turn it Off?" — indicating the server-side state is still On. The UI is displaying the wrong state. Dismissing the dialog (keeping it On) restores the correct display, and Claude Code resumes working after a restart — no actual change was made.

Expected behavior:

  1. Headless Claude Code via OAuth should not require usage credits when plan limits have not been reached.
  2. The usage credits toggle UI should accurately reflect server-side state and should not flip spontaneously.

Steps to reproduce Bug 2:

  1. Enable usage credits
  2. Run Claude Code in non-interactive/headless mode via OAuth for an extended session
  3. Observe the toggle in claude.ai/settings/usage switches to Off on its own
  4. Claude Code stops working
  5. Navigate to toggle — confirmation dialog says "turn Off?" (server still On)
  6. Dismiss dialog — toggle shows On — Claude Code resumes after restart

What Should Happen?

Claude Code non-interactive (headless) mode should accept OAuth for Max plan within usage limits without requiring Usage credits enabled, and Usage credits toggle should remain on if user sets them as on.

Error Messages/Logs

Steps to Reproduce

For Bug 1:

Have a Max plan Claude.ai account authenticated via OAuth Ensure weekly usage is well below plan limits (verify at claude.ai/settings/usage) Run Claude Code in non-interactive/headless mode Observe the error: "Usage credits are required for long context requests." Enable usage credits at claude.ai/settings/usage Re-run Claude Code — it works, but no credits are charged

For Bug 2:

Enable usage credits (workaround for Bug 1) Run Claude Code in non-interactive/headless mode for an extended session At some point during the session, navigate to claude.ai/settings/usage Observe the usage credits toggle is showing Off despite not having been changed Claude Code stops accepting requests at this point Click the toggle to re-enable — a confirmation dialog appears saying "Are you sure you want to turn it Off?" confirming server-side state is still On Dismiss the dialog without changing anything Toggle now correctly shows On Restart Claude Code — resumes working normally with no credits charged

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.141 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING