> ## 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-hant/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，必須為公開可存取且可直接訪問的影像檔案。對於 `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-hant/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-hant/models/image)
* [生成 API 總覽](https://apixo.ai/docs/zh-hant/models.md)
* [送出生成任務](https://apixo.ai/docs/zh-hant/api-reference/generate-task.md)
* [查詢任務狀態](https://apixo.ai/docs/zh-hant/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)
* [錯誤碼](https://apixo.ai/docs/zh-hant/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.