快速开始
API 通过 HTTPS 使用标准 JSON。创建密钥、提交生成任务,然后轮询返回的任务 ID。
- 01
创建 Bearer 密钥
- 02
提交生成请求
- 03
轮询任务 ID
基础 URL
所有公开 API 请求都使用 qwenapi.org 域名。
https://qwenapi.org身份验证
每个生成、状态和历史请求都需要在 Authorization 请求头中发送 Qwen API 密钥。
Authorization: Bearer $QWEN_API_KEY
请将 API 密钥保存在服务端,不要暴露在浏览器包、公开仓库或客户端日志中。
生成图片
提交已支持的在线模型 ID 及其对应输入字段。
curl https://qwenapi.org/api/v1/images/generations \
-H "Authorization: Bearer $QWEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-3",
"prompt": "Editorial product photo in soft morning light",
"aspect_ratio": "16:9",
"resolution": "1K"
}'受理响应
{
"code": 200,
"message": "success",
"data": {
"task_id": "n86...qw3",
"status": "IN_PROGRESS"
}
}查询任务状态
使用返回的任务 ID 获取进度、错误和最终输出 URL。
curl "https://qwenapi.org/api/v1/tasks/$TASK_ID" \ -H "Authorization: Bearer $QWEN_API_KEY"
IN_PROGRESS
后端已受理任务并正在处理。
SUCCESS
输出 URL 已可获取。
FAILED
任务已停止并返回结构化错误。
已上线模型 ID
只有以下模型 ID 当前会路由到已接入计费的生产服务。
| 模型 | 成本 | 输入 | 输出 |
|---|---|---|---|
| qwen-image-3 | 10 credits / image | Text, up to 3 images | PNG or JPEG |
| qwen2-image | 10 credits / image | Text or image | PNG or JPEG |
| qwen-image-2512 | 5 credits / image | Text or images | PNG, JPEG, WebP |
| qwen-multi-angles | 5 credits / image | 1-3 images | PNG or JPEG |
| qwen-layered | 10 credits / layer | Image and instruction | Layer images |
错误处理
HTTP 状态码会配套结构化 JSON 错误。联系支持时请保留任务 ID 和错误信息。
400invalid_request检查模型 ID 和请求字段。401unauthorized确认 Bearer 密钥存在且有效。402insufficient_credits在计费控制台补充积分。404not_found确认任务 ID 属于 Qwen 路由。429rate_limited退避后加入随机抖动重试。500server_error稍后重试,并保留任务 ID 以便支持排查。