> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbrod.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT-Image-2.5 图像生成

> - 提供 gpt-image-2.5-flare 与 gpt-image-2.5-sunburst 两种模型
- 支持文生图与最多 16 张参考图的图像编辑
- 支持 15 种比例、精确像素尺寸以及 1K / 2K / 4K 分辨率
- 支持 low / medium / high / xhigh / max 五档质量

```bash cURL theme={null}
curl -X POST 'https://ai.xbrod.com/v1/images/generations' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"model":"gpt-image-2.5-flare","prompt":"一张简洁的绿色植物海报，干净背景","size":"1:1","resolution":"1k","quality":"low"}'
```

```python Python theme={null}
import json
import requests

response = requests.post('https://ai.xbrod.com/v1/images/generations',
    headers={'Authorization': 'Bearer <token>'},
    json=json.loads("{\"model\":\"gpt-image-2.5-flare\",\"prompt\":\"一张简洁的绿色植物海报，干净背景\",\"size\":\"1:1\",\"resolution\":\"1k\",\"quality\":\"low\"}"))
print(response.json())
```

```javascript JavaScript theme={null}
const response = await fetch('https://ai.xbrod.com/v1/images/generations', {
  method: 'POST',
  headers: { Authorization: 'Bearer <token>', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "model": "gpt-image-2.5-flare",
    "prompt": "一张简洁的绿色植物海报，干净背景",
    "size": "1:1",
    "resolution": "1k",
    "quality": "low"
  }),
});
console.log(await response.json());
```

```go Go theme={null}
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, err := http.NewRequest("POST", "https://ai.xbrod.com/v1/images/generations", bytes.NewBufferString(`{"model":"gpt-image-2.5-flare","prompt":"一张简洁的绿色植物海报，干净背景","size":"1:1","resolution":"1k","quality":"low"}`))
    if err != nil { panic(err) }
    req.Header.Set("Authorization", "Bearer <token>")
    req.Header.Set("Content-Type", "application/json")
    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()
    body, err := io.ReadAll(resp.Body)
    if err != nil { panic(err) }
    fmt.Println(string(body))
}
```

```java Java theme={null}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder(URI.create("https://ai.xbrod.com/v1/images/generations"))
            .header("Authorization", "Bearer <token>")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString("{\"model\":\"gpt-image-2.5-flare\",\"prompt\":\"一张简洁的绿色植物海报，干净背景\",\"size\":\"1:1\",\"resolution\":\"1k\",\"quality\":\"low\"}"))
            .build();
        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```php PHP theme={null}
<?php
$ch = curl_init('https://ai.xbrod.com/v1/images/generations');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer <token>', 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => '{"model":"gpt-image-2.5-flare","prompt":"一张简洁的绿色植物海报，干净背景","size":"1:1","resolution":"1k","quality":"low"}',
    CURLOPT_RETURNTRANSFER => true,
]);
$result = curl_exec($ch);
if ($result === false) { throw new RuntimeException(curl_error($ch)); }
curl_close($ch);
echo $result;
```

```ruby Ruby theme={null}
require 'net/http'

uri = URI('https://ai.xbrod.com/v1/images/generations')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = '{"model":"gpt-image-2.5-flare","prompt":"一张简洁的绿色植物海报，干净背景","size":"1:1","resolution":"1k","quality":"low"}'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
puts response.body
```


## OpenAPI

````yaml generated/gpt-image-2.5.json POST /v1/images/generations
openapi: 3.0.3
info:
  title: new-api GPT Image 2.5 API
  version: 0.1.0
servers:
  - url: https://ai.xbrod.com
    description: 本项目线上 API 网关
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      summary: GPT-Image-2.5 图像生成
      description: 使用 Flare 或 Sunburst 模型生成或编辑图片。下方按字段说明请求参数与响应格式。
      operationId: generate_gpt_image_2_5
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: |-
                    图像生成模型名称。可选值：

                    - `gpt-image-2.5-flare`
                    - `gpt-image-2.5-sunburst`
                prompt:
                  type: string
                  description: 图片生成或编辑的文字描述。仅传入提示词时生成图片；配合 `image_urls` 时根据参考图进行生成或编辑。
                size:
                  type: string
                  default: auto
                  description: >-
                    输出图像的比例或精确像素尺寸。支持：


                    - `auto`：由模型根据提示词或参考图决定

                    -
                    比例名：`1:1`、`3:2`、`2:3`、`4:3`、`3:4`、`5:4`、`4:5`、`16:9`、`9:16`、`2:1`、`1:2`、`21:9`、`9:21`、`3:1`、`1:3`

                    - 精确像素：例如 `1600x1200`
                resolution:
                  type: string
                  default: 1k
                  description: |-
                    分辨率档位，与比例形式的 `size` 配合决定实际输出像素。

                    - `1k`（默认）
                    - `2k`
                    - `4k`

                    当 `size` 使用精确像素格式时，此字段会被忽略。
                quality:
                  type: string
                  default: low
                  description: |-
                    图片质量档位。

                    - `low`（默认）
                    - `medium`
                    - `high`
                    - `xhigh`
                    - `max`
                    - `auto`（在本网关中按 `low` 处理）
                'n':
                  type: integer
                  minimum: 1
                  maximum: 4
                  default: 1
                  description: 本次生成的图片数量，1 至 4 张；省略时生成 1 张。
                output_format:
                  type: string
                  enum:
                    - png
                    - jpeg
                    - webp
                  default: png
                  description: 输出图片格式：`png`（默认）、`jpeg` 或 `webp`。
                output_compression:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: JPEG 或 WebP 的输出压缩参数，取值为 0 至 100。
                background:
                  type: string
                  description: 背景设置：`transparent`、`opaque` 或 `auto`。透明背景仅适用于 PNG 或 WebP。
                image_urls:
                  type: array
                  items:
                    type: string
                  description: 图生图或图像编辑使用的参考图数组，最多 `16` 张。传入后自动进入编辑模式。支持公网可访问的 HTTP(S) URL。
                mask_url:
                  type: string
                  description: >-
                    局部编辑蒙版。需与第一张参考图同尺寸，使用带 Alpha 通道的 PNG；可提供公开可访问的图片 URL 或 Data
                    URI，且需同时提供 `image_urls`。
                response_format:
                  type: string
                  enum:
                    - url
                    - b64_json
                  default: b64_json
                  description: 返回格式：默认 b64_json 为 Base64 数据；url 为图片地址。
              required:
                - model
                - prompt
            example:
              model: gpt-image-2.5-flare
              prompt: 一张简洁的绿色植物海报，干净背景
              size: '1:1'
              resolution: 1k
              quality: low
      responses:
        '200':
          description: '生成成功，默认返回 Base64 图片数据；显式传入 response_format: url 时返回图片 URL'
          content:
            application/json:
              schema:
                type: object
                properties:
                  created:
                    type: integer
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        b64_json:
                          type: string
                          description: 图片原始字节的 Base64 编码
                        url:
                          type: string
                          description: 转换后的图片 URL
              example:
                created: 1
                data:
                  - b64_json: iVBORw0KGgoAAAANSUhEUg...
        '504':
          description: 图片等待超时；返回 task_id 仅供查询原任务状态，不提供图片制品；重复提交可能再次计费。
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 控制台获取的API密钥

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.