messages 结构,适合把文字和图片一起发给模型。{ "type": "text", "text": "..." }。{ "type": "image_url", "image_url": { "url": "https://..." } }。url 可以是公网图片 URL,也可以是 base64 data URI。/v1/images/generations,请求体更简单。Authorization: Bearer ********************{
"model": "gpt-image-2",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "请描述这张图里的主体、背景和整体风格。"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/photo.jpg"
}
}
]
}
]
}curl --location '/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "请描述这张图里的主体、背景和整体风格。"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/photo.jpg"
}
}
]
}
]
}'{
"id": "chatcmpl_xxx",
"object": "chat.completion",
"created": 1776768940,
"model": "gpt-image-2",
"choices": [
{
"index": 0,
"message": {
"role": "system",
"content": "string",
"property1": "string",
"property2": "string"
},
"finish_reason": "string"
}
],
"property1": "string",
"property2": "string"
}