-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Summary
Add OpenCode provider support in OpenUsage for:
- Zen billing usage (balance, monthly usage/limit, reload settings)
- Black rolling/weekly usage when available
Why
OpenCode does not currently expose a documented public billing/usage API for Zen API keys. Zen docs expose model/inference endpoints, not account billing endpoints.
Research
Public docs / endpoints
- Zen docs: https://opencode.ai/docs/zen/
- Documented endpoints are model/inference oriented (
/zen/v1/models,/zen/v1/responses,/zen/v1/messages,/zen/v1/chat/completions)
Prior art
- CodexBar OpenCode provider uses browser cookies + private
_servercalls:
What we verified
- With authenticated session cookies,
GET https://opencode.ai/workspace/<workspaceId>/billingreturns HTML that embeds hydrated billing payload in script (contains fields likebalance,monthlyUsage,monthlyLimit,reload*,subscription*, payment list). - Hardcoded
_serverfunction IDs are brittle/unstable across time. - In OpenCode source, Black rolling/weekly usage is computed in dashboard server-side flow (
querySubscription), not via documented public API-key endpoint:
Proposal
Implement OpenCode as experimental provider via authenticated dashboard payload parsing:
- Auth input: manual
Cookieheader (required), optional workspace ID override. - Fetch billing page (
/workspace/<id>/billing) and parse hydration payload. - Map Zen metrics from
billing.getpayload:- current balance
- monthly usage / limit
- reload settings
- If Black subscription usage is present, map rolling/weekly usage + reset timers.
- Fail loudly with explicit parse/auth errors (no silent fallback).
Scope guardrails
- No browser scraping automation in v1.
- No reliance on hardcoded private
_serverIDs in v1. - Mark provider as experimental/fragile in UI/docs.
Acceptance Criteria
- OpenCode plugin exists with manual cookie auth UX.
- Parser covered with fixtures + regression tests for payload-shape drift.
- Clear user-facing errors for expired cookie / parse failure.
- README updated to include OpenCode support and experimental warning.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels