使用 gpt-image-2 生成图片,支持异步任务和 JSON 参考图。
gpt-image-2 从文本生成图片。也可以通过 image_urls 携带参考图,实现图生图或风格迁移。
?async=true。同步模式会等待图片完成后才返回,容易受到调用方超时影响。task_id 后,请调用 Retrieve image task 查询结果。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | string | gpt-image-2 | 模型名称。 |
prompt | string | 必填 | 生图或编辑提示词。 |
n | integer | 1 | 当前建议按 1 设计。接口会把过小或过大的值归一到支持范围。 |
size | string | 1024x1024 | 支持比例如 1:1、16:9,也支持像素如 3840x2160。 |
resolution | string | 空 | 推荐清晰度字段:1k、2k、4k。 |
output_format | string | 空 | 输出格式建议使用 png、jpeg 或 webp。 |
output_compression | integer | 空 | 输出压缩质量,通常配合 jpeg 或 webp。 |
background | string | 空 | 背景偏好,如 auto、transparent、opaque。 |
moderation | string | 空 | 内容审核强度,如 auto、low。 |
user | string | 空 | 调用方用户标识,便于审计。 |
wait_for_result | boolean | true | 传 false 可进入异步提交。 |
image_urls | string / array / object | 空 | JSON 参考图字段,最多 4 张。 |
?async=true?wait_for_result=falsePrefer: respond-async"wait_for_result": falseimage_urls:
reference_images、images、image、image_url、input_image 和 input_images。
blob: URL 不能直接传入,请先上传到你的服务端或转成 data URL。Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Set to true to submit an async image task.
Set to false to submit an async image task.
Set to apimart for APIMart-compatible response shape.
apimart 1 <= x <= 4"1:1"
"16:9"
"3840x2160"
1k, 2k, 4k "png"
"jpeg"
"webp"
"auto"
"transparent"
"opaque"
"auto"
"low"