Skip to main content
Getting Started

First API call

Get started in a few minutes

Set up your account and make your first API call to Qwen models.

Prerequisites

1

Create an account

Go to Qwen Cloud and sign in with GitHub or email.
2

Get your API key

Navigate to API Keys, click Add API Key, and copy your key (starts with sk-). Detailed guide →
Keep your API key secret! Never commit it to version control or share it publicly.
3

Set your environment variable

Store your API key so your code can access it:
export DASHSCOPE_API_KEY="sk-your-api-key-here"
For permanent setup across sessions, see Configure your API key →.

Make your first call

  • Python
  • Node.js
  • curl
Install the OpenAI SDK:
pip install openai
Create a file hello_qwen.py:
import os
from openai import OpenAI

client = OpenAI(
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
  model="qwen3.6-plus",
  messages=[
    {"role": "user", "content": "Hello! Tell me a fun fact about AI."}
  ]
)

print(completion.choices[0].message.content)
Run it:
python hello_qwen.py
For Java, Go, PHP, C#, and other languages, use the OpenAI-compatible endpoint shown in the curl tab with your language's HTTP client. For Java, you can also use the DashScope Java SDK.

What's next?