Skip to content

API-mode usage reader from response headers (built, inactive) #32

Description

@Ryan-Atkinson87

Implement the API-key-mode usage reader against the UsageReader interface (#30). Built for
completeness; inactive until an API key is configured (the human is subscription-only for now).

Spec: §6.2 (Reading usage — API mode), §6.1 (Meters).

Acceptance criteria

  • Reads rate-limit headers (anthropic-ratelimit-tokens-remaining, anthropic-ratelimit-tokens-reset, and siblings) per call via the SDK's raw-response accessor — no polling endpoint.
  • Maps headers onto the Usage meter model, governing-meter selection, and reader interface #30 meters (api_budget and any token/request windows the headers expose).
  • Selected only when provider.plan: api; otherwise dormant. The subscription path (Subscription usage reader: OAuth /api/oauth/usage poll with degradation chain #31) is unaffected.
  • Reading stays behind the Claude adapter boundary (Spec §3.3); the engine talks to UsageReader.
  • Both success and failure paths explicit; a missing/un-parseable header degrades rather than crashes.
  • Unit tests cover header parsing → meters using fixture responses (path is not exercised live).

Depends on: #30
Depends on: #17

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions