Amux
图像Qwen 格式(OpenAI)

生成图像

通过 OpenAI 兼容格式调用阿里百炼 Qwen / Wan 系列图像模型生成图像

通过标准的 OpenAI Images Generations 端点调用阿里百炼(DashScope)的 Qwen 图像系列Wan 系列模型。amux-api 在网关层会根据 model 自动路由到 Ali 适配器,并在内部把请求转换为百炼原生 DashScope 格式。

项目
请求方法POST
请求路径/v1/images/generations
完整 URLhttps://api.amux.ai/v1/images/generations
认证方式Authorization: Bearer <API_TOKEN>
请求格式application/json
响应格式application/json

本接口与 OpenAI 格式 / 生成图像 共用同一端点,仅 model 字段不同。请求体的标准字段(prompt / n / size / response_format 等)请参考该文档;本页聚焦 Qwen 专属的扩展行为与参数。

支持的模型

amux-api 内置以下百炼图像模型:

模型类型模式
qwen-imageQwen 文生图同步
z-imageZ 系列文生图同步
wan2.6万相 V2.6同步
wan2.7万相 V2.7同步
wan2.2-t2v-plus万相早期版本异步(含轮询)
wanx-*万相 X 系列异步

完整可用模型与计费请见 https://api.amux.ai/pricing

同步 vs 异步:amux-api 在网关层屏蔽了百炼同步 / 异步任务的差异。

  • 同步模型qwen-image / z-image / wan2.6 / wan2.7):调用方等单次 HTTP 响应即可拿到生图结果
  • 异步模型(旧 wan / wanx 系列):amux-api 自动向 DashScope 发起异步任务并轮询状态,最终把结果以 OpenAI 格式同步返回给调用方

请求体参数

标准 OpenAI 字段

完全沿用 OpenAI Images Generations 标准字段:

Prop

Type

Qwen / Wan 专属参数

amux-api 提供两种方式访问百炼专属参数:

方式 1:扁平字段(部分参数)

watermark 等已建模字段直接放在请求体顶层:

{
  "model": "qwen-image",
  "prompt": "...",
  "watermark": true
}

方式 2:嵌套 parameters 字段(推荐,访问完整 DashScope 参数集)

通过顶层 parameters 对象传入百炼 DashScope 原生 parameters 字段,amux-api 会原样合并到上游请求中:

Prop

Type

方式 3:嵌套 input 字段(高级)

调用方也可显式传入 input 对象,覆盖 amux-api 默认从 prompt 自动构建的 input.messages / input.prompt 结构:

Prop

Type

transform 透明性:当调用方仅使用 OpenAI 标准字段时,amux-api 会按以下规则自动构造百炼请求:

  • 同步模型:input.messages = [{ role: "user", content: [{ text: prompt }] }]
  • 异步模型:input.prompt = prompt
  • parameters.size = request.size 中的 x 替换为 *(如 1024*1024
  • parameters.n = request.n(默认 1)
  • parameters.watermark = request.watermark

如果显式提供了 parametersinput,则以传入值为准。

请求示例

基础用法(OpenAI 标准格式)

curl https://api.amux.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AMUX_API_KEY" \
  -d '{
    "model": "qwen-image",
    "prompt": "一只戴着贝雷帽的可爱海獭幼崽,水彩风格",
    "n": 1,
    "size": "1024x1024"
  }'
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.amux.ai/v1",
    api_key=os.environ["AMUX_API_KEY"],
)

response = client.images.generate(
    model="qwen-image",
    prompt="一只戴着贝雷帽的可爱海獭幼崽,水彩风格",
    n=1,
    size="1024x1024",
)

print(response.data[0].url)
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.amux.ai/v1',
  apiKey: process.env.AMUX_API_KEY,
});

const response = await client.images.generate({
  model: 'qwen-image',
  prompt: '一只戴着贝雷帽的可爱海獭幼崽,水彩风格',
  n: 1,
  size: '1024x1024',
});

console.log(response.data![0].url);

进阶用法(透传 DashScope parameters

curl https://api.amux.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AMUX_API_KEY" \
  -d '{
    "model": "z-image",
    "prompt": "一只戴着贝雷帽的可爱海獭幼崽,水彩风格",
    "parameters": {
      "size": "1024*1024",
      "n": 1,
      "prompt_extend": true,
      "seed": 42,
      "watermark": false
    }
  }'

使用反向提示词

curl https://api.amux.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AMUX_API_KEY" \
  -d '{
    "model": "qwen-image",
    "prompt": "一只可爱的海獭幼崽",
    "input": {
      "prompt": "一只可爱的海獭幼崽",
      "negative_prompt": "低质量, 模糊, 卡通风格"
    },
    "parameters": {
      "size": "1024*1024"
    }
  }'

响应示例

amux-api 始终以 OpenAI 标准 ImageResponse 格式返回,与 OpenAI 生成图像 一致:

{
  "created": 1730000000,
  "data": [
    {
      "url": "https://dashscope-result-xxx.oss-cn-beijing.aliyuncs.com/.../result.png",
      "revised_prompt": "..."
    }
  ]
}

response_format=b64_json 时返回 b64_json 字段;url 字段由百炼 OSS 临时签发,使用前请尽快下载或转为 Base64 长期保存。

错误响应

错误结构与 OpenAI 生成图像 一致:

{
  "error": {
    "message": "...",
    "type": "invalid_request_error",
    "code": "invalid_value"
  }
}

常见错误:

错误原因
convert image request to async ali image request failed: invalid parameters fieldparameters 字段 JSON 格式不合法
invalid input fieldinput 字段 JSON 格式不合法
unsupported image relay mode模型在 amux 中标识为非图像生成模型
异步任务超时异步模型轮询超过最大次数(amux 内部上限),多由上游模型负载引起

HTTP 状态码沿用 OpenAI 体系。

On this page