Your First API Call

Go from account creation to a working API response in under five minutes.

Your First API Call

1. Create an Account

Sign up at qwenapi.com. No credit card required to start — you get 1M free tokens per model for 90 days on the International region.

2. Get Your API Key

After signing in, go to Dashboard → API Keys → Create Key. Copy the key and store it somewhere safe — it won't be shown again.

Set it as an environment variable:

``bash

export QWENAPI_KEY="sk-..."

`

3. Install the SDK

QwenAPI uses the standard OpenAI SDK. No custom package needed.

`bash

Python

pip install openai

Node.js

npm install openai

`

4. Make Your First Request

Python

`python

import os

from openai import OpenAI

client = OpenAI(

api_key=os.environ["QWENAPI_KEY"],

base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",

)

response = client.chat.completions.create(

model="qwen3.5-flash",

messages=[{"role": "user", "content": "What is the capital of France?"}],

)

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

`

Node.js

`javascript

import OpenAI from "openai";

const client = new OpenAI({

apiKey: process.env.QWENAPI_KEY,

baseURL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",

});

const response = await client.chat.completions.create({

model: "qwen3.5-flash",

messages: [{ role: "user", content: "What is the capital of France?" }],

});

console.log(response.choices[0].message.content);

`

cURL

`bash

curl https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions \

-H "Authorization: Bearer $QWENAPI_KEY" \

-H "Content-Type: application/json" \

-d '{

"model": "qwen3.5-flash",

"messages": [{"role": "user", "content": "What is the capital of France?"}]

}'

`

5. Check Your Usage

Token usage is in every response under response.usage:

`python

print(response.usage.prompt_tokens) # input tokens

print(response.usage.completion_tokens) # output tokens

`

Troubleshooting

ErrorLikely cause
401 UnauthorizedInvalid or missing API key
404 Not FoundWrong base_url or model name
429 Too Many RequestsRate limit hit — back off and retry
503 Service Unavailable`Temporary upstream issue — retry with exponential backoff

Next Steps

  • Choose a model — find the right model for your workload
  • Regions — switch to a US or EU endpoint for lower latency