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

# Seedream 图片生成

> 通过 OpenAI Images 兼容格式调用 Seedream 文生图模型（gogogotoken.ai）

通过 OpenAI Images 兼容格式调用 Seedream 文生图模型。模型列表与 USD 单价见 [Seedream 图像模型](/overseas/seedream-models)。

<RequestExample>
  ```bash 文生图（推荐：不传 size） theme={null}
  curl -X POST https://gogogotoken.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "doubao-seedream-5-0-lite",
      "prompt": "a minimalist product photo of a smartwatch on white background, studio lighting",
      "n": 1
    }'
  ```

  ```bash 批量生成 theme={null}
  curl -X POST https://gogogotoken.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "doubao-seedream-4-5",
      "prompt": "cute orange cat sitting on a windowsill, soft afternoon light, photorealistic",
      "n": 2
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "model": "seedream-5-0-260128",
    "created": 1782574755,
    "data": [
      {
        "url": "https://assets.example.com/generated-image.jpeg",
        "size": "2048x2048"
      }
    ],
    "usage": {
      "generated_images": 1,
      "output_tokens": 16384,
      "total_tokens": 16384
    }
  }
  ```

  ```json 400 尺寸过小 theme={null}
  {
    "error": {
      "message": "The parameter `size` specified in the request is not valid: image size must be at least 3686400 pixels.",
      "type": "upstream_error",
      "code": "InvalidParameter"
    }
  }
  ```
</ResponseExample>

## 接口说明

* **Base URL**：`https://gogogotoken.ai`
* **路径**：`POST /v1/images/generations`
* **鉴权**：`Authorization: Bearer YOUR_API_KEY`
* **Content-Type**：`application/json`

响应中的 `model` 字段可能显示上游内部 ID（如 `seedream-5-0-260128`），调用时仍请使用 `doubao-seedream-5-0-lite` 或 `doubao-seedream-4-5`。

<Note>
  图片 URL 通常有时效（例如 24 小时）。请在拿到结果后尽快下载或转存到你的对象存储。
</Note>

## 请求头

<ParamField header="Authorization" type="string" required>
  API Key 鉴权信息，格式为 `Bearer YOUR_API_KEY`。
</ParamField>

<ParamField header="Content-Type" type="string" required>
  固定为 `application/json`。
</ParamField>

## 请求体

<ParamField body="model" type="string" required default="doubao-seedream-5-0-lite">
  模型 ID：`doubao-seedream-5-0-lite` 或 `doubao-seedream-4-5`。完整列表见 [模型列表](/overseas/seedream-models)。
</ParamField>

<ParamField body="prompt" type="string" required default="a minimalist product photo of a smartwatch on white background, studio lighting">
  图片描述，支持中英文。
</ParamField>

<ParamField body="n" type="integer" default={1}>
  生成数量，默认 `1`。按实际成功输出张数计费。
</ParamField>

<ParamField body="size" type="string">
  可选。不传时默认 **2048×2048**。若指定，总像素须 ≥ 3,686,400（勿传 `1024×1024`）。
</ParamField>

<ParamField body="response_format" type="string">
  返回格式，例如 `url` 或 `b64_json`。Seedream 上游通常返回 `url`。
</ParamField>

## 响应体

<ResponseField name="created" type="integer">
  响应创建时间戳。
</ResponseField>

<ResponseField name="data" type="object[]">
  图片结果数组。

  <ResponseField name="url" type="string">
    生成图片的可访问 URL。
  </ResponseField>

  <ResponseField name="size" type="string">
    实际输出尺寸，例如 `2048x2048`。
  </ResponseField>

  <ResponseField name="b64_json" type="string">
    base64 编码的图片内容（若上游与 `response_format` 支持）。
  </ResponseField>
</ResponseField>

<ResponseField name="usage.generated_images" type="integer">
  成功生成的图片张数，用于核对按张扣费。
</ResponseField>

## 错误码

| 状态码   | 含义                | 处理建议                      |
| ----- | ----------------- | ------------------------- |
| `400` | 参数无效（如 `size` 过小） | 省略 `size` 或改用 ≥ 1920×1920 |
| `401` | API Key 无效或未传     | 检查请求头与令牌状态                |
| `403` | 无权限访问目标模型         | 检查 API Key 分组权限           |
| `429` | 触发限速              | 降低请求频率或调整套餐               |
| `5xx` | 上游或网关异常           | 稍后重试，并查看控制台日志             |
