gpt-4o-image
模型来生成高质量的图像。/v1/chat/completions
接口。您无需调用新的接口,只需在请求中指定模型为 gpt-4o-image
,即可将对话内容作为图像描述(Prompt)来生成图片。/v1/chat/completions
POST
Bearer Token
Authorization
字段。Authorization: Bearer YOUR_API_KEY
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
model | string | 是 | 必须指定为 gpt-4o-image 。这是调用图像生成的关键。 |
messages | array | 是 | 对话消息列表。通常只包含一条 user 角色的消息。 |
messages[].role | string | 是 | 消息发送者的角色,应为 user 。 |
messages[].content | string | 是 | 图像的详细描述(Prompt),例如 "一只可爱的猫咪,戴着宇航员头盔,漂浮在宇宙中,背景是璀璨的星河"。 |
n | integer | 否 | 希望生成的图像数量。默认为 1 。 |
size | string | 否 | 生成图像的尺寸。支持 1024x1024 , 1024x1792 , 1792x1024 。默认为 1024x1024 。 |
quality | string | 否 | 图像质量。standard 为标准质量,hd 为高清质量。默认为 standard 。 |
style | string | 否 | 图像风格。vivid (生动)使图像更具戏剧性,natural (自然)则更逼真。默认为 vivid 。 |
stream | boolean | 否 | 是否使用流式传输。对于图像生成,通常建议设置为 false 。 |
user | string | 否 | 代表最终用户的唯一标识符,用于监控和防止滥用。 |
{
"model": "gpt-4o-image",
"messages": [
{
"role": "user",
"content": "一只可爱的英国短毛猫,穿着西装,坐在咖啡馆里看报纸,窗外是下雨的街道,油画风格。"
}
],
"n": 1,
"size": "1024x1024",
"quality": "hd"
}
参数 | 类型 | 描述 |
---|---|---|
created | integer | 任务创建时的 Unix 时间戳。 |
data | array | 包含生成结果的数组。 |
data[].url | string | 生成的图像 URL。此链接在一段时间后会失效,请及时下载和保存。 |
data[].revised_prompt | string | 系统为了更好的效果而优化的提示词。 |
{
"created": 1725000000,
"data": [
{
"revised_prompt": "An adorable British Shorthair cat, dressed in a sharp suit, is sitting in a cozy cafe, engrossed in a newspaper. Rain streaks down the windowpane, revealing a glistening, wet street outside. The entire scene is rendered in a rich oil painting style.",
"url": "https://oaidalleapiprodscus.blob.core.windows.net/private/..."
}
]
}