Skip to content

The agent that grows with you

fix(providers): fold Token Plan into the alibaba plugin, add runtime-path regressions, document all variants

Ayush Nangia695d86f51807
diff --git a/plugins/model-providers/alibaba-token-plan/__init__.py b/plugins/model-providers/alibaba-token-plan/__init__.py
deleted file mode 100644
index da8512b6a2f..00000000000
--- a/plugins/model-providers/alibaba-token-plan/__init__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-"""Alibaba Cloud Token Plan (Model Studio flat-token tier) provider profiles.
-
-Token Plan is a separate purchase tier from both standard DashScope and the
-Coding Plan, with its own dedicated endpoints and API key
-(``ALIBABA_TOKEN_PLAN_API_KEY``). Both regional endpoints speak the
-OpenAI-compatible chat-completions protocol:
-
- - ``alibaba-token-plan`` → token-plan.ap-southeast-1.maas.aliyuncs.com (international)
- - ``alibaba-token-plan-cn`` → token-plan.cn-beijing.maas.aliyuncs.com (mainland China)
-
-Profile names match the models.dev catalog keys exactly so model metadata
-lines up and ``model.provider: alibaba-token-plan-cn`` resolves at runtime
-instead of failing with "Unknown provider" (#73265).
-"""
-
-from providers import register_provider
-from providers.base import ProviderProfile
-
-alibaba_token_plan = ProviderProfile(
- name="alibaba-token-plan",
- aliases=("dashscope-token-plan",),
- display_name="Alibaba Cloud (Token Plan)",
- description="Alibaba Cloud Model Studio Token Plan (flat-token tier)",
- signup_url="https://help.aliyun.com/zh/model-studio/",
- env_vars=("ALIBABA_TOKEN_PLAN_API_KEY", "ALIBABA_TOKEN_PLAN_BASE_URL"),
- base_url="https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
- auth_type="api_key",
-)
-
-alibaba_token_plan_cn = ProviderProfile(
- name="alibaba-token-plan-cn",
- aliases=("dashscope-token-plan-cn",),
- display_name="Alibaba Cloud (Token Plan, China)",
- description="Alibaba Cloud Model Studio Token Plan, mainland-China endpoint",
- signup_url="https://help.aliyun.com/zh/model-studio/",
- env_vars=("ALIBABA_TOKEN_PLAN_API_KEY", "ALIBABA_TOKEN_PLAN_CN_BASE_URL"),
- base_url="https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
- auth_type="api_key",
-)
-
-register_provider(alibaba_token_plan)
-register_provider(alibaba_token_plan_cn)
diff --git a/plugins/model-providers/alibaba-token-plan/plugin.yaml b/plugins/model-providers/alibaba-token-plan/plugin.yaml
deleted file mode 100644
index 7c9fd95f83d..00000000000
--- a/plugins/model-providers/alibaba-token-plan/plugin.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-name: alibaba-token-plan-provider
-kind: model-provider
-version: 1.0.0
-description: Alibaba Cloud Model Studio Token Plan (international + China endpoints)
-author: Nous Research
diff --git a/plugins/model-providers/alibaba/__init__.py b/plugins/model-providers/alibaba/__init__.py
index 74fd171948c..f471650edb4 100644
--- a/plugins/model-providers/alibaba/__init__.py
+++ b/plugins/model-providers/alibaba/__init__.py
@@ -4,6 +4,13 @@ DashScope has region-split endpoints with the same key type:
- ``alibaba`` → dashscope-intl.aliyuncs.com (international)
- ``alibaba-cn`` → dashscope.aliyuncs.com (mainland China)
+The Model Studio Token Plan (flat-token tier of the SAME vendor/service,
+same OpenAI-compatible protocol, its own key + endpoints) registers here
+too rather than as a new plugin directory — one module per vendor, matching
+how the kimi module carries both of its endpoint variants:
+ - ``alibaba-token-plan`` → token-plan.ap-southeast-1.maas.aliyuncs.com
+ - ``alibaba-token-plan-cn`` → token-plan.cn-beijing.maas.aliyuncs.com
+
Profile names match the models.dev catalog keys exactly
(``alibaba`` / ``alibaba-cn``) so model metadata lines up and
``model.provider: alibaba-cn`` resolves at runtime (#73265).
@@ -30,3 +37,28 @@ alibaba_cn = ProviderProfile(
register_provider(alibaba)
register_provider(alibaba_cn)
+
+alibaba_token_plan = ProviderProfile(
+ name="alibaba-token-plan",
+ aliases=("dashscope-token-plan",),
+ display_name="Alibaba Cloud (Token Plan)",
+ description="Alibaba Cloud Model Studio Token Plan (flat-token tier)",
+ signup_url="https://help.aliyun.com/zh/model-studio/",
+ env_vars=("ALIBABA_TOKEN_PLAN_API_KEY", "ALIBABA_TOKEN_PLAN_BASE_URL"),
+ base_url="https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
+ auth_type="api_key",
+)
+
+alibaba_token_plan_cn = ProviderProfile(
+ name="alibaba-token-plan-cn",
+ aliases=("dashscope-token-plan-cn",),
+ display_name="Alibaba Cloud (Token Plan, China)",
+ description="Alibaba Cloud Model Studio Token Plan, mainland-China endpoint",
+ signup_url="https://help.aliyun.com/zh/model-studio/",
+ env_vars=("ALIBABA_TOKEN_PLAN_API_KEY", "ALIBABA_TOKEN_PLAN_CN_BASE_URL"),
+ base_url="https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
+ auth_type="api_key",
+)
+
+register_provider(alibaba_token_plan)
+register_provider(alibaba_token_plan_cn)
diff --git a/tests/hermes_cli/test_api_key_providers.py b/tests/hermes_cli/test_api_key_providers.py
index a6dc2351132..16aee6c957a 100644
--- a/tests/hermes_cli/test_api_key_providers.py
+++ b/tests/hermes_cli/test_api_key_providers.py
@@ -1217,3 +1217,46 @@ class TestDeepInfraProviderProfile:
# of truth. Pin the shape only, not contents.
assert isinstance(profile.fallback_models, tuple)
+
+
+class TestRuntimeAlibabaRegionalAndTokenPlan:
+ """#73265: the catalog-advertised Alibaba China/Token Plan variants must
+ resolve on the shared execution path (resolve_runtime_provider), not just
+ in the profile registry — provider, key, api mode, and base URL."""
+
+ def test_runtime_alibaba_cn(self, monkeypatch):
+ monkeypatch.setenv("DASHSCOPE_API_KEY", "ds-key")
+ from hermes_cli.runtime_provider import resolve_runtime_provider
+ result = resolve_runtime_provider(requested="alibaba-cn")
+ assert result["provider"] == "alibaba-cn"
+ assert result["api_mode"] == "chat_completions"
+ assert result["api_key"] == "ds-key"
+ assert result["base_url"] == "https://dashscope.aliyuncs.com/compatible-mode/v1"
+
+ def test_runtime_alibaba_coding_plan_cn(self, monkeypatch):
+ monkeypatch.setenv("ALIBABA_CODING_PLAN_API_KEY", "acp-key")
+ monkeypatch.delenv("DASHSCOPE_API_KEY", raising=False)
+ from hermes_cli.runtime_provider import resolve_runtime_provider
+ result = resolve_runtime_provider(requested="alibaba-coding-plan-cn")
+ assert result["provider"] == "alibaba-coding-plan-cn"
+ assert result["api_mode"] == "chat_completions"
+ assert result["api_key"] == "acp-key"
+ assert result["base_url"] == "https://coding.dashscope.aliyuncs.com/v1"
+
+ def test_runtime_alibaba_token_plan(self, monkeypatch):
+ monkeypatch.setenv("ALIBABA_TOKEN_PLAN_API_KEY", "atp-key")
+ from hermes_cli.runtime_provider import resolve_runtime_provider
+ result = resolve_runtime_provider(requested="alibaba-token-plan")
+ assert result["provider"] == "alibaba-token-plan"
+ assert result["api_mode"] == "chat_completions"
+ assert result["api_key"] == "atp-key"
+ assert result["base_url"] == "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
+
+ def test_runtime_alibaba_token_plan_cn(self, monkeypatch):
+ monkeypatch.setenv("ALIBABA_TOKEN_PLAN_API_KEY", "atp-key")
+ from hermes_cli.runtime_provider import resolve_runtime_provider
+ result = resolve_runtime_provider(requested="alibaba-token-plan-cn")
+ assert result["provider"] == "alibaba-token-plan-cn"
+ assert result["api_mode"] == "chat_completions"
+ assert result["api_key"] == "atp-key"
+ assert result["base_url"] == "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
diff --git a/website/docs/integrations/providers.md b/website/docs/integrations/providers.md
index 3a3985cc7a5..4fe52265e38 100644
--- a/website/docs/integrations/providers.md
+++ b/website/docs/integrations/providers.md
@@ -35,8 +35,9 @@ You need at least one way to connect to an LLM. Use `hermes model` to switch pro
| **MiniMax China** | `MINIMAX_CN_API_KEY` in `~/.hermes/.env` (provider: `minimax-cn`) |
| **xAI (Grok) — Responses API** | `XAI_API_KEY` in `~/.hermes/.env` (provider: `xai`) |
| **xAI Grok OAuth (SuperGrok)** | `hermes model` → "xAI Grok OAuth (SuperGrok / Premium+)" — browser login, no API key. See [guide](../guides/xai-grok-oauth.md) |
-| **Qwen Cloud (Alibaba DashScope)** | `DASHSCOPE_API_KEY` in `~/.hermes/.env` (provider: `alibaba`) |
-| **Alibaba Cloud (Coding Plan)** | `DASHSCOPE_API_KEY` (provider: `alibaba-coding-plan`, alias: `alibaba_coding`) — separate billing SKU, different endpoint |
+| **Qwen Cloud (Alibaba DashScope)** | `DASHSCOPE_API_KEY` in `~/.hermes/.env` (provider: `alibaba`; mainland-China endpoint: `alibaba-cn`) |
+| **Alibaba Cloud (Coding Plan)** | `ALIBABA_CODING_PLAN_API_KEY` (falls back to `DASHSCOPE_API_KEY`) (provider: `alibaba-coding-plan`, alias: `alibaba_coding`; mainland-China endpoint: `alibaba-coding-plan-cn`) — separate billing SKU, different endpoint |
+| **Alibaba Cloud (Token Plan)** | `ALIBABA_TOKEN_PLAN_API_KEY` in `~/.hermes/.env` (provider: `alibaba-token-plan`; mainland-China endpoint: `alibaba-token-plan-cn`) — Model Studio flat-token tier |
| **Kilo Code** | `KILOCODE_API_KEY` in `~/.hermes/.env` (provider: `kilocode`) |
| **Xiaomi MiMo** | `XIAOMI_API_KEY` in `~/.hermes/.env` (provider: `xiaomi`, aliases: `mimo`, `xiaomi-mimo`) |
| **Tencent TokenHub** | `TOKENHUB_API_KEY` in `~/.hermes/.env` (provider: `tencent-tokenhub`, aliases: `tencent`, `tokenhub`, `tencentmaas`) |
diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.md
index 473c7530740..6ba9a5e9500 100644
--- a/website/docs/reference/cli-commands.md
+++ b/website/docs/reference/cli-commands.md
@@ -116,7 +116,7 @@ Common options:
| `--oneshot` | With `-q`/`--query-file`: answer the query and exit (the pre-0.21 single-query behavior) instead of seeding an interactive session. Implied on non-TTY stdio and by `-Q`. |
| `-m`, `--model <model>` | Override the model for this run. |
| `-t`, `--toolsets <csv>` | Enable a comma-separated set of toolsets. |
-| `--provider <provider>` | Force a provider: `auto`, `openrouter`, `nous`, `openai-codex`, `copilot-acp`, `copilot`, `anthropic`, `gemini`, `huggingface`, `novita` (aliases `novita-ai`, `novitaai`), `openai-api`, `zai`, `kimi-coding`, `kimi-coding-cn`, `minimax`, `minimax-cn`, `minimax-oauth`, `kilocode`, `xiaomi`, `arcee`, `gmi`, `upstage` (alias `solar`), `alibaba`, `alibaba-coding-plan` (alias `alibaba_coding`), `deepseek`, `nvidia`, `ollama-cloud`, `xai` (alias `grok`), `xai-oauth` (alias `grok-oauth`), `qwen-oauth`, `bedrock`, `opencode-zen`, `opencode-go`, `opencode-free` (aliases `free`, `opencode_free`; keyless), `commandcode`, `commandcode-anthropic`, `ai-gateway`, `azure-foundry`, `lmstudio`, `stepfun`, `tencent-tokenhub` (alias `tencent`, `tokenhub`), `router` (aliases `ramp-router`, `ramp`), `nebius-token-factory` (aliases `nebius`, `nebius-tf`, `tokenfactory`), `tencent-tokenplan` (aliases `tokenplan`, `tencent-lkeap`). |
+| `--provider <provider>` | Force a provider: `auto`, `openrouter`, `nous`, `openai-codex`, `copilot-acp`, `copilot`, `anthropic`, `gemini`, `huggingface`, `novita` (aliases `novita-ai`, `novitaai`), `openai-api`, `zai`, `kimi-coding`, `kimi-coding-cn`, `minimax`, `minimax-cn`, `minimax-oauth`, `kilocode`, `xiaomi`, `arcee`, `gmi`, `upstage` (alias `solar`), `alibaba`, `alibaba-cn`, `alibaba-coding-plan` (alias `alibaba_coding`), `alibaba-coding-plan-cn`, `alibaba-token-plan`, `alibaba-token-plan-cn`, `deepseek`, `nvidia`, `ollama-cloud`, `xai` (alias `grok`), `xai-oauth` (alias `grok-oauth`), `qwen-oauth`, `bedrock`, `opencode-zen`, `opencode-go`, `opencode-free` (aliases `free`, `opencode_free`; keyless), `commandcode`, `commandcode-anthropic`, `ai-gateway`, `azure-foundry`, `lmstudio`, `stepfun`, `tencent-tokenhub` (alias `tencent`, `tokenhub`), `router` (aliases `ramp-router`, `ramp`), `nebius-token-factory` (aliases `nebius`, `nebius-tf`, `tokenfactory`), `tencent-tokenplan` (aliases `tokenplan`, `tencent-lkeap`). |
| `-s`, `--skills <name>` | Preload one or more skills for the session (can be repeated or comma-separated). |
| `-v`, `--verbose` | Verbose output. |
| `-Q`, `--quiet` | Programmatic mode: suppress banner/spinner/tool previews. |
diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md
index 135da4e864b..6ece971ab74 100644
--- a/website/docs/reference/environment-variables.md
+++ b/website/docs/reference/environment-variables.md
@@ -82,8 +82,12 @@ Hermes reads environment variables from the process environment and, for user-ma
| `ANTHROPIC_TOKEN` | Manual or legacy Anthropic OAuth/setup-token override |
| `DASHSCOPE_API_KEY` | Qwen Cloud (Alibaba DashScope) API key for Qwen models ([modelstudio.console.alibabacloud.com](https://modelstudio.console.alibabacloud.com/)) |
| `DASHSCOPE_BASE_URL` | Custom DashScope base URL (default: `https://dashscope-intl.aliyuncs.com/compatible-mode/v1`; use `https://dashscope.aliyuncs.com/compatible-mode/v1` for mainland-China region) |
-| `ALIBABA_CODING_PLAN_API_KEY` | Qwen Coding Plan API key (`alibaba-coding-plan` provider) |
-| `ALIBABA_CODING_PLAN_BASE_URL` | Override the Qwen Coding Plan base URL |
+| `ALIBABA_CODING_PLAN_API_KEY` | Qwen Coding Plan API key (`alibaba-coding-plan` / `alibaba-coding-plan-cn` providers) |
+| `ALIBABA_CODING_PLAN_BASE_URL` | Override the Qwen Coding Plan base URL (international) |
+| `ALIBABA_CODING_PLAN_CN_BASE_URL` | Override the Qwen Coding Plan base URL (mainland China) |
+| `ALIBABA_TOKEN_PLAN_API_KEY` | Alibaba Model Studio Token Plan API key (`alibaba-token-plan` / `alibaba-token-plan-cn` providers) |
+| `ALIBABA_TOKEN_PLAN_BASE_URL` | Override the Token Plan base URL (international) |
+| `ALIBABA_TOKEN_PLAN_CN_BASE_URL` | Override the Token Plan base URL (mainland China) |
| `DEEPSEEK_API_KEY` | DeepSeek API key for direct DeepSeek access ([platform.deepseek.com](https://platform.deepseek.com/api_keys)) |
| `DEEPSEEK_BASE_URL` | Custom DeepSeek API base URL |
| `DEEPINFRA_API_KEY` | DeepInfra API key ([deepinfra.com](https://deepinfra.com/dash/api_keys)) |