Skip to content
中文

Chat (Edit Image)

Method: POSTEndpoint: /v1/chat/completions

Official GuideOfficial API Documentation All chat models can use this interface. Change the model field to the target model name. Requires a model with image-generation support.

Request Parameters

Header Parameters

text
Content-Type
string
Required
Example:
application/json
Accept
string
Required
Example:
application/json
Authorization
string
Optional
Default Value:
Bearer {{YOUR_API_KEY}}

Body Parameters application/json

text
model
enum<string>
Required
The ID of the model to use. For details about which models support the Chat API, see
the model endpoint compatibility table.
Enum Values:
gpt-image-1
gpt-4o-image
sora_image
flux-kontext-pro
  // provider-specific example normalized for English documentation
nano-banana
doubao-seedream-4-0-250828
doubao-seededit-3-0-i2i-250628
nano-banana-hd
qwen-image-edit
messages
array
[object]
Required
in
the chat format
to generate a chat completion message.
role
string
Optional
content
string
Optional
stream
boolean
Optional
If set, partial message deltas are streamed just like in ChatGPT. Tokens are sent as data-only
server-sent events
data: [DONE]
events as they become available, and the stream is terminated by a final message.
For sample code
, see the OpenAI Cookbook.
Example
{
"model"
:
"gpt-4o-image"
,
"stream"
:
false
,
"messages"
:
[
{
"role"
:
"user"
,
"content"
:
[
{
"type"
:
"text"
,
"text"
:
  // provider-specific example normalized for English documentation
}
,
{
"type"
:
"image_url"
,
"image_url"
:
{
"url"
:
"https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
}
}
,
{
"type"
:
"image_url"
,
"image_url"
:
{
"url"
:
"Supports multiple images"
}
}
]
}
]
}

Example Request

Shell

bash
curl --location --request POST '/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gpt-4o-image",
    "stream": false,
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
  // provider-specific example normalized for English documentation
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
                    }
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "Supports multiple images"
                    }
                }
            ]
        }
    ]
}'

Response

🟢 200 OK

Content Type: application/json

Response Schema

text
id
string
Required
object
string
Required
created
integer
Required
choices
array
[object]
Required
index
integer
Optional
message
object
Optional
finish_reason
string
Optional
usage
object
Required
prompt_tokens
integer
Required
completion_tokens
integer
Required
total_tokens
integer
Required

Example

json
{
    "id": "chatcmpl-123",
    "object": "chat.completion",
    "created": 1677652288,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n\nHello there, how may I assist you today?"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 12,
        "total_tokens": 21
    }
}