生成图像
根据文字描述生成图像。
/model/v1/images/generations● 支持请求体
modelstring必填Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.
已验证生效。
response_formatstring可选◐ 部分支持Image response encoding. Only b64_json is accepted; url returns 400.
gpt-image-2 支持 b64_json;url 返回 400。
promptstring必填Text description of the image to generate. Router support (supported): Verified to take effect.
已验证生效。
ninteger可选Number of images to generate, from 1 to 10; defaults to 1. Router support (supported): Controls image count; zero returns 400 and values 1–10 are accepted.
控制图片数量,0 返回 400,允许 1–10。
sizestring可选◐ 部分支持Size of the generated images. Router support (partial): gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.
gpt-image-2 已验证 1024x1024、1024x1536;512x512 返回 400。
qualitystring可选Quality of the generated images. Router support (supported): Verified to take effect.
已验证生效。
backgroundstring可选gpt-image-2 的 transparent 返回透明 PNG。
output_formatstring可选gpt-image-2 的 jpeg 返回 JPEG。
返回
200
鉴权、限流、参数校验等平台错误按 problem+json 返回;OCR 的错误也为 problem+json,其它模型调用的错误按该端点所属格式(OpenAI 或 Anthropic)返回,参见 错误码
响应
HTTP 200
Image generation response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| created | integer | Unix time in seconds at which the images were created. |
| data | array<object> | Generated images. |
| data[].url | string | URL of the image; present when response_format is `url`. |
| data[].b64_json | string | Base64-encoded image; present when response_format is `b64_json`. |
| data[].revised_prompt | string | Prompt after the image model rewrote it, when the model reports it. |