Skip to content

Pi Web API-key setup does not support Qwen Token Plan custom endpoint, causing misleading 401 #583

Description

@zackie1671-create

Summary

Qwen Token Plan works correctly in Pi CLI after configuring it as a custom provider,
but entering the Token Plan API key directly in Pi Web's Models/API Key UI results in:

401 Invalid API-key provided

The API key itself is valid.

Environment

  • Windows 11
  • Pi: 0.84.x
  • Pi Web: latest
  • Provider: Alibaba Cloud Qwen Token Plan Personal
  • Model: qwen3.8-max

What I initially did

In Pi Web, I entered my Qwen Token Plan API key (sk-sp-...) through the API-key UI.

Pi Web returned:

401 Invalid API-key provided

Root cause / workaround

Qwen Token Plan requires its dedicated OpenAI-compatible endpoint:

https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1

It cannot be used as a normal Qwen/DashScope API key.

I added the following custom provider to:

~/.pi/agent/models.json

{
"providers": {
"qwen-token-plan": {
"baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
"api": "openai-completions",
"apiKey": "QWEN_TOKEN_PLAN_API_KEY",
"models": [
{
"id": "qwen3.8-max",
"name": "Qwen 3.8 Max - Token Plan",
"input": ["text", "image"]
}
]
}
}
}

After setting the environment variable and launching Pi/Pi Web with this configuration,
Qwen 3.8 Max works correctly in both CLI and Pi Web.

Expected behavior

It would be helpful if Pi Web could support custom API-key providers directly from the Models UI,
including:

  • custom Base URL
  • API compatibility type
  • model ID
  • environment-variable-backed API key

Alternatively, if a key such as sk-sp-... is entered for Qwen Token Plan,
the UI could explain that Token Plan requires a different endpoint instead of showing a generic
"Invalid API key" error.

Why this matters

The current UI makes it appear that the API key itself is invalid,
while the actual issue is the provider endpoint/configuration.

This creates a confusing difference between Pi CLI and Pi Web.

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