Pre-flight checks
OpenCode version reviewed
1.18.30 (opencode-quota 4.8.2 installed; verified the same gaps still exist in 4.9.0)
Problem statement
The alibaba-token-plan provider (registered on models.dev as "Alibaba Token Plan", e.g. alibaba-token-plan/qwen3.8-max) is never detected by opencode-quota. With enabledProviders: "auto" and a valid auth.json entry:
{ "alibaba-token-plan": { "type": "api", "key": "..." } }
the provider does not appear in /quota, the quota_status tool, the TUI sidebar, or ~/.cache/opencode/quota-provider-state/. Only alibaba-coding-plan / alibaba are recognized.
Root-cause pointers in dist/ (same in 4.8.2 and 4.9.0):
lib/alibaba-auth.js — ALIBABA_AUTH_KEYS and ALIBABA_PROVIDER_KEYS are ["alibaba-coding-plan", "alibaba"]; allowed env vars are only ALIBABA_CODING_PLAN_API_KEY / ALIBABA_API_KEY; isAlibabaModelId() only matches alibaba/ and alibaba-cn/ prefixes.
lib/qwen-local-quota.js — local usage counting only scans messages with providerIds: ["alibaba-coding-plan", "alibaba"], so traffic on alibaba-token-plan/* models is never attributed.
lib/provider-metadata.js — alibaba-coding-plan entry has runtimeIds: ["alibaba-coding-plan"], synonyms: ["alibaba"]; nothing maps alibaba-token-plan.
Provider facts (from models.dev / Alibaba docs):
Note: the Token Plan quota is a token-based allowance (per model family / window), not the Coding Plan's request-count windows (lite/pro tiers, 5h/weekly/monthly request caps), so the existing Coding Plan local-estimation limits would not be accurate even if the provider id were simply aliased.
Proposed change
Recognize alibaba-token-plan (and ideally alibaba-token-plan-cn) as a first-class quota provider:
- Add it to the Alibaba auth/provider key lists (or a dedicated
alibaba-token-plan-auth.js), including ALIBABA_TOKEN_PLAN_API_KEY as an allowed env var.
- Register it in
provider-metadata.js (runtimeIds, label "Alibaba Token Plan").
- Count local usage for messages whose
providerID is alibaba-token-plan / model IDs prefixed alibaba-token-plan/ (extend qwen-local-quota.js providerIds and isAlibabaModelId()).
- Track the Token Plan's token-based windows per its docs rather than the Coding Plan request tiers. If Alibaba exposes no quota/usage endpoint for the Token Plan, a local token-based estimation (analogous to the Coding Plan's local estimation, but summing tokens against the plan's token allowance) would already be very useful.
Alternatives considered
Acceptance criteria
Pre-flight checks
OpenCode version reviewed
1.18.30 (opencode-quota 4.8.2 installed; verified the same gaps still exist in 4.9.0)
Problem statement
The
alibaba-token-planprovider (registered on models.dev as "Alibaba Token Plan", e.g.alibaba-token-plan/qwen3.8-max) is never detected by opencode-quota. WithenabledProviders: "auto"and a validauth.jsonentry:{ "alibaba-token-plan": { "type": "api", "key": "..." } }the provider does not appear in
/quota, thequota_statustool, the TUI sidebar, or~/.cache/opencode/quota-provider-state/. Onlyalibaba-coding-plan/alibabaare recognized.Root-cause pointers in
dist/(same in 4.8.2 and 4.9.0):lib/alibaba-auth.js—ALIBABA_AUTH_KEYSandALIBABA_PROVIDER_KEYSare["alibaba-coding-plan", "alibaba"]; allowed env vars are onlyALIBABA_CODING_PLAN_API_KEY/ALIBABA_API_KEY;isAlibabaModelId()only matchesalibaba/andalibaba-cn/prefixes.lib/qwen-local-quota.js— local usage counting only scans messages withproviderIds: ["alibaba-coding-plan", "alibaba"], so traffic onalibaba-token-plan/*models is never attributed.lib/provider-metadata.js—alibaba-coding-planentry hasruntimeIds: ["alibaba-coding-plan"],synonyms: ["alibaba"]; nothing mapsalibaba-token-plan.Provider facts (from models.dev / Alibaba docs):
https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1(OpenAI-compatible)ALIBABA_TOKEN_PLAN_API_KEYalibaba-token-plan-cn(similar tominimax-china-coding-planhandled in [bug]: MiniMax Token Plan (CN) does not display quota #232).Note: the Token Plan quota is a token-based allowance (per model family / window), not the Coding Plan's request-count windows (lite/pro tiers, 5h/weekly/monthly request caps), so the existing Coding Plan local-estimation limits would not be accurate even if the provider id were simply aliased.
Proposed change
Recognize
alibaba-token-plan(and ideallyalibaba-token-plan-cn) as a first-class quota provider:alibaba-token-plan-auth.js), includingALIBABA_TOKEN_PLAN_API_KEYas an allowed env var.provider-metadata.js(runtimeIds, label "Alibaba Token Plan").providerIDisalibaba-token-plan/ model IDs prefixedalibaba-token-plan/(extendqwen-local-quota.jsproviderIds andisAlibabaModelId()).Alternatives considered
alibaba-token-planinto the existingalibaba-coding-planauth keys locally: detection would trigger, but usage attribution still misses (providerIdsfilter andisAlibabaModelId()prefix), and the displayed limits would be the Coding Plan lite/pro request windows, i.e. wrong numbers for a Token Plan subscription.Acceptance criteria
auth.jsonentryalibaba-token-plan: { type: "api", key: ... }(orALIBABA_TOKEN_PLAN_API_KEY) is detected withenabledProviders: "auto".alibaba-token-plan/*models is attributed and shown in/quota,quota_status, and the TUI sidebar.alibaba-token-plan-cnis handled or explicitly documented as out of scope.