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

# Seedream 4.0 API：字节跳动的文生图与图像编辑模型

> 字节跳动 Seedream 4.0 图像生成 API，支持文生图和图生图工作流，提供 1K、2K 和 4K 输出预设

## 概览

Seedream 4.0 是字节跳动的图像模型，可根据文字或参考图生成图像。可选 1K、2K 和 4K 输出分辨率，每个任务最多生成 15 张图。还可启用系列图生成，或使用 `standard`、`fast` 模式优化提示词。

| 功能 | 值 |
| - | - |
| 模型 ID | `seedream-4-0` |
| 模式 | `text-to-image`, `image-to-image` |
| 提示词长度 | 1 至 5000 个字符 |
| 参考图片 | 1-14 `image-to-image` 的 URL |
| 每个任务的图像数量 | `max_images` 为必填项，范围 1-15；对于 `image-to-image`，`image_urls` 数量加上 `max_images` 必须小于或等于 15。 |
| 分辨率档位 | `1K`, `2K`, `4K` |
| 纵横比 | `1:1`, `2:3`, `3:2`, `4:3`, `3:4`, `9:16`, `16:9`, `21:9` |
| 尺寸输入 | `1K`, `2K`, `4K`, `2048x2048`, `2048X2048`, `2048*2048` |
| 顺序生成 | `disabled`, `auto` |
| 提示词优化 | `standard`, `fast` |

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/seedream-4-0` | 提交生成任务 |
| `GET` | `/statusTask/seedream-4-0?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

```http theme={null}
Content-Type: application/json
```

## 异步请求示例

以下示例提交一个最简单的文生图任务，响应中会返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/seedream-4-0" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "mode": "text-to-image",
      "prompt": "a sunrise train passing through snowy hills",
      "max_images": 2,
      "resolution": "1K",
      "aspect_ratio": "16:9",
      "prompt_optimize_mode": "fast"
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

保存 `taskId`，后续轮询结果时需要用到它。

## 请求体

### 文生图

```json theme={null}
{
  "input": {
    "mode": "text-to-image",
    "prompt": "a clean architectural concept of a coastal library",
    "max_images": 2,
    "resolution": "1K",
    "aspect_ratio": "16:9",
    "prompt_optimize_mode": "fast"
  }
}
```

### 图生图

```json theme={null}
{
  "input": {
    "mode": "image-to-image",
    "prompt": "turn this sketch into a cinematic concept frame",
    "image_urls": [
      "https://example.com/reference-1.png"
    ],
    "max_images": 2,
    "resolution": "2K",
    "aspect_ratio": "3:4",
    "sequential_image_generation": "auto",
    "prompt_optimize_mode": "standard"
  }
}
```

### 显式尺寸

```json theme={null}
{
  "input": {
    "mode": "text-to-image",
    "prompt": "an editorial interior still",
    "max_images": 1,
    "size": "2048*2048"
  }
}
```

## 参数

**request\_type** `string` (default: async)

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当 `request_type` 为 `callback` 时必填。请提供公网可访问的 HTTPS 地址，用于接收任务的最终结果。详见 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

Seedream 4.0 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `text-to-image`、`image-to-image`。

**prompt** `string` *required*

用文字描述要生成的图像或要做的修改。去除首尾空白后，长度须为 1 至 5000 个字符。

**max\_images** `integer` *required*

请求的图像数量。支持范围：1-15。对于 `image-to-image`，`image_urls` 中参考图像数量加上 `max_images` 不得超过 15。

**image\_urls** `string[]`

参考图像 URL。`image-to-image` 任务必需。支持 1-14 个 URL。URL 需为公开可访问且可直接访问的图像文件。对于 `image-to-image`，`image_urls` 数量加上 `max_images` 必须小于或等于 15。

**resolution** `string` (default: 2K)

输出分辨率预设。支持的值：`1K`、`2K`、`4K`。当`resolution + aspect_ratio`和`size`同时提供时，`resolution + aspect_ratio`优先。

**aspect\_ratio** `string`

可选的输出纵横比。支持的值：`1:1`、`2:3`、`3:2`、`4:3`、`3:4`、`9:16`、`16:9`、`21:9`。

**size** `string`

可选的显式大小或预设标记。预设标记不区分大小写，支持 `1K`、`2K` 和 `4K`。像素字符串接受 `x`、`X` 或 `*` 分隔符，例如 `2048x2048`、`2048X2048` 或 `2048*2048`。自定义像素大小必须使用 16 像素粒度，保持宽高比在 `1/16` 和 `16` 之间，并将总像素保持在 `921,600` 和 `16,777,216` 之间（等效于 `1280x720` 至 `4096x4096`）。不支持的自定义值将被调整为最接近的支持的输出大小。

**sequential\_image\_generation** `string` (default: disabled)

连续图像模式。支持的值：`disabled`、`auto`。

**prompt\_optimize\_mode** `string` (default: standard)

提示优化模式。支持的值：`standard`、`fast`。

**nsfw\_checker** `boolean` (default: false)

为本次请求启用内容安全过滤。默认值为 `false`。如有填写，值必须为布尔值。

### 尺寸预设基于 `resolution + aspect_ratio`

当提供 `aspect_ratio` 时，APIXO 将 `resolution` 和 `aspect_ratio` 映射到这些输出维度：

| 纵横比 | `1K` 尺寸 | `2K` 尺寸 | `4K`尺寸 |
| - | - | - | - |
| `1:1` | `1024x1024` | `2048x2048` | `4096x4096` |
| `2:3` | `832x1248` | `1664x2496` | `3328x4992` |
| `3:2` | `1248x832` | `2496x1664` | `4992x3328` |
| `3:4` | `864x1152` | `1728x2304` | `3520x4704` |
| `4:3` | `1152x864` | `2304x1728` | `4704x3520` |
| `9:16` | `736x1312` | `1600x2848` | `3040x5504` |
| `16:9` | `1312x736` | `2848x1600` | `5504x3040` |
| `21:9` | `1568x672` | `3136x1344` | `6240x2656` |

## 轮询和交付指导

Seedream 4.0 任务是异步的。

| 分辨率 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `1K` | 20s-30s | 任务创建 15 秒后 | 3s |
| `2K` | 25s-35s | 任务创建 20 秒后 | 3s-5s |
| `4K` | 40s-55s | 任务创建 30 秒后 | 5s |

对于生产系统，更喜欢 `callback_url` 而不是紧密的轮询循环。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

Seedream 4.0 按生成的图像计费。当前的公开 APIXO 价格是该型号的单一统一费率。

| 单位 | APIXO 价格 |
| - | - |
| 每张生成的图像 | `$0.030 / image` |

计费行为：

```text theme={null}
precharge = requested max_images * unit price
final charge = successful images * unit price
```

如果成功输出的图像数量少于要求的数量，APIXO 会自动将最终费用调整为成功输出的实际数量。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/image/seedream-4-0.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_urls`。请保留用户指定的文件顺序。API 负责校验模型参数。

## 相关链接

* [图像模型](https://apixo.ai/docs/zh/models/image)
* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [API定价](https://apixo.ai/pricing/api)


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