# **Seedream 5.5 Image Generation API**

#### [Download this document as MD](https://beeroute.ai/doc/coding/seedream.md)

**Endpoint**: `POST https://beeroute.ai/v1/images/generations`

**Model name**: `doubao-seedream-5-5-261028`

Seedream 5.5 is ByteDance's image model for professional content production, focused on precise editing and multi-turn consistency, with stronger real-world scenes, multi-image fusion, small text and multilingual text rendering. **Request bodies and responses are identical to the official Volcengine Ark API**: to use an official example, replace `https://ark.cn-beijing.volces.com/api/v3/images/generations` with `https://beeroute.ai/v1/images/generations` and use your BeeRoute API key. The request body stays the same.

**Note: image URLs are temporary (valid for 24 hours). Save important results promptly.**

---

## 1. Capabilities

| Capability | Description |
| :--- | :--- |
| **Text-to-image** | Generate one image from a prompt |
| **Image-to-image / multi-image fusion** | 1–10 reference images + prompt, generates one image |
| **Interactive editing** | Mark positions on the reference image with coordinates, boxes, arrows or sketches for precise edits |
| **Transparent background (RGBA)** | Generate PNGs with an alpha channel directly, from text or from images |
| **Layer decomposition** | Split one image into 1 base image + up to 99 layers (each a transparent PNG), with each layer's position, name and description |
| **Rich-text OCR** | During layer decomposition, recognize the text and style (font, color, bold, italic, underline, strikethrough, shadow, translucency) of regular text layers |
| **Multilingual prompts** | Besides Chinese and English: Japanese, Korean, French, German, Spanish, Portuguese, Russian, Arabic, Vietnamese, Thai, Indonesian and more |

> **Not supported by Seedream 5.5**: image sets (`sequential_image_generation`), web search (`tools`), streaming (`stream`). Do not send these parameters.

---

## 2. Pricing

Seedream 5.5 is **billed per image**: each input reference image is charged once, and each output image is charged by its pixel tier.

| Item | Unit price |
| :--- | :--- |
| Input image (reference / image to decompose) | **$0.0074 / image** |
| Output image, total pixels ≤ 2.61M (2,610,000) | **$0.0191 / image** |
| Output image, total pixels > 2.61M | **$0.0338 / image** |

**Tier of common sizes:**

| `size` | Actual width x height (examples) | Pixels per image | Output price |
| :--- | :--- | :--- | :--- |
| `1K` | 1024x1024, 1424x800, 800x1424 | ~1.0M–1.14M | $0.0191 |
| `1.5K` | 1536x1536, 2048x1152, 1152x2048 | ~2.34M–2.41M | $0.0191 |
| `2K` (default) | 2048x2048, 2816x1584, 1664x2496 | ~4.15M–4.46M | $0.0338 |
| Custom `WxH` | e.g. `2560x1440` | 3.69M | $0.0338 |

**Cost examples:**

| Scenario | Input images | Output images | Cost |
| :--- | :--- | :--- | :--- |
| Text-to-image, `size: 2K` | 0 | 1 (2K) | 0.0338 = **$0.0338** |
| Text-to-image, `size: 1K` | 0 | 1 (1K) | 0.0191 = **$0.0191** |
| Multi-image fusion, 2 references, `size: 2K` | 2 | 1 (2K) | 2×0.0074 + 0.0338 ≈ **$0.0485** |
| Layer decomposition, `size: 2K`, 1 base + 7 layers (all layers ≤ 2.61M pixels) | 1 | 1 base (2K) + 7 layers | 0.0074 + 0.0338 + 7×0.0191 ≈ **$0.175** |

> **Billing notes**:
> - Only **successfully generated** images are charged. Failed images are free.
> - In **layer decomposition**, the base image and every layer count as output images, each priced by its own pixel tier. Layers are usually small, so most fall into the $0.0191 tier.
> - **Pre-deduction**: when a request starts, the maximum possible number of images is pre-deducted; after completion you are charged for the actual count and the difference is refunded. Layer decomposition pre-deducts `layer_decomposition_options.max_images` (default 30) images, all at the high tier — by default 0.0074 + 30×0.0338 ≈ $1.0221. **If your balance is below the pre-deduction amount, the request is rejected.** For simple images, lower `max_images`.
> - In the usage log, the "input / output" columns for this model are **image counts**, not tokens. The log details show the per-image prices.
> - Actual billing follows the group ratio configured by the administrator.

---

## 3. Request Parameters

### Header

| Parameter | Type | Required | Default | Description |
| :--- | :--- | :--- | :--- | :--- |
| `Authorization` | string | ✅ | `Bearer {{YOUR_API_KEY}}` | API authentication token |
| `Content-Type` | string | ✅ | `application/json` | Request body type |

### Body (`application/json`)

| Parameter | Type | Required | Default | Description |
| :--- | :--- | :--- | :--- | :--- |
| `model` | string | ✅ | - | `doubao-seedream-5-5-261028` |
| `prompt` | string | Required for generation | - | Image description. Optional for layer decomposition: specifies which elements to extract; if omitted, the model detects all main elements. Recommended: ≤ 300 Chinese characters or ≤ 600 English words |
| `image` | string / string[] | Required for layer decomposition | - | Reference image(s), URL or Base64 (`data:image/png;base64,<data>`, lowercase format). Up to 10 for generation; exactly 1 for layer decomposition |
| `size` | string | No | Generation `2K`; layer decomposition `auto` | Output size, see "size values" below. **Directly affects cost** |
| `background` | string | No | `auto` | Alpha channel: `auto` (model decides), `transparent` (RGBA output), `opaque`. Not allowed with layer decomposition |
| `output_format` | string | No | `png` | `png` or `jpeg`. In layer decomposition it only applies to the base image; layers are always `png`. `jpeg` cannot be combined with `background: transparent` |
| `response_format` | string | No | `url` | `url` (download link, valid 24 hours) or `b64_json` (Base64 data) |
| `watermark` | boolean | No | `true` | Adds an "AI generated" watermark at the bottom right. **On by default — pass `false` to disable** |
| `layer_decomposition` | boolean | No | `false` | Layer decomposition switch. When `true`, `image` is split into 1 base image + multiple layers |
| `layer_decomposition_options.max_images` | integer | No | `30` | Maximum total output images including the base, range `[2, 100]`. Larger values give finer splits and **also set the pre-deduction amount** |
| `layer_decomposition_options.text_recognition` | boolean | No | `false` | Return rich-text OCR for regular text layers (`data[].text_recognition`) |
| `optimize_prompt_options.mode` | string | No | `standard` | Prompt optimization mode; 5.5 only supports `standard` |
| `safety_identifier` | string | No | - | End-user identifier (≤ 64 characters), ideally a hash of the user ID, used by the platform to detect abusive users; echoed back in the response |

### Reference image requirements

| Scenario | Formats | Size | Dimensions |
| :--- | :--- | :--- | :--- |
| Generation (image-to-image / fusion / interactive editing) | jpeg, png, webp, bmp, tiff, gif, heic, heif | ≤ 30MB | Aspect ratio [1/16, 16]; width and height > 14px; total pixels ≤ 6000×6000 |
| Layer decomposition | png, jpeg | ≤ 30MB | Aspect ratio [1/16, 16]; total pixels between 512×512 and 6000×6000 |

### size values

**Generation** — choose one of two methods, do not mix:

- **Method 1 (recommended)**: pass a resolution tier `1K`, `1.5K` or `2K` and describe the aspect ratio or purpose in the prompt (e.g. "vertical phone wallpaper"); the model decides the final dimensions.
- **Method 2**: pass exact dimensions `WxH`, e.g. `2560x1440`. Total pixels must be within [921,600 (1280x720), 4,624,220] and the aspect ratio within [1/16, 16]. For example `512x512` has too few pixels and is rejected.

Typical actual dimensions for method 1:

| Aspect ratio | `1K` | `1.5K` | `2K` |
| :--- | :--- | :--- | :--- |
| 1:1 | 1024x1024 | 1536x1536 | 2048x2048 |
| 4:3 | 1152x864 | 1792x1344 | 2368x1776 |
| 3:4 | 864x1152 | 1344x1792 | 1776x2368 |
| 16:9 | 1424x800 | 2048x1152 | 2816x1584 |
| 9:16 | 800x1424 | 1152x2048 | 1584x2816 |
| 3:2 | 1248x832 | 1872x1248 | 2496x1664 |
| 2:3 | 832x1248 | 1248x1872 | 1664x2496 |
| 21:9 | 1568x672 | 2352x1008 | 3136x1344 |

**Layer decomposition** — tiers only: `1K`, `1.5K`, `2K`, `auto` (default).

- The base image matches the `size` resolution and the original aspect ratio; each layer is close to the `size` resolution and keeps its aspect ratio from the original image.
- `auto`: outputs the base and each layer at their original size; anything below 1K is output at 1K and anything above 2K at 2K.

> **How to call**: image-to-image also uses `/v1/images/generations` — pass a URL or Base64 in `image`. The `/v1/images/edits` endpoint and multipart file upload are not supported yet.

---

## 4. Request Examples

### 1. Text-to-image

```bash
curl -X POST 'https://beeroute.ai/v1/images/generations' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "A vibrant close-up editorial portrait, model with a piercing gaze wearing a sculptural hat, rich color blocking, sharp focus on the eyes, shallow depth of field, Vogue cover aesthetic, shot on medium format, dramatic studio lighting.",
    "size": "2K",
    "output_format": "png",
    "watermark": false
  }'
```

### 2. Transparent background (RGBA)

```bash
curl -X POST 'https://beeroute.ai/v1/images/generations' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "A sticker of a Shiba Inu wearing a red scarf, flat illustration style, white outline",
    "size": "1K",
    "background": "transparent",
    "output_format": "png",
    "watermark": false
  }'
```

> With `background: transparent`, `output_format` must be `png`. `data[].background` in the response reports the image's actual transparency.

### 3. Image-to-image

```bash
curl -X POST 'https://beeroute.ai/v1/images/generations' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "Keep the model pose and the flowing shape of the liquid garment unchanged. Change the garment material from silver metal to completely transparent clear water (or glass). Skin details are visible through the liquid. Lighting changes from reflection to refraction.",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png",
    "size": "2K",
    "watermark": false
  }'
```

### 4. Multi-image fusion

```bash
curl -X POST 'https://beeroute.ai/v1/images/generations' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "Replace the outfit in image 1 with the outfit from image 2",
    "image": [
      "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimage_1.png",
      "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imagesToimage_2.png"
    ],
    "size": "2K",
    "watermark": false
  }'
```

> Refer to reference images as "image 1", "image 2" in the prompt, in the same order as the `image` array.

### 5. Interactive editing

Mark positions on the reference image with boxes, arrows or sketches, then describe the edit in the prompt:

```bash
curl -X POST 'https://beeroute.ai/v1/images/generations' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "Edit the image according to the hand-drawn sketch. Add a stack of real magazines or art books in the marked area at the bottom left, and a ceramic coffee cup with a saucer in the marked area on the right. Remove all sketch lines. Keep the composition unchanged. Blend the new objects naturally into the scene.",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_input2.png",
    "size": "2K",
    "watermark": false
  }'
```

### 6. Layer decomposition (with rich-text OCR)

```bash
curl -X POST 'https://beeroute.ai/v1/images/generations' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "Separate the image into precise layers. Text to separate is at <bbox>180 64 812 198</bbox>, <bbox>757 210 939 280</bbox>, <bbox>63 212 320 282</bbox>, <bbox>178 714 826 810</bbox>, <bbox>814 819 949 894</bbox>, <bbox>326 824 669 930</bbox>; the parrot is at <bbox>347 305 642 997</bbox>.",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png",
    "layer_decomposition": true,
    "layer_decomposition_options": {
      "max_images": 10,
      "text_recognition": true
    },
    "size": "2K",
    "output_format": "jpeg",
    "watermark": false
  }'
```

> - The prompt is optional; the model will detect all main elements. Use `<bbox>left top right bottom</bbox>` (coordinates normalized to 0–1000) to target specific regions.
> - With `max_images` set to 10, the pre-deduction is 0.0074 + 10×0.0338 ≈ $0.3456; the final charge is based on the actual image count.
> - If any layer fails, the whole request fails — there are no partial results.

### 7. Python (OpenAI SDK)

The OpenAI SDK does not know Seedream-specific parameters; put them in `extra_body`:

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://beeroute.ai/v1",
    api_key="{{YOUR_API_KEY}}",
)

response = client.images.generate(
    model="doubao-seedream-5-5-261028",
    prompt="Split the subject, text and background into separate layers",
    size="2K",
    response_format="url",
    extra_body={
        "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png",
        "layer_decomposition": True,
        "layer_decomposition_options": {"max_images": 10},
        "watermark": False,
    },
)

for item in response.data:
    print(item.url)
```

---

## 5. Response

### Response fields

| Field | Type | Description |
| :--- | :--- | :--- |
| `model` | string | Model ID actually used |
| `created` | integer | Creation time (Unix seconds) |
| `data[].url` | string | Image URL (when `response_format: url`), **valid for 24 hours** |
| `data[].b64_json` | string | Image Base64 (when `response_format: b64_json`) |
| `data[].size` | string | Actual dimensions, e.g. `2048x2048`. This determines the pricing tier |
| `data[].output_format` | string | `png` or `jpeg` |
| `data[].background` | string | Actual transparency: `transparent` (has transparent or translucent pixels) or `opaque` |
| `data[].z_index` | integer | **Layer decomposition**: stacking order; base is `0`, layers count up from `1`, higher is on top |
| `data[].name` | string | **Layer decomposition**: layer name |
| `data[].description` | string | **Layer decomposition**: layer description (color, material, etc.) |
| `data[].bounding_box.absolute` | int[4] | **Layer decomposition**: pixel coordinates in the base image `[left, top, right, bottom]` (not returned for the base) |
| `data[].bounding_box.normalized` | int[4] | **Layer decomposition**: coordinates normalized to 0–1000 `[left, top, right, bottom]` |
| `data[].text_recognition` | object | **Rich-text OCR**: `text` full text; `lines[]` each with `bounding_box` and style runs `runs[]` (`text`, `style` with `similar_font_family`, `foreground_color`, `bold`, `italic`, `underline`, `strikethrough`, `shadow`, `translucent`) |
| `usage.input_images` | integer | Number of input images |
| `usage.generated_images` | integer | Number of images generated successfully |
| `usage.output_tokens` | integer | Tokens reported by Volcengine (sum of output pixels / 256); **not used for BeeRoute billing** |
| `safety_identifier` | string | Echoed back only if sent in the request |
| `error` | object | `code` and `message` when the whole request fails |

### Text-to-image response example

```json
{
    "model": "doubao-seedream-5-5-261028",
    "created": 1794920003,
    "data": [
        {
            "url": "https://ark-acg-cn-beijing.tos-cn-beijing.volces.com/doubao-seedream-5-5/....png",
            "size": "1664x2496",
            "output_format": "png",
            "background": "opaque"
        }
    ],
    "usage": {
        "input_images": 0,
        "generated_images": 1,
        "output_tokens": 16224,
        "total_tokens": 16224
    }
}
```

> Output is 1664x2496, about 4.15M pixels, in the > 2.61M tier: cost $0.0338.

### Layer decomposition response example

```json
{
    "model": "doubao-seedream-5-5-261028",
    "created": 1784696685,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
        },
        {
            "url": "https://...",
            "size": "1273x265",
            "output_format": "png",
            "z_index": 1,
            "bounding_box": {
                "absolute": [383, 120, 1655, 384],
                "normalized": [187, 59, 808, 188]
            },
            "name": "Seedream title text",
            "description": "Seedream title text in a large yellow serif font"
        }
    ],
    "usage": {
        "input_images": 1,
        "generated_images": 2,
        "output_tokens": 23107,
        "total_tokens": 23107
    }
}
```

> In this example: 1 input ($0.0074) + base 2048x2048 ($0.0338) + layer 1273x265 ($0.0191) = $0.0603.

### Placing layers back onto the base image

- **Using `absolute`** (recommended, for the output base image): scale the layer to `width = right - left`, `height = bottom - top`, and place it at `(left, top)` on the base.
- **Using `normalized`** (for any canvas `W × H`): position `(left/1000×W, top/1000×H)`, size `(right-left)/1000×W × (bottom-top)/1000×H`.
- Stack multiple layers in ascending `z_index` order.

---

## 6. FAQ

1. **Images have an "AI generated" watermark?** `watermark` defaults to `true`; pass `"watermark": false` explicitly.
2. **Image link no longer works?** URLs are valid for only 24 hours after generation; download promptly, or use `"response_format": "b64_json"` to receive the image data directly.
3. **"预扣费额度失败" (pre-deduction failed) although the balance looks enough?** The maximum possible image count is pre-deducted when the request starts (layer decomposition pre-deducts 30 high-tier images, $1.0221, by default). Lower `layer_decomposition_options.max_images` to reduce it; you are charged for the actual count at the end.
4. **Error when sending `stream`, `sequential_image_generation` or `tools`?** Seedream 5.5 does not support streaming, image sets or web search.
5. **Layer decomposition fails?** Make sure you send exactly 1 image in png/jpeg of at least 512×512 pixels, and do not send `background`.
6. **Want it cheaper?** Output at `1K` or `1.5K` ($0.0191/image) — 43% cheaper than `2K` ($0.0338/image).
