How to hit the Alibaba Qwen (Model Studio) API

Alibaba Cloud Model Studio (DashScope) serves the Qwen models with an OpenAI-compatible API. This example uses the international endpoint.

Authentication

Create a key at Model Studio. Send it as Authorization: Bearer <key>. The key must come from the same region as the endpoint. In the examples it's written {{DASHSCOPE_API_KEY}}.

Full reference: https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope

Chat completion

curl 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": "user", "content": "Explain what a webhook is in two sentences."}]}'
Run in PostTaco