Skip to content

feat: add alibaba-token-plan provider#33109

Closed
orcool wants to merge 1 commit into
NousResearch:mainfrom
orcool:feat/alibaba-token-plan-provider
Closed

feat: add alibaba-token-plan provider#33109
orcool wants to merge 1 commit into
NousResearch:mainfrom
orcool:feat/alibaba-token-plan-provider

Conversation

@orcool

@orcool orcool commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Add support for Alibaba Cloud Token Plan (Team Edition) as a dedicated provider, separate from alibaba-coding-plan.

Problem

Token Plan users currently have to configure Alibaba's Token Plan through a custom endpoint. That is easy to mix up with Coding Plan or DashScope pay-as-you-go because each plan uses different API keys, base URLs, billing/quota semantics, and supported model catalogs.

Alibaba's own Hermes Agent setup guide recommends the Token Plan Anthropic-compatible endpoint, so this PR wires Token Plan as an anthropic_messages provider by default.

Changes

  • Add alibaba-token-plan provider to PROVIDER_REGISTRY
  • Default Token Plan to the Anthropic-compatible endpoint:
    • https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic
  • Add alibaba-token-plan provider overlay with:
    • transport="anthropic_messages"
    • ALIBABA_TOKEN_PLAN_API_KEY
    • ALIBABA_TOKEN_PLAN_BASE_URL override support
  • Add provider picker entry for Alibaba Token Plan
  • Add aliases:
    • alibaba_token
    • alibaba-token
    • alibaba_token_plan
  • Add Token Plan model catalog:
    • qwen3.7-max
    • qwen3.6-plus
    • qwen3.6-flash
    • deepseek-v4-pro
    • deepseek-v4-flash
    • deepseek-v3.2
    • kimi-k2.6
    • kimi-k2.5
    • glm-5.1
    • glm-5
    • MiniMax-M2.5
  • Add regression tests for:
    • alias parsing
    • catalog fallback validation
    • provider registry URL/env wiring
    • provider overlay transport/base URL wiring
    • /apps/anthropic API-mode auto-detection

Notes

Token Plan also exposes an OpenAI-compatible URL:

https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1

This PR intentionally uses the Anthropic-compatible endpoint by default because Alibaba's Hermes Agent guide recommends that configuration for Token Plan. Users can still override the base URL with ALIBABA_TOKEN_PLAN_BASE_URL if they need the OpenAI-compatible endpoint.

Image generation models such as qwen-image-2.0 and wan2.7-image are not included in the chat model catalog here. Alibaba documents those as separate multimodal-generation APIs that should be integrated through a tool/skill/extension mechanism.

Test Plan

  • ./venv/bin/python -m py_compile hermes_cli/auth.py hermes_cli/providers.py tests/hermes_cli/test_alibaba_token_plan_provider.py
  • ./venv/bin/pytest tests/hermes_cli/test_alibaba_token_plan_provider.py tests/hermes_cli/test_model_validation.py tests/hermes_cli/test_detect_api_mode_for_url.py -q --tb=short -o 'addopts='
    • 104 passed

Docs Source

  • Token Plan quick start: https://www.alibabacloud.com/help/en/model-studio/token-plan-quickstart
  • Token Plan overview: https://www.alibabacloud.com/help/en/model-studio/token-plan-overview
  • Alibaba Hermes Agent setup guide: https://www.alibabacloud.com/help/en/model-studio/hermes-agent

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins labels May 27, 2026
@orcool orcool force-pushed the feat/alibaba-token-plan-provider branch 2 times, most recently from e57261c to b91a7fc Compare May 27, 2026 08:13
@orcool

orcool commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated this PR after a self-review:

  • Added alibaba-token-plan to CANONICAL_PROVIDERS so it appears in the provider/model picker.
  • Added aliases to the model parser as well as provider auth/metadata aliases.
  • Added tests for alias parsing and catalog fallback validation.
  • Rebased on current main; PR is mergeable.

Focused test passes: 83/83 in tests/hermes_cli/test_model_validation.py.

Add support for Alibaba Cloud Token Plan (Team Edition) as a dedicated
provider with its own model catalog.

Token Plan offers broader model selection than Coding Plan, including:
- Qwen 3.7-max, 3.6-plus, 3.6-flash
- DeepSeek v4-pro, v4-flash, v3.2
- Kimi k2.6, k2.5
- GLM 5.1, 5
- MiniMax M2.5

Base URL: https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1
Env var: ALIBABA_TOKEN_PLAN_API_KEY

This allows users to select the correct provider in setup wizard and
model picker instead of using alibaba-coding-plan which has a limited
model list.

Refs: https://modelstudio.console.alibabacloud.com/ap-southeast-1/?tab=doc#/doc/?type=model&url=3028858
@orcool orcool force-pushed the feat/alibaba-token-plan-provider branch from b91a7fc to 7eef57c Compare May 27, 2026 08:57
@orcool

orcool commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated after checking Alibaba's official Hermes Agent setup guide.

Changes in this update:

  • Default Token Plan to the Anthropic-compatible endpoint: https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic
  • Set the provider overlay transport to anthropic_messages
  • Add ALIBABA_TOKEN_PLAN_API_KEY and base_url_override to the provider overlay
  • Add a display label for the Hermes-only provider path
  • Add focused regression tests for registry wiring, overlay wiring, alias resolution, and /apps/anthropic api-mode detection

The OpenAI-compatible Token Plan endpoint can still be used by setting ALIBABA_TOKEN_PLAN_BASE_URL explicitly.

Focused tests pass: 104/104.

@orcool

orcool commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Additional protocol-adjacent checks pass after the Anthropic-compatible endpoint change:

  • test_alibaba_token_plan_provider.py
  • test_model_validation.py
  • test_detect_api_mode_for_url.py
  • test_custom_provider_model_switch.py
  • TestDelegationCredentialResolution from test_delegate.py

Result: 133 passed.

@orcool

orcool commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Closing this for now because the branch has drifted from current main and the provider integration surface changed while this PR was open. If still useful, I’ll reopen a cleaner, smaller PR from current main with the Token Plan / Coding Plan separation and transport choice documented more clearly.

@orcool orcool closed this May 28, 2026
@orcool orcool deleted the feat/alibaba-token-plan-provider branch May 28, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants