Skip to content

[feature]: Support model ID mapping for proxy providers (LiteLLM, etc.) #95

@sacrtap

Description

@sacrtap

Problem

When using a proxy provider like LiteLLM, the modelID returned by the session API reflects the proxy's model name (e.g., litellm-local/qwen3.6-plus) rather than the original provider prefix (e.g., alibaba-cn/qwen3.6-plus).

The isAlibabaModelId() function only matches models starting with alibaba/ or alibaba-cn/, so local request counting never triggers for proxied models.

Root Cause

plugin.js:1389isAlibabaModelId(model) checks:

normalized.startsWith("alibaba/") || normalized.startsWith("alibaba-cn/")

But when routed through LiteLLM, sessionMeta.modelID = litellm-local/qwen3.6-plus, which doesn't match.

Impact

  • recordAlibabaCodingPlanCompletion() is never called
  • alibaba-coding-plan-local-quota.json recent array stays empty
  • Users with proxy setups cannot track local request counts

Suggested Solutions

Option A: Configurable model ID mapping

Add a config option to map custom model prefixes to provider quota tracking:

{
  "modelIdMapping": {
    "litellm-local/qwen3.6-plus": "alibaba-coding-plan"
  }
}

Option B: Provider-based matching fallback

When modelID doesn't match any known prefix, fall back to providerID from sessionMeta to determine which quota tracker to use.

Option C: Wildcard/pattern matching in isAlibabaModelId

Allow configurable regex or wildcard patterns for model ID matching.

Environment

  • opencode-quota: v3.8.7
  • opencode: v1.15.4
  • Provider: LiteLLM proxy routing to Alibaba Coding Plan

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