POST

Authorizations

Authorization
string
header
required

在请求头中传入:Authorization: Bearer sk-...

Body

application/json

OpenAI Images 兼容的图片生成请求。新接入优先提交到 /v1/images/generations/jobs 创建异步任务;短耗时或兼容旧客户端时也可提交到 /v1/images/generations。gpt-image-2、gpt-image-2-2K 和 gpt-image-2-4K 均支持同步与异步生成;同步请求会在服务内部等待异步任务完成。边聊边出图或图片理解场景通常使用 /v1/chat/completions。

model
string
required

图片模型 ID。gpt-image-2、gpt-image-2-2K 和 gpt-image-2-4K 均支持同步与异步生成。不同模型的尺寸、质量、格式和参考图规则以模型页说明为准。

Example:

"qwen-image"

prompt
string
required

图片生成描述。说明主体、画面环境、风格、构图、文字要求和需要避开的内容;使用参考图时,同时说明每张参考图的用途。

Example:

"一张干净的产品海报,白色背景,柔和光线"

n
integer

生成图片数量。常见范围为 1 到 10,具体上限由模型决定。多张图片会按数量计费。

Required range: x >= 1
Example:

1

size
string

图片尺寸。常见值包括 auto、1024x1024、1536x1024、1024x1536、2048x2048、2048x1152、2160x3840。gpt-image-2-2K 与 gpt-image-2-4K 的 size 必须为 WIDTHxHEIGHT,宽高均为正数且是 16 的倍数,最长边不超过 3840px,宽高比不超过 3:1,总像素范围为 655,360 至 8,294,400;最大横图为 3840x2160,最大竖图为 2160x3840,最大方图为 2880x2880。其他模型以模型说明为准。

Example:

"1024x1024"

quality
string

生成质量。常见值:auto、standard、hd、high、medium、low。高清或高档位通常耗时更长,价格也可能不同。

Example:

"auto"

style
string

风格字段。豆包图片 常见值为 vivid、natural;其他模型可能忽略该字段。

Example:

"vivid"

response_format
enum<string>

返回图片格式。url 表示返回图片地址,b64_json 表示返回 base64。部分新模型固定返回某一种格式,会忽略该字段。

Available options:
url,
b64_json
image

参考图 URL。可传单个公网图片地址或 URL 数组。gpt-image-2-2K 与 gpt-image-2-4K 最多支持 8 张参考图,传入 9 张或更多会失败。需要用网络 URL 做参考图创作、换装、合成或改图时,推荐使用 /v1/images/generations/jobs 的 image 数组,例如 qwen-image-edit 的 OSS/CDN 图片模式。

Example:
background
string

背景模式。透明背景模型会读取该字段,常见值为 transparent、opaque、auto。透明 PNG 搭配 png 输出格式使用。

Example:

"transparent"

moderation
string

内容审核强度。常见值为 auto、low,是否生效以模型说明为准。

Example:

"auto"

output_format
string

输出图片格式,例如 png、jpeg、webp。不同模型可能使用 output_format 或 format 字段。

Example:

"png"

format
string

图片格式字段,常见值为 png、jpeg、webp。

Example:

"png"

output_compression
integer

输出压缩质量,范围 0 到 100。jpeg 或 webp 输出会读取该字段;png 输出一般忽略。

Required range: 0 <= x <= 100
Example:

80

partial_images
integer

流式或渐进生成时返回的阶段图片数量。只有阶段图模型会读取该字段。

Example:

1

watermark
boolean

是否添加水印。只有水印模型会读取该字段。

Example:

false

user
string

终端用户标识,供审计、风控或请求追踪使用。

Example:

"user-123"

negative_prompt
string

部分图片模型会读取反向提示词,作为模型扩展参数提交。

Example:

"低清晰度、畸形文字"

aspect_ratio
string

部分图片模型会读取比例参数,作为模型扩展参数提交。使用 Chat Completions 时,也兼容 Chat 请求顶层 aspect_ratio。

Example:

"16:9"

image_size
string

部分模型使用 image_size 而不是 size,作为模型扩展参数提交。使用 Chat Completions 时,也兼容 Chat 请求顶层 image_size 或 resolution。

Example:

"1024x1024"

seed
integer

部分模型会读取固定随机种子,作为模型扩展参数提交。

Example:

12345

Response

任务已创建

id
string
required
Example:

"imgtask-..."

object
string
required
Example:

"image.edit.job"

status
enum<string>
required
Available options:
queued,
running,
succeeded,
failed
created
integer
required

Unix 秒级时间戳。

updated
integer
required

Unix 秒级时间戳。

model
string
started_at
integer | null
completed_at
integer | null
reference_urls
string<uri>[]
data
object[]

任务成功后返回图片结果,结构与 Images 响应 data 数组一致。

error
object | null