Skip to content

OpenCode Go: support the public usage API with an API key #3065

Description

@akshayprabhu200

Summary

Use OpenCode Go's public authenticated usage endpoint (GET https://opencode.ai/zen/go/v1/usage) when an OPENCODE_API_KEY is configured, while retaining the existing local-history and cookie-backed paths as fallbacks.

Current behavior

Current main has local and web strategies for OpenCode Go, but no API-key strategy and no reference to the public endpoint. Users with an API key therefore cannot obtain authoritative rolling, weekly, and monthly usage windows through the supported API.

This is distinct from #2982:

Expected behavior

  • Resolve OPENCODE_API_KEY from provider configuration or the environment.
  • Send it only to the fixed OpenCode HTTPS usage endpoint as a Bearer credential.
  • Parse rolling, weekly, and monthly percentages and reset times.
  • Preserve local daily cost/model history when authoritative API windows are overlaid.
  • Preserve the existing cookie-backed path as a compatibility fallback.
  • Propagate cancellation and fail soft to established sources on ordinary API errors.
  • Never log or include the credential in diagnostics or proof.

Proposed implementation and proof

PR #2879 contains a provider-scoped implementation, deterministic request-contract and fallback tests, documentation, and prior green cross-platform CI. Before merge it should be rebased onto current main and accompanied by redacted authenticated runtime proof from a real OpenCode Go account.

No credentials or personal usage data are included here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions