Qwen API Documentation
Buy credits, generate a key, and call Qwen through a simple endpoint. If you've used the OpenAI API before, you already know this one.
qwenapi.io is an independent proxy and reseller for Qwen. Endpoints below point at our proxy; responses originate from Qwen models.
Introduction
The Qwen API exposes a REST interface modeled on the OpenAI specification. You authenticate with a bearer token and receive standard JSON responses, so the official OpenAI SDKs and most HTTP clients work with minimal changes.
Base URL
Authentication
The API uses bearer token authentication. Create a key from your dashboard after topping up credits, then pass it on every request:
# HTTP headers
Authorization: Bearer sk-qwen-your-key
Content-Type: application/jsonKeep keys secret. Treat API keys like passwords — never embed them in client-side code or commit them to a repository. Rotate or revoke a leaked key instantly from your dashboard.
Quickstart
Python
from openai import OpenAI
client = OpenAI(api_key="sk-qwen-your-key", base_url="https://api.qwenapi.io/v1")
resp = client.chat.completions.create(
model="qwen-max",
messages=[{"role": "user", "content": "Explain RAG in one sentence."}],
)
print(resp.choices[0].message.content)cURL
curl https://api.qwenapi.io/v1/chat/completions \
-H "Authorization: Bearer sk-qwen-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "qwen-max", "messages": [{"role":"user","content":"Hello!"}]}'Chat completions
Creates a model response for a conversation. Core parameters:
model—qwen-maxorqwen-plus. Required.messages— array of{ role, content }objects. Required.temperature,max_tokens,stream— optional.
Streaming
Set stream: true to receive tokens as server-sent events, terminated by data: [DONE] — identical to the OpenAI streaming format.
Models
| Model ID | Name |
|---|---|
| qwen-max | Qwen-Max |
| qwen-plus | Qwen-Plus |
Errors
Conventional HTTP status codes are used, with an OpenAI-style error body: { "error": { "message", "type", "code" } }.
| Code | Meaning |
|---|---|
| 400 | Malformed request |
| 401 | Invalid or missing API key |
| 402 | Insufficient credits — top up your balance |
| 429 | Rate limit exceeded |
| 500 / 503 | Upstream or proxy error — retry with backoff |
Rate limits
Rate limits scale with your plan and balance. When you exceed a limit you'll receive a 429 with a Retry-After header — back off and retry. Need a custom limit? Contact us.
Ready to build? Get your API key and make your first call in minutes.