Skip to content

Claude: read extra usage amounts as minor units (cents) - #19

Merged
nstarke merged 1 commit into
mainfrom
fix/claude-extra-usage-cents
Oct 25, 2026
Merged

nstarke merged 1 commit into
mainfrom
fix/claude-extra-usage-cents

Conversation

@nstarke

@nstarke nstarke commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Problem

After adding usage credits, the widget showed Extra usage $6819 instead of $68.19.

The OAuth usage endpoint reports extra_usage.used_credits and monthly_limit in minor units, with decimal_places giving the exponent:

"extra_usage": {"is_enabled": true, "monthly_limit": null, "used_credits": 6819.0, "currency": "USD", "decimal_places": 2}

fetch_claude read those values as dollars.

Fix

  • Divide used_credits and monthly_limit by 10 ** decimal_places, assuming 2 when the field is missing or invalid.
  • The extra-usage credit cutoff uses the same Credits values, so it's corrected too.

Tests

  • Changed the existing extra-usage fixtures from dollars to cents.
  • Added a test that uses the real response shape (6819 → $68.19) and one that checks decimal_places is respected.
  • pytest: 675 passed, 1 skipped (boto3 not installed).

🤖 Generated with Claude Code

The usage API reports used_credits and monthly_limit in minor units with
decimal_places giving the exponent, so 6819 meant $68.19, not $6819.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nstarke
nstarke merged commit e0535d8 into main Oct 25, 2026
31 checks passed
@nstarke
nstarke deleted the fix/claude-extra-usage-cents branch October 25, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant