Files
hermes-agent/plugins/model-providers/alibaba/__init__.py
T
Teknium 44a57921c5 fix(providers): hide phantom -cn picker rows lit only by shared intl keys; give alibaba-token-plan-cn its own key var
- alibaba-coding-plan-cn / alibaba-token-plan-cn keep the shared intl key vars
  as ordered fallbacks after their dedicated *_CN_API_KEY, so users who set
  ALIBABA_CODING_PLAN_API_KEY / ALIBABA_TOKEN_PLAN_API_KEY for the CN endpoint
  keep working (the PR as filed dropped them).
- list_authenticated_providers hides a '-cn' row whose only lit key vars are
  ones it shares with its non-CN sibling, unless that CN provider is the
  configured model.provider. With only the shared key: one row, not two;
  DASHSCOPE_API_KEY alone: 3 alibaba rows, not 4.
- Docs: environment-variables.md, providers.md.
2026-09-02 05:32:20 -07:00

65 lines
2.6 KiB
Python

"""Alibaba Cloud DashScope provider profiles.
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).
"""
from providers import register_provider
from providers.base import ProviderProfile
alibaba = ProviderProfile(
name="alibaba",
aliases=("dashscope", "alibaba-cloud", "qwen-dashscope"),
env_vars=("DASHSCOPE_API_KEY",),
base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)
alibaba_cn = ProviderProfile(
name="alibaba-cn",
aliases=("dashscope-cn", "alibaba-cloud-cn"),
display_name="Alibaba Cloud DashScope (China)",
description="Alibaba Cloud DashScope, mainland-China endpoint",
env_vars=("DASHSCOPE_API_KEY", "DASHSCOPE_CN_BASE_URL"),
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
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_CN_API_KEY", "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)