eca icon indicating copy to clipboard operation
eca copied to clipboard

Qwen API support

Open onetom opened this issue 6 months ago • 3 comments

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

Problem

I can't find any mentions of how to use the cloud version of https://qwen.ai/ neither in the issues, nor in the documentation on https://eca.dev

I'm new to the Qwen platform (I've only tried their open-weight models on-prem), so I'm not aware any technical or political obstacles, though the docs seem to be in Chinese only on https://help.aliyun.com/zh/model-studio/qwen-api-reference/ (when I tried to click the English option in the upper right globe-menu, nothing has happened), though the https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=doc#/doc/?type=model&url=2840914 is in English

The API reference says they support OpenAI & Anthropic APIs, but I hasn't even figured it out how to pay for it.

The online https://chat.qwen.ai/ so called Qwen Studio works, but doesn't indicate any quotas.

The Qwen CLI https://qwen.ai/qwencode also works and authenticates over OAuth.

I saw agent-shell can interface with Qwen CLI's experimental ACP (Agent Client Protocol) https://github.com/xenodium/agent-shell/blob/main/agent-shell-qwen.el

Solution

No idea what would be the best solution, but in the meantime Qwen would worth a mention in the docs, even if it just says not supported or configure it as a custom provider or use it through OpenRouter.

onetom avatar May 27 '26 06:05 onetom

@onetom I could not configure my account, and the documentation is pretty weird indeed, but I believe this should work in eca config :

{    
    "providers": {
        "qwen": {
            "api": "openai-responses",
            "url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
            "key": "KEY-HERE"
        }
    }
}

If that works we can add a example to https://eca.dev/config/models/

ericdallo avatar May 27 '26 18:05 ericdallo

"api": "openai-chat" works, with a Singapore specific url (which is where my free trial token quota was allocated at):

{
      "providers": {
        "qwen": {
            "api": "openai-chat",
            "url": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
            "key": "sk-ws-..."
        }
    }
}

With openai-responses or anthropic values, I'm just getting this error, when I ask the qwen/qwe3.7-max or qwen/qwen3.6-plus:


OpenAI response status: 404 body: 

if i M-x eca-open-global-config, i can see the qwen on the Provider "tab", configured with 50 models, regardless of the value of the api key in the config:

 ● qwen                               ✓ configured
   API Key · (config) · active
   api: openai-responses
   url: https://dashscope-intl.aliyuncs.com/compatible-mode/v1
   ▸ 50 models                          

Further reading

The https://www.alibabacloud.com/help/en/model-studio/qwen-api-via-openai-chat-completions gives this curl example for the Singapore region, where my free quota was allocated to:

curl -X POST https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen-plus",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user", 
            "content": "Who are you?"
        }
    ]
}'

and it responds with:

{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Qwen, a large-scale language model developed by Tongyi Lab. I'm designed to assist with a wide range of tasks—such as answering questions, writing stories or emails, coding, logical reasoning, mathematical calculations, and more. I can also help with creative projects, explain complex concepts, and support learning across various subjects.\n\nI aim to be helpful, accurate, and respectful in all interactions. While I don't have personal experiences or emotions, I strive to understand your needs and respond thoughtfully. Feel free to ask me anything—I'm here to help! 😊"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 23,
    "completion_tokens": 119,
    "total_tokens": 142,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  },
  "created": 1780083774,
  "system_fingerprint": null,
  "model": "qwen-plus",
  "id": "chatcmpl-509e8743-d434-9d72-a1d7-2d213a8be7bb"
}

onetom avatar May 29 '26 20:05 onetom

@onetom /chat/completions is the openai-chat api, unless they explicitly mention it should work with responses or anthropic, that's the way and should work mostly the same in the end but it will be a different url for sure. I will add a example using openai-chat with qwen, thanks!

ericdallo avatar May 30 '26 13:05 ericdallo