Skip to content

[feature]: Add Alibaba Token Plan (alibaba-token-plan) quota provider support #268

Description

@lucasrochaqw

Pre-flight checks

  • I searched existing issues and did not find a duplicate request.
  • I reviewed current behavior on the production released OpenCode version.

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.jsALIBABA_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.jsalibaba-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:

  1. 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.
  2. Register it in provider-metadata.js (runtimeIds, label "Alibaba Token Plan").
  3. 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()).
  4. 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

  • An auth.json entry alibaba-token-plan: { type: "api", key: ... } (or ALIBABA_TOKEN_PLAN_API_KEY) is detected with enabledProviders: "auto".
  • Usage from alibaba-token-plan/* models is attributed and shown in /quota, quota_status, and the TUI sidebar.
  • Reported windows/limits reflect the Token Plan's token-based allowance (or are clearly labeled as local estimates), not the Coding Plan request tiers.
  • alibaba-token-plan-cn is handled or explicitly documented as out of scope.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions