Skip to content

πŸ› Bug: Claude Code charges users twice - API billing AND prepaid credits consumed simultaneouslyΒ #23315

Description

@Kari-Basavaraj

πŸ› Bug Report: Double Billing on API-Based Login

Summary

Users on API-based billing (pay-per-usage) are being charged twice for every request β€” once via API billing (correct) and once via prepaid credits (incorrect).


πŸ”— Related Issues

This issue has been reported multiple times but remains unresolved:

Issue Title Relevance
#20976 "Max plan shows as API Usage Billing" EXACT same issue
#7719 "API credits consumed despite Pro subscription" Same dual-billing pattern
#5300 "PRO account shows Credit balance too low" Credit depletion on paid plans

πŸ“Š Evidence: Billing Proof

Test Session 1 (15 minutes of usage):

Metric Before After Change
Prepaid Credits $1.53 $1.12 -$0.41 ❌
API Usage $8.71 $9.12 +$0.41 βœ…

Test Session 2 (with forceLoginMethod: "console"):

Metric Before After Change
Login managed API key $0.00 $0.26 +$0.26
Prepaid Credits $4.84 $4.58 -$0.26 ❌

Result: Exact dual charge β€” same amount charged to both payment methods even with forceLoginMethod set.


πŸ”„ Steps to Reproduce

  1. Have API billing enabled ($100/month limit)
  2. Log in to Claude Code using API-based billing (pay-per-usage)
  3. Use Claude Code for 10-15 minutes
  4. Check both:

Result: Both show charges for the same usage (approximately equal amounts)


βœ… Expected Behavior

  • βœ… Only API usage increases
  • βœ… Prepaid credits remain unchanged
  • βœ… Single billing method

❌ Actual Behavior

  • ❌ Both prepaid AND API usage increase
  • ❌ Same usage charged twice
  • ❌ Prepaid balance can go negative

πŸ” Root Cause Analysis (Suspected - Unconfirmed)

We suspect (but cannot confirm) this may be related to an authentication split:

Suspected Issue:

  • Main Claude Code process: Uses API key β†’ API Usage Billing βœ…
  • MCP OAuth servers: Use OAuth tokens from .credentials.json β†’ Prepaid Credits ❌

❌ Failed Fix Attempts

Attempt Action Result
1 Delete ~/.claude/.credentials.json OAuth tokens regenerated automatically ❌
2 Set "enableAllProjectMcpServers": false OAuth tokens still regenerated ❌
3 Empty OAuth credentials manually Full OAuth configs restored from plugin files ❌
4 Set "forceLoginMethod": "console" in settings.json Dual billing still occurs ❌
5 Export ANTHROPIC_API_KEY in ~/.zshrc Key shows "Never used" - Claude Code ignores it and uses login managed key ❌
6 Run /logout and restart Still charges both API key AND prepaid credits ❌

Key Finding from Attempt 4-6:
Even with forceLoginMethod: "console" configured:

  • Claude Code shows "API Usage Billing" in status bar βœ…
  • Login managed API key is charged βœ…
  • Prepaid credits STILL consumed ❌ (same amount deducted from both)
  • Environment variable ANTHROPIC_API_KEY is completely ignored

Why Client-Side Fixes Don't Work:

  • Official plugins are closed-source
  • OAuth server URLs are hardcoded in plugin code
  • No API key configuration option exists for plugins
  • Plugins auto-load and override manual credential changes
  • forceLoginMethod doesn't prevent OAuth-based charges

πŸ’₯ Impact

Impact Area Description
πŸ’° Financial Users charged 2x for requests
πŸ”‡ Silent Failure No warning before credit depletion
⚠️ Negative Balance Users hit -$0.21 without ever buying credits
πŸ”’ Trust Unexpected charges erode user confidence

🌍 Environment

  • OS: macOS (likely affects all platforms)
  • Claude Code Version: v2.1.31 (Feb 2026)
  • Billing Type: API-based billing (pay-per-usage via console.anthropic.com)
  • API Key: Configured in ~/.zshrc as ANTHROPIC_API_KEY
  • Settings: forceLoginMethod: "console" in ~/.claude/settings.json
  • Regression Started: ~February 2-3, 2026
  • Frequency: 100% reproducible

πŸ™ Requested Fix

  1. Immediate: Audit billing routing to identify why dual charges occur
  2. Root Cause: Ensure API billing users are only charged via API billing
  3. Refund: Consider refunding incorrectly charged prepaid credits for affected users

Potential Solutions (for Anthropic team to evaluate):

  • Option 1: Make OAuth MCP servers use API billing when API key is present
  • Option 2: Allow API key auth for official plugins instead of OAuth
  • Option 3: Skip prepaid charges for OAuth requests when API billing is enabled

πŸ“Ž Additional Notes

  • This is a regression β€” worked correctly before Feb 2-3, 2026
  • Possibly related to Jan 2026 platform changes that restricted OAuth tokens to Claude Code only
  • The issue is server-side β€” no client-side workaround available
  • Only working workaround: Uninstall OAuth-based plugins (but loses valuable integrations)

πŸ”„ Additional Issue: Broken /login Flow

When running /login command and selecting "Anthropic Console account β€’ API usage billing":

Expected: Should provide an API key token to copy for authorization
Actual: Redirects to "Buy credits to get started" page

This indicates the system is incorrectly routing API billing users through the credits purchase flow instead of the API key authorization flow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions