How to Access the Qwen API: A Practical Guide (Model Studio, DashScope & Self-Hosting)

Getting started with the Qwen Chat ecosystem programmatically comes down to one official route — Alibaba Cloud Model Studio — plus a fully open-weight path you can host yourself. This guide walks through both, from creating a key to your first request.

Qwen (also written Tongyi Qianwen) is a family of large language models built by Alibaba Cloud, as documented on Wikipedia. You reach the paid API through Model Studio’s DashScope service, and you can alternatively download the open weights and run them on your own hardware.

Diagram of the two ways to access Qwen: the Model Studio cloud API and self-hosting, both connecting to the central Qwen model.
Two routes to Qwen: the official Model Studio API, or self-hosting the open weights yourself.

This is an unofficial guide — qwenchat.pro is not affiliated with Alibaba Cloud or the Qwen team. Model names, endpoints and prices change; always confirm current values in the official documentation.

What the Qwen API actually is

Qwen is Alibaba Cloud’s large language model family, spanning general-purpose chat models, vision-language models, and coding-specialized variants. The official API surface for reaching these models is Alibaba Cloud Model Studio, and the underlying model-serving layer that actually processes requests is called DashScope. In practice, DashScope exposes two things at once: a native interface with the fullest feature set, and an OpenAI-compatible mode that lets existing OpenAI SDK code point at Qwen with minimal changes.

That layering — Alibaba Cloud as the parent platform, Model Studio as the console, DashScope as the serving engine — trips up a lot of newcomers, so it’s worth separating the three names before writing any code.

Layered architecture: Alibaba Cloud, then Model Studio, then DashScope, then Qwen models, connected left to right.
How the pieces fit: Alibaba Cloud hosts Model Studio, which serves the Qwen models through DashScope.

Model Studio vs. DashScope vs. Qwen Chat

People frequently conflate three different products that share the Qwen name. Model Studio is the console where you manage billing, activate services, and generate API keys. DashScope is the model-serving service and native SDK that Model Studio sits on top of — it’s what actually runs inference. Qwen Chat (chat.qwen.ai) is the consumer-facing web chat interface, not an API at all — you can’t call it programmatically. This unofficial hub, qwenchat.pro, covers the Qwen ecosystem for readers but is a separate, independent resource.

NameWhat it isWhen you use it
Model StudioConsole/platform for account, billing, keysSetting up access, managing usage
DashScopeModel-serving service + native SDKMaking native or OpenAI-compatible API calls
Qwen ChatConsumer web chat UICasual browser-based chat, not programmatic access

Two API interfaces: native DashScope and OpenAI-compatible

DashScope offers a native interface with the fullest feature set — this is the recommended path if you need every parameter and capability Alibaba Cloud exposes. Alongside it, Model Studio also documents an OpenAI-compatible Chat Completions mode, which is a drop-in option for teams that already have code built around the OpenAI Python or Node SDKs. Anthropic-Messages-style compatibility is also documented for some models, though that should be treated as a documented option to check per-model rather than a blanket guarantee across the whole catalog.

How to get a Qwen API key

Getting a working key means creating an Alibaba Cloud account, activating Model Studio, and generating credentials from the console’s API Keys section. The official first-API-call guide walks through the exact console screens, which can shift slightly by region, so treat the steps below as the general shape rather than a pixel-perfect walkthrough.

Once generated, the key is passed as a Bearer token in the Authorization header of every request, and it’s common practice to store it in an environment variable such as DASHSCOPE_API_KEY rather than hardcoding it. New Model Studio accounts typically receive a limited free trial token quota to test the API before paying — the exact amount varies by region and time, so check your console’s billing page for the current figure rather than relying on any number quoted elsewhere.

Five-step flow to obtain a Qwen API key: create account, enable console, open API Keys, generate a new key, store securely.
Getting a Qwen API key in five steps — finish by storing it in an environment variable, never in your source code.

Step-by-step (ordered list)

  1. Create or sign in to an Alibaba Cloud account.
  2. Open Alibaba Cloud Model Studio and activate the service.
  3. Navigate to the API Keys section in the console.
  4. Create a new API key and copy it — most consoles only show the full value once.
  5. Store the key as an environment variable (for example DASHSCOPE_API_KEY), never directly in source code.

Exact console labels and menu positions may differ by region, so verify the current flow in the official documentation before you rely on written screenshots.

Keep your key safe (unordered list)

  • Load the key from an environment variable or secrets manager, never commit it to source control.
  • Rotate the key immediately if it’s ever exposed in logs, a repo, or a client-side bundle.
  • Set per-key rate or spend limits where the console allows it, so a leaked key can’t run up unbounded usage.
  • Use separate keys per environment (development, staging, production) so you can revoke one without breaking the others.

Which Qwen models you can call via API

Model Studio’s catalog is organized into tiers rather than a single model. The commercial flagship text tiers are qwen-max, qwen-plus, and qwen-turbo, roughly ordered from highest reasoning capability to fastest and cheapest per token. Alongside those, Alibaba Cloud also offers long-context and multimodal variants under the qwen-vl family, plus coding-specialized models such as qwen-coder and qwen3-coder. Exact current model IDs, context window sizes, and per-token prices change often enough that the only reliable source is the live API reference — don’t treat any fixed number as permanent, and don’t trust invented model names that aren’t listed there.

Grid of Qwen model families callable via the API: qwen-max, qwen-plus, qwen-turbo, qwen-vl and qwen-coder.
The Qwen API catalog spans reasoning (qwen-max), a balanced default (qwen-plus), speed (qwen-turbo), vision and coder variants — confirm exact IDs in the official reference.

Commercial tiers (table)

Model familyBest forNote
qwen-maxHardest reasoning tasksHighest capability tier
qwen-plusBalanced defaultGood general-purpose starting point
qwen-turboHigh-volume, low-latency workloadsFastest and cheapest per call
qwen-vl-*Vision + text (multimodal)For image-input use cases
qwen-coder / qwen3-coderCode generation and reviewCoding-specialized variants

Illustrative — confirm exact model IDs, context lengths and pricing in the official API reference.

Open-weight models served the same way

Beyond the commercial tiers, Model Studio also serves open-weight checkpoints from the Qwen2.5 and Qwen3 families through the same API surface — these are the same weights available for download on Hugging Face. Matching an API model ID to its Hugging Face repository name is generally straightforward, since Alibaba Cloud keeps the naming conventions aligned, but it’s still worth cross-checking the API reference against the model card before assuming parity in defaults like context length or system-prompt handling.

Make your first request (minimal example)

The fastest way to test the Qwen API is through the OpenAI-compatible endpoint, since it lets you reuse the standard OpenAI SDK with two changes: swap base_url for Model Studio’s compatible-mode endpoint, and swap the API key for your DashScope key. The official quick-start is the canonical reference for the current endpoint value, which differs between the China and International regions — don’t hardcode one you found elsewhere without checking.

OpenAI-compatible request showing the base_url, api_key and model fields, with an SDK badge pointing at Qwen.
The OpenAI-compatible endpoint means one base_url and API-key swap points the standard OpenAI SDK straight at Qwen.

Python (OpenAI SDK) — illustrative

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="<compatible-mode endpoint>",  # verify current endpoint & model names in the official Model Studio docs
)

response = client.chat.completions.create(
    model="qwen-plus",  # verify current endpoint & model names in the official Model Studio docs
    messages=[
        {"role": "user", "content": "Explain what DashScope is in one sentence."}
    ],
)

print(response.choices[0].message.content)

curl — illustrative

# verify current endpoint & model names in the official Model Studio docs
curl -X POST "<compatible-mode endpoint>/chat/completions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "qwen-plus",
        "messages": [{"role": "user", "content": "Hello"}]
      }'

Regions & authentication

Model Studio runs across several regional endpoints — including China (Beijing) and international locations such as Singapore — and keys are tied to the region they were created in: a key issued for one region will not authenticate against another region’s endpoint. Authentication itself is uniform: a Bearer token carried in the Authorization header on every request. Always check the console for the current list of supported regions and the matching endpoint for each.

The OpenAI-compatible mode means most existing OpenAI SDK integrations need only a base_url and API key swap to call Qwen — but that base_url is region-specific and documented at alibabacloud.com/help/en/model-studio/.

Alternative: self-host Qwen with open weights

If per-token billing or data residency is a blocker, Qwen’s open-weight checkpoints are published on Hugging Face and mirrored in the QwenLM GitHub organization, with many models released under the Apache 2.0 license. Running them yourself means loading the checkpoints with Hugging Face Transformers, or serving them through an inference engine like vLLM or Ollama, both of which can expose their own OpenAI-compatible endpoint locally. The trade-off is straightforward: you give up per-token pricing and pay in GPU hardware and operations time instead, in exchange for full control over your data and infrastructure.

Comparison of using the cloud API versus self-hosting Qwen open weights with HuggingFace, vLLM and Ollama.
Cloud API vs. self-hosting: pay per token for zero ops, or run the open weights yourself with HuggingFace, vLLM or Ollama for full control.

On licensing, the Qwen team has been explicit about the open-weight models:

The open-weight Qwen3 models are released under the permissive Apache 2.0 license, which generally allows free commercial use — always confirm the exact terms on the specific model card you deploy.

Source: Qwen3 repository, github.com/QwenLM/Qwen3 and the official Qwen blog.

When to use the API vs. self-hosting (table)

FactorModel Studio APISelf-hosted open weights
SetupCreate account, generate key, call endpointProvision GPUs, install serving stack
Cost modelPay per tokenPay for hardware/cloud compute + ops time
ScalingHandled by Alibaba CloudYou manage capacity yourself
Data controlData passes through Alibaba CloudFully on your own infrastructure
HardwareNone requiredGPU(s) required for reasonable throughput
Model choiceCommercial tiers + hosted open weightsAny open-weight checkpoint you can run
Best forFast prototyping, low ops overheadData-sensitive workloads, heavy sustained usage

Quick local start (unordered list)

  • Ollama — install the runtime, then run a command such as ollama run qwen3 (illustrative — check the current model tag/name in Ollama’s library before running it).
  • vLLMpip install vllm, then vllm serve <Qwen repo id> to expose an OpenAI-compatible endpoint locally (illustrative — confirm the exact repo id on Hugging Face).
  • Transformers — load a checkpoint directly from huggingface.co/Qwen for full control over inference code.

Licensing & compliance (unordered list)

  • Most Qwen open-weight models are released under the Apache 2.0 license, which generally permits commercial use.
  • Some model variants have historically shipped under different or more restrictive terms.
  • Always read the license file on the specific model card you intend to deploy — don’t assume Apache 2.0 applies uniformly across every Qwen release.

FAQ

keyboard_arrow_up