# GPT Image — Chat Format

Generate and edit images with gpt-image-2.6-flare-c through Chat Completions, with JSON or result-only SSE.

- Source: https://www.unifyllm.com/docs/api-reference/gpt-image-chat/
- Language: en
- Updated: 2026-11-30

## Endpoint

```http
POST https://api.unifyllm.top/v1/chat/completions
```

Use the authentication and headers shown in the request examples. Content-Type: application/json

## Current models and endpoints

Checked against the model square on 2026-11-30. Examples use gpt-image-2.6-flare-c; gpt-image-2.6-sunburst-c is also available. Use the complete public model name.

- Use https://api.unifyllm.top without channel prefixes.

- Use generations for text-to-image and edits for reference editing; Chat fits existing chat clients.

- Check the model square and key access for gpt-image-2-c and gpt-image-2-4k-c.

## Sizes, output, and references

- Images returns created, model, and data[].url, without b64_json or raw upstream usage. One output image per request.

- n=1, quality=high, and response_format=url are fixed; other controls such as mask are not guaranteed.

- Requested pixels do not prove native detail. The reference project tested 1024x1024 → 1254×1254 and 3840x2160 → 3840×2160 on 2026-11-30. Check actual public-route results.

| Item | Rule |
| --- | --- |
| size | auto or WIDTHxHEIGHT; multiples of 16, longest edge 3840, ratio up to 3:1 |
| Total pixels | 655,360–8,294,400 |
| References | Standard models: JSON or multipart, up to 10 references |
| Legacy 4K edit alias | gpt-image-2-4k-c edits require multipart file upload |

## Chat and streaming

- Include the prompt and references in the current user message, including the previous result when editing it.

- stream=false puts Markdown image links in choices[0].message.content; stream=true emits content after success and ends with stop and [DONE].

- The compatibility layer adds parameter summaries and completion text; 100% is not live progress.

- GPT-image Chat usage is estimated by the compatibility layer, not the supplier’s actual image-token bill. Missing Images usage does not mean free generation.

## Save images and troubleshoot

- Download the signed image URL without an API key, promptly and with the query string intact.

- A route may store the file before responding or cache it on the first full download. Save it promptly; storage is not permanent.

- For 400 check sizes, references, and model; 401 auth; 413 request size; 429 limit details. Keep request IDs for timeouts or 5xx.

- Do not automatically repeat uncertain paid generation requests. Retry the same URL first if download fails.

## Parameters

| Field | Location | Type | Required | Description | Allowed values | Example |
| --- | --- | --- | --- | --- | --- | --- |
| model | body | string | yes | Examples use gpt-image-2.6-flare-c; gpt-image-2.6-sunburst-c is also listed. Check the model square and key access for legacy aliases. | gpt-image-2.6-flare-c, gpt-image-2.6-sunburst-c, gpt-image-2.5-flare-c, gpt-image-2.5-sunburst-c, gpt-image-2-c, gpt-image-2-4k-c | gpt-image-2.6-flare-c |
| messages | body | array | yes | Reads text and image_url references from the last user message; previous images are not restored. Text is required. |  |  |
| messages[].content[].image_url | body | object | no | Reference image as {"url":"public URL or image data URL"}. |  |  |
| size | body | string | no | auto or WIDTHxHEIGHT. Both dimensions must be multiples of 16; longest edge ≤3840, aspect ratio ≤3:1, total pixels 655,360–8,294,400. Actual pixels depend on the upstream. | auto, 1024x1024, 1536x1024, 1024x1536, 2048x1152, 3840x2160 | 1024x1024 |
| stream | body | boolean | no | Defaults to false. true emits SSE after successful generation and ends with data: [DONE]; no live waiting-period progress. |  |  |
| n / quality / response_format | body | fixed | no | Fixed to one image, high quality, and URL output; requesting b64_json does not enable Base64. Other generation controls are not guaranteed to be forwarded. |  |  |

## Chat generation

```json
{
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": "A yellow ceramic bowl on a white background."
    }
  ],
  "size": "1024x1024",
  "stream": false
}
```

### cURL

```bash
curl --fail-with-body --max-time 300 'https://api.unifyllm.top/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": "A yellow ceramic bowl on a white background."
    }
  ],
  "size": "1024x1024",
  "stream": false
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/chat/completions", {
  method: "POST",
  headers: {
  "Authorization": "Bearer <YOUR_API_KEY>",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": "A yellow ceramic bowl on a white background."
    }
  ],
  "size": "1024x1024",
  "stream": false
}),
  signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

payload = json.loads("{\n  \"model\": \"gpt-image-2.6-flare-c\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"A yellow ceramic bowl on a white background.\"\n    }\n  ],\n  \"size\": \"1024x1024\",\n  \"stream\": false\n}")
response = requests.post(
    "https://api.unifyllm.top/v1/chat/completions",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=payload,
    timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
```

## Streaming generation

```json
{
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": "A yellow ceramic bowl on a white background."
    }
  ],
  "size": "1024x1024",
  "stream": true
}
```

### cURL

```bash
curl --fail-with-body --max-time 300 --no-buffer 'https://api.unifyllm.top/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": "A yellow ceramic bowl on a white background."
    }
  ],
  "size": "1024x1024",
  "stream": true
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/chat/completions", {
  method: "POST",
  headers: {
  "Authorization": "Bearer <YOUR_API_KEY>",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": "A yellow ceramic bowl on a white background."
    }
  ],
  "size": "1024x1024",
  "stream": true
}),
  signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const decoder = new TextDecoder();
for await (const chunk of response.body) {
  process.stdout.write(decoder.decode(chunk, { stream: true }));
}
// SSE may split across chunks. Parse complete data: events through [DONE].
```

### Python

```python
import json
import requests

payload = json.loads("{\n  \"model\": \"gpt-image-2.6-flare-c\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"A yellow ceramic bowl on a white background.\"\n    }\n  ],\n  \"size\": \"1024x1024\",\n  \"stream\": true\n}")
with requests.post(
    "https://api.unifyllm.top/v1/chat/completions",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=payload,
    timeout=(10, 300),
    stream=True,
) as response:
    response.raise_for_status()
    for line in response.iter_lines():
        if line:
            print(line.decode("utf-8"), flush=True)
```

## Chat edit

```json
{
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Change the cup to blue."
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/reference.jpg"
          }
        }
      ]
    }
  ],
  "size": "1024x1024",
  "stream": false
}
```

### cURL

```bash
curl --fail-with-body --max-time 300 'https://api.unifyllm.top/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Change the cup to blue."
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/reference.jpg"
          }
        }
      ]
    }
  ],
  "size": "1024x1024",
  "stream": false
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/chat/completions", {
  method: "POST",
  headers: {
  "Authorization": "Bearer <YOUR_API_KEY>",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "model": "gpt-image-2.6-flare-c",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Change the cup to blue."
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/reference.jpg"
          }
        }
      ]
    }
  ],
  "size": "1024x1024",
  "stream": false
}),
  signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

payload = json.loads("{\n  \"model\": \"gpt-image-2.6-flare-c\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"Change the cup to blue.\"\n        },\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"https://example.com/reference.jpg\"\n          }\n        }\n      ]\n    }\n  ],\n  \"size\": \"1024x1024\",\n  \"stream\": false\n}")
response = requests.post(
    "https://api.unifyllm.top/v1/chat/completions",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=payload,
    timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
```

## Response examples

### Chat result — HTTP 200

```json
{
  "id": "chatcmpl-example",
  "object": "chat.completion",
  "model": "gpt-image-2.6-flare-c",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "生成完成\n\n![生成图片](https://image.ezworkapi.top/oai-hc-img?u=EXAMPLE_IMAGE&sig=EXAMPLE_SIGNATURE)\n\n图片链接：[点击查看](https://image.ezworkapi.top/oai-hc-img?u=EXAMPLE_IMAGE&sig=EXAMPLE_SIGNATURE)"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 24,
    "total_tokens": 36,
    "media_units": 1
  }
}
```

### SSE result — HTTP 200

```sse
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","model":"gpt-image-2.6-flare-c","choices":[{"index":0,"delta":{"role":"assistant","content":"生成完成\n\n![生成图片](https://image.ezworkapi.top/oai-hc-img?u=EXAMPLE_IMAGE&sig=EXAMPLE_SIGNATURE)"},"finish_reason":null}]}

data: {"id":"chatcmpl-example","object":"chat.completion.chunk","model":"gpt-image-2.6-flare-c","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":24,"total_tokens":36,"media_units":1}}

data: [DONE]


```

## Related endpoints

- [GPT Image 2.6 Generation](https://www.unifyllm.com/docs/api-reference/create-image/)
- [GPT Image 2.6 Edit — File Upload](https://www.unifyllm.com/docs/api-reference/edit-image-form-data/)
- [GPT Image Edit — JSON](https://www.unifyllm.com/docs/api-reference/gpt-image-edit-json/)
