Skip to content

[bug]: Anthropic quota unavailable — claude auth status does not expose usage data #49

@vsixer

Description

@vsixer

Pre-flight checks

  • I searched existing issues and did not find a duplicate.
  • I verified this on the current production released OpenCode version, or I explain why not below.

OpenCode version tested

1.4.11

opencode-quota version tested

3.0.0

Bug summary

The Anthropic quota rows never appear in /quota, toasts, or the sidebar. The plugin probes claude auth status --json for 5-hour and 7-day usage windows, but the Claude CLI does not include any quota or utilization fields in that response. As a result, parseUsageResponse() always returns null and the provider is silently skipped.
Root cause: Anthropic quota data is not exposed through claude auth status. It is available through a separate undocumented

OAuth usage endpoint:

GET https://api.anthropic.com/api/oauth/usage
Authorization: Bearer <claudeAiOauth.accessToken>
anthropic-beta: oauth-2025-04-20
Response shape:
{
    "five_hour": { "utilization": 0.42, "resets_at": "2026-04-19T17:00:00Z" },
    "seven_day":  { "utilization": 0.61, "resets_at": "2026-04-24T08:00:00Z" }
}

The OAuth token is stored at ~/.claude/.credentials.json under claudeAiOauth.accessToken. This is the same approach used by claude-usage-monitor (https://github.com/aiedwardyi/claude-usage-monitor) and documented independently at https://ianlpaterson.com/blog/tracking-claude-codex-gemini-quotas-from-one-script/.
Suggested fix: in lib/anthropic.ts, when claude auth status confirms authentication but parseUsageResponse() returns null, fall back to calling the OAuth usage endpoint directly and parse the response with the existing parseUsageResponse() logic — it already handles the five_hour/seven_day/utilization/resets_at field names.

Steps to reproduce

  1. Install Claude Code CLI and authenticate: claude auth login
  2. Confirm auth: claude auth status --json — returns loggedIn: true, subscriptionType: "max", but no quota fields
  3. Configure opencode-quota with the anthropic provider enabled (auto-detect)
  4. Start OpenCode and run /quota
  5. Observe: no Anthropic rows appear in the output

Expected behavior

Anthropic quota rows (5-hour and 7-day usage windows with percentage remaining and reset time) should appear in /quota output, toasts, and the sidebar panel — the same way OpenAI and Z.ai quota rows appear.

Actual behavior

No Anthropic quota rows are shown anywhere. The claude auth status --json response contains no utilization data, so the plugin has nothing to display.

Relevant logs/output

claude --version output:
  2.1.114 (Claude Code)
claude auth status --json output:
  {
    "loggedIn": true,
    "authMethod": "claude.ai",
    "apiProvider": "firstParty",
    "subscriptionType": "max"
  }
  No "quota", "usage", "rate_limits", or "oauth_usage" keys present.

If not tested on current production OpenCode, explain why

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions