Qwen图片生成

OpenAI 兼容:POST /v1/images/generations。原生路径:/api/v1/services/aigc/multimodal-generation/generation。图片生成 API

模型 ID 以平台「开放模型列表」为准。OpenAI 兼容路径请用 prompt + image / image_urls;不支持 messages、style、quality。


1. OpenAI 兼容接入 (POST)

  • 路径: https://www.tokenpad.ai/v1/images/generations
  • 鉴权: Authorization: Bearer sk-your_token

A. 文生图

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "赛博朋克城市夜景,霓虹倒影,超清写实,电影级构图",
    "size": "1024*1024",
    "n": 1,
    "response_format": "url"
  }'

B. 单图参考 / 图生图

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "参考图中人物,站在图书馆窗边远眺,电影感自然光",
    "image": "https://example.com/assets/character_face.jpg",
    "size": "1024*1024",
    "n": 1
  }'

C. 多图参考生图

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "参考图一角色外形与图二场景氛围,统一插画风格,暖色自然光",
    "image_urls": [
      "https://example.com/character.png",
      "https://example.com/scene.png"
    ],
    "size": "1280*720",
    "n": 2
  }'

D. 负向提示词

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "赛博朋克城市夜景,霓虹倒影,超清写实",
    "negative_prompt": "模糊,低画质,变形,水印",
    "size": "1024*1024",
    "n": 1
  }'

2. OpenAI 兼容参数字典

参数类型必填说明
modelstring是如 qwen-image-3.0-pro
promptstring是画面描述
negative_promptstring否负向提示词
imagestring / array否参考图 URL;单张字符串或 URL 数组
image_urlsarray否多图参考 URL 数组(与 image 数组等价,任选其一)
sizestring否如 1024*1024、1280*720;1024x1024 自动转为 *
ninteger否生成张数,默认 1
response_formatstring否"url" 或 "b64_json"

3. 阿里百炼原生路由(简要)

能力路径
图像提交POST /api/v1/services/aigc/multimodal-generation/generation
异步查询GET /api/v1/tasks/{task_id}

已含官方 input / parameters 结构时可原样透传;异步任务需头 X-DashScope-Async: enable。


4. 返回示例 (200 OK)

{
  "created": 1719441600,
  "data": [
    { "url": "https://example.com/output/qwen_img_1.png" },
    { "url": "https://example.com/output/qwen_img_2.png" }
  ]
}

5. 常见错误码与问题排查

HTTP 状态码、错误体格式及分场景排查已 统一维护 于专页,避免与各调用示例重复不同步。

👉 网关常见错误码与排查

速记(详情见专页):

码含义
400参数非法 / 内容风控或版权拦截
402账户余额不足(不是 429)
429令牌 RPS/RPM 限频,或低余额在途任务过多
403令牌/IP/模型权限(余额见 402;内容拦截见 400)
200 + status: failed异步视频等长任务的业务失败(轮询时常见)

HTTP 响应码与控制台调用日志 status_code 一致,可按 log_id 追溯。

维护约定:新增或调整错误说明时,请只更新专页 error-codes;本附录通过链接自动指向最新内容。

Raw Markdown (.md) · llms.txt