搜索

搜索 HiAPI 模型、工具和资源。

返回博客
教程5 分钟阅读

Qwen Image 3.0 Pro API 接入:curl、Python 和全部参数

文生图和图生图两个入口,1K $0.0497、2K $0.0993,现行参数、旧模型名报错怎么改、写字时的设置。

HiAPI 编辑部Qwen Image 3.0API 教程图片生成

Qwen Image 3.0 Pro(通义千问图像 3.0 Pro)在 HiAPI 上有两个入口:文生图 qwen-image-3.0-pro/text-to-image 和图生图 qwen-image-3.0-pro/image-to-image。它比标准版贵,换来更丰富的细节和材质,中英文字照样写得准。这篇给出能直接跑的 curl 和 Python 示例、现在的全部参数,以及上线前要注意的几件事。

早期的模型名 qwen-image-3.0-pro 和 size 字段已经不能用了:旧模型名会返回 MODEL_UNAVAILABLE,size 会被当成未知字段拒绝。请用上面两个模型名,配合 aspect_ratio 和 resolution。

先看价格

1K(默认)2K
Pro 文生图 / 图生图$0.0497$0.0993
标准版文生图 / 图生图(对照)$0.0358$0.0358

HiAPI 现价,2026 年 10 月 18 日核对。

Pro 1K 比标准版贵约 39%,2K 是标准版的约 2.8 倍。图生图的 1–3 张参考图不加钱。失败不扣费。

一张真实出图

16:9。桌上铜牌的「深海来信」和下面一行小字「LETTERS FROM THE DEEP」都逐字写对了:

High-end cinematic architectural editorial photograph inside a futuristic underwater restaurant at midnight. A vast curved observation window fills the background with deep cobalt water and luminous translucent jellyfish drifting outside. On the right, a sculptural dining table of black stone, hand-blown glass and restrained brushed brass catches a narrow beam of warm light. A small refined brass menu plaque on the table is naturally photographed and contains only the exact Chinese characters “深海来信”; directly below, the exact English words “LETTERS FROM THE DEEP”. The left third remains calm dark-blue negative space with volumetric light rays. No poster layout; this must feel like an expensive real location photographed for an architecture magazine. cinematic composition, dramatic directional lighting, rich cohesive cobalt-and-gold color grade, ultra-detailed, premium commercial finish, subtle film grain, shallow depth of field, high dynamic range, 16:9 hero composition

Qwen Image 3.0 Pro:深夜的海底餐厅,弧形观景窗外漂着水母,桌上铜牌写着「深海来信」和 LETTERS FROM THE DEEP

用这条提示词生成 →

qwen-image-3.0-pro/text-to-image,16:9,模型页示例图。

跑通第一张

准备:在 控制台 创建 API Key。新用户注册送 200 积分。

curl

curl -s -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer $HIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro/text-to-image",
    "input": {
      "prompt": "一只青瓷茶壶放在胡桃木桌上,清晨的侧光,茶壶旁的小卡片上写着「雨前龙井」",
      "aspect_ratio": "4:3",
      "resolution": "1K",
      "prompt_extend": false
    }
  }'

返回 taskId 后查结果:

curl -s https://api.hiapi.ai/v1/tasks/tk-hiapi-... \
  -H "Authorization: Bearer $HIAPI_KEY"

data.status 为 success 时,图片在 data.output[0].url。这是临时链接,拿到就下载转存。

Python

import os, time, requests

KEY = os.environ["HIAPI_KEY"]
BASE = "https://api.hiapi.ai/v1"
H = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}

r = requests.post(f"{BASE}/tasks", headers=H, json={
    "model": "qwen-image-3.0-pro/text-to-image",
    "input": {
        "prompt": "一只青瓷茶壶放在胡桃木桌上,清晨的侧光,茶壶旁的小卡片上写着「雨前龙井」",
        "aspect_ratio": "4:3",
        "resolution": "1K",
        "prompt_extend": False,
    },
})
task_id = r.json()["data"]["taskId"]

while True:
    d = requests.get(f"{BASE}/tasks/{task_id}", headers=H).json()["data"]
    if d["status"] in ("success", "fail"):
        break
    time.sleep(5)

if d["status"] == "success":
    open("result.png", "wb").write(requests.get(d["output"][0]["url"]).content)
else:
    print(d)

全部参数

字段必填取值说明
prompt是最长 18000 字符画面内容、风格、构图;要出现的字用引号写进来
image_urls图生图必填1–3 张JPEG/PNG/WEBP/BMP/GIF/TIFF,单张 ≤10MB,不支持 SVG
aspect_ratio否1:1(默认)、3:2、2:3、4:3、3:4、16:9、9:16、21:9
resolution否1K(默认)/ 2K决定价格
output_format否png(默认)/ jpeg
prompt_extend否布尔,默认 true自动改写提示词;要求文字一字不差时设为 false
negative_prompt否最长 500 字符不想出现的内容
seed否0–2147483647固定后便于复现

图生图示例:

{
  "model": "qwen-image-3.0-pro/image-to-image",
  "input": {
    "prompt": "把这张产品图修成高端杂志风格,保留瓶身形状和标签上的文字",
    "image_urls": ["https://example.com/product.jpg"],
    "aspect_ratio": "1:1",
    "resolution": "2K",
    "prompt_extend": false
  }
}

常见报错

都是提交时同步返回 HTTP 400,不建任务、不扣费:

  • MODEL_UNAVAILABLE:用了旧模型名 qwen-image-3.0-pro,改成带 /text-to-image 或 /image-to-image 的名字。
  • additional properties 'size' not allowed:size 已经不收了,用 aspect_ratio 加 resolution。
  • resolution: value must be one of '1K', '2K':Pro 没有 4K。
  • image_urls: minItems: got 0, want 1:图生图至少传 1 张参考图。

上线前注意

  • 写字时关掉 prompt_extend:自动改写可能改动你要的字。
  • 用回调代替轮询:请求体顶层加 "callback": {"url": "https://你的域名/hiapi/callback", "when": "final"},按 taskId 去重。
  • 防重复扣费:提交时带 Idempotency-Key 请求头,超时重试用同一个 key。
  • 及时转存:输出链接会过期。

常见问题

Pro 和标准版怎么选?

先用标准版试,$0.0358 一张,1K 和 2K 同价。标准版细节不够时再换 Pro。标准版接入见 Qwen Image 3.0 API 接入。

能出 4K 吗?

不能,只有 1K 和 2K。

参考图最多几张?

3 张,不加钱。

也可以直接复制上面的海底餐厅提示词,去模型页生成。

现在就用 HiAPI 生成

选一个模型,输入你的提示词,直接查看生成结果。

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成