---
title: Seedream 5.0 Flash image API
description: "Seedream 5.0 Flash on Tokenlio: 1K / 1.5K / 2K output, reference editing, transparent PNG and layer decomposition through asynchronous image tasks."
outline: [2, 3]
---

# Seedream 5.0 Flash

**ByteDance ｜ 1K / 1.5K / 2K ｜ reference editing ｜ transparent PNG ｜ layer decomposition**

Seedream 5.0 Flash generates and edits images from text plus reference images. Every request creates one asynchronous task: create it, poll it, then download the private roles it returns.

**Base URL** `https://api.tokenlio.ai` — the paths below are relative to it:

- **Create**: `POST /v1/images/generations` → **202 Accepted**
- **Query**: `GET /v1/tasks/{id}`
- **Download**: `GET /v1/tasks/{id}/content?role=image_0`

::: tip Before you start
1. Create a Workspace **model-routing API key** in the Tokenlio console.
2. Copy the API model ID published for your Workspace from the [model catalog](https://api.tokenlio.ai/marketplace). The examples use `seedream-5-0-flash`.
3. Image tasks are asynchronous: the create call only accepts the task. Poll until `succeeded`, then download.
:::

::: warning Integration guide, not an availability announcement
Available models, parameter support and prices are listed in the catalog, and your Workspace **and** API key must both be permitted for this model. This page describes the contract; it does not grant access.
:::

## 1. Choose a model

| Model | Size tiers | Images per task | Extra output controls |
| --- | --- | --- | --- |
| **Seedream 5.0 Flash** | `1k` / `1.5k` / `2k` | exactly `1` | transparent PNG, layer decomposition |
| Seedream 5.0 Pro | `1k` / `1.5k` / `2k` | exactly `1` | transparent PNG, layer decomposition |
| Seedream 5.0 Lite | `2k` / `3k` / `4k` | `1`–`15` in one task | none (batch generation instead) |

Flash and Pro default to `size: auto` with `resolution: 1k` and return a single image. Lite defaults to `1:1` with `2k` and can return several images from one task; it does not accept `background`, `layer_decomposition` or prompt optimization.

::: warning `n` is not portable between models
Flash and Pro accept exactly `n: 1`. A request copied from a Lite batch (`n: 2` or more) is rejected locally with **400** and
`n must be 1 for this model; create separate tasks to generate multiple images`.
:::

Model names describe capabilities, not access. All values below are placeholders only for the parts you must replace.

## 2. Quick start: create, poll, download

::: code-group

```bash [cURL]
BASE_URL='https://api.tokenlio.ai'
curl "$BASE_URL/v1/images/generations" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: seedream-flash-001' \
  --data '{"model":"seedream-5-0-flash","prompt":"A serene mountain lake at sunrise, soft mist over the water","size":"auto","resolution":"1k"}'
```

```json [Request body]
{
  "model": "seedream-5-0-flash",
  "prompt": "A serene mountain lake at sunrise, soft mist over the water",
  "size": "auto",
  "resolution": "1k"
}
```

```python [Python]
import json, os, urllib.request

body = {
    "model": "seedream-5-0-flash",
    "prompt": "A serene mountain lake at sunrise, soft mist over the water",
    "size": "auto",
    "resolution": "1k",
}
request = urllib.request.Request(
    "https://api.tokenlio.ai/v1/images/generations",
    data=json.dumps(body).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['TOKENLIO_API_KEY']}",
        "Content-Type": "application/json",
        "Idempotency-Key": "seedream-flash-001",
    },
)
print(json.load(urllib.request.urlopen(request)))
```

:::

A **202** means the task was accepted, not that an image exists:

```json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7",
  "model": "seedream-5-0-flash",
  "status": "queued",
  "assets": []
}
```

Then poll and download:

::: code-group

```bash [Poll]
curl "https://api.tokenlio.ai/v1/tasks/dfc68868-d388-4d83-a173-d44e47a8bec7" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY"
```

```bash [Download]
curl --location "https://api.tokenlio.ai/v1/tasks/dfc68868-d388-4d83-a173-d44e47a8bec7/content?role=image_0" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" -o result.jpeg
```

:::

`status` moves `queued` → `processing` → `succeeded` or `failed`. Poll every 5–15 seconds; the default image timeout is 10 minutes. Keep `message` and `error.code`, and never create a new task while a previous response is still uncertain — query the stored task ID instead.

## 3. Request parameters

| Parameter | Type | Default | Contract |
| --- | --- | --- | --- |
| `model` | string | required | Exact published API model ID |
| `prompt` | string | required | Non-empty UTF-8 text; may be omitted only with `layer_decomposition: true` |
| `size` | string | `auto` | `auto`, a ratio, a size tier, or exact `WxH` pixels |
| `resolution` | string | `1k` | `1k` / `1.5k` / `2k`; used when `size` is `auto` or a ratio |
| `n` | integer | `1` | This model accepts exactly `1` |
| `output_format` | string | `jpeg` | `jpeg` or `png` |
| `background` | string | `opaque` | `opaque` or `transparent` (needs one PNG with alpha) |
| `layer_decomposition` | boolean | `false` | Split one reference image into 1–17 ordered files |
| `image_urls` | string[] | empty | Public HTTPS URLs or complete Base64 Data URIs; at most 10; input order is significant |
| `watermark` | boolean | omitted | Send explicitly to control watermarking |
| `nsfw_check` | boolean | omitted | Send explicitly to control content checking |
| `optimize_prompt_options` | object | `{"mode":"standard"}` | Only `mode: "standard"` is accepted |

Use real JSON booleans and integers — not strings, and not `null`. Unknown fields, duplicate keys, `null` values and trailing data are rejected, so remove anything you do not need.

::: warning Not part of this integration
`quality`, `mask_url`, `output_compression`, `moderation`, `aspect_ratio`, `response_format`, `watermark_text` and internal asset, creator or price fields are rejected. The response is never a synchronous OpenAI-style payload: there is no `data[].b64_json` and no multipart `/v1/images/edits`. Reference images are supplied through `image_urls`.
:::

## 4. Size, resolution and output count

`size` and `resolution` interact in a fixed order:

| `size` | Actual output |
| --- | --- |
| `auto` | Tier from `resolution` (`1k` by default) |
| `1k` / `1.5k` / `2k` | Size tier wins; `resolution` is ignored |
| Ratio such as `16:9` | That ratio at the `resolution` tier |
| Exact `WxH` | Those exact pixels; `resolution` is ignored |

- Tiers are case-insensitive and normalised to lowercase; `1K` is stored as `1k`.
- Supported ratios: `1:1`, `4:3`, `3:4`, `16:9`, `9:16`, `3:2`, `2:3`, `2:1`, `1:2`, `21:9`.
- Exact pixels must total 921,600–4,624,220 pixels with a long-to-short ratio of at most 16:1, for example `2048x2048` or `2048x1152`.
- `n` is exactly `1`: one image per task. Generate several images with several tasks, or use Seedream 5.0 Lite.

::: code-group

```json [Ratio with a tier]
{
  "model": "seedream-5-0-flash",
  "prompt": "A wide cinematic desert road at golden hour",
  "size": "16:9",
  "resolution": "2k"
}
```

```json [Exact pixels]
{
  "model": "seedream-5-0-flash",
  "prompt": "A square product photo of a ceramic cup on linen",
  "size": "2048x2048"
}
```

:::

## 5. Reference images and Base64

Send references in `image_urls` as public HTTPS URLs or as complete Data URIs. Order is preserved, so describe positions in the prompt when it matters.

| Limit | Flash / Pro |
| --- | --- |
| Reference images per request | at most 10 |
| Bytes per reference file | ≤ 30 MiB |
| Decoded inline images, total | ≤ 45 MiB |
| Whole JSON request body | ≤ 64 MiB |
| Pixels per side | more than 14 px, at most 24,000 px |
| Total pixels per image | ≤ 36 megapixels |
| Aspect ratio | between 1:16 and 16:1 |
| Accepted formats | PNG, JPEG, WebP, GIF, BMP, TIFF |

Every reference must be a single, fully decodable static image. Animated PNG and WebP, multi-frame GIF, multi-page TIFF, MPO and concatenated JPEG are rejected, and **HEIC/HEIF are not supported** — convert them first. For Base64, send the complete `data:image/png;base64,...` form: bare Base64, URL-safe alphabets, spaces, missing padding and a declared MIME that disagrees with the real bytes are all rejected.

Inline identity is the decoded image content, not the Base64 text, so re-wrapping line breaks does not create a different request. Large batches should use URLs instead of inline data. URLs are measured after the task is accepted, so a broken or slow link can still fail the task later.

::: code-group

```python [Build JSON from a local file]
import base64, json
from pathlib import Path

data = Path("reference.png").read_bytes()
request = {
    "model": "seedream-5-0-flash",
    "prompt": "Keep the subject and change the lighting to a soft window light",
    "image_urls": ["data:image/png;base64," + base64.b64encode(data).decode("ascii")],
}
Path("request.json").write_text(json.dumps(request), encoding="utf-8")
```

```bash [Send the prepared file]
curl "https://api.tokenlio.ai/v1/images/generations" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: seedream-flash-reference-001' \
  --data-binary @request.json
```

```json [URL reference]
{
  "model": "seedream-5-0-flash",
  "prompt": "Place the same chair beside a large window, keep its material",
  "size": "4:3",
  "resolution": "1.5k",
  "image_urls": ["https://YOUR_PUBLIC_CDN/chair.png"]
}
```

:::

Build the JSON with a JSON library and hold it in a file or memory. Never paste image bytes into a query string, a header or your logs.

## 6. Advanced output controls

### Transparent PNG editing

Transparency requires exactly one reference PNG with a real alpha channel, `background: transparent` and `output_format: png`. A flat JPEG that merely looks transparent does not qualify, and transparency cannot be combined with layer decomposition.

```json
{
  "model": "seedream-5-0-flash",
  "prompt": "Keep the subject, remove the background, preserve the soft edge",
  "background": "transparent",
  "output_format": "png",
  "image_urls": ["https://YOUR_PUBLIC_CDN/with-alpha.png"]
}
```

### Layer decomposition

Layer decomposition splits one reference image into ordered, separately downloadable layers: the base plus up to 16 stacked layers, 1–17 files in total. Request with `layer_decomposition: true` and `n: 1`.

```json
{
  "model": "seedream-5-0-flash",
  "layer_decomposition": true,
  "n": 1,
  "image_urls": ["https://YOUR_PUBLIC_CDN/poster.png"]
}
```

- Exactly one reference image, at least 262,144 and at most 36,000,000 pixels.
- `size` must be `auto` or a size tier; exact pixels and ratios are not accepted here.
- `prompt` is optional; add it to steer which elements become layers.
- `n: 1` is the number of *requested* results. The actual file count is `assets.length` and can be anywhere from 1 to 17.

### Prompt optimisation, watermark and content check

`optimize_prompt_options` defaults to `{"mode":"standard"}`; this is the only accepted mode. Send `watermark` or `nsfw_check` explicitly when you need a specific value — leaving them out means the platform does not set them.

## 7. Results, roles and reconstruction

```json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7",
  "model": "seedream-5-0-flash",
  "status": "succeeded",
  "canvas": {
    "width": 2048,
    "height": 2048
  },
  "assets": [
    {
      "role": "image_0",
      "url": "https://private.example.com/signed-result",
      "mime": "image/jpeg",
      "width": 2048,
      "height": 2048,
      "layer": {
        "kind": "base",
        "z_index": 0
      }
    },
    {
      "role": "image_1",
      "url": "https://private.example.com/signed-layer",
      "mime": "image/png",
      "width": 1024,
      "height": 1024,
      "layer": {
        "kind": "layer",
        "z_index": 1,
        "name": "Subject",
        "bounding_box": {
          "absolute": [512, 512, 1536, 1536],
          "normalized": [0.25, 0.25, 0.75, 0.75]
        }
      }
    }
  ]
}
```

| Field | Meaning |
| --- | --- |
| `assets[].role` | `image_0` is the base or first image; `image_1`–`image_16` are ordered layers |
| `assets[].url` | Private signed link; query the task again for a fresh one |
| `assets[].mime` | Measured type of the delivered file |
| `assets[].width` / `height` | Measured pixel size |
| `canvas.width` / `height` | Measured size of the base image, present for decomposed results |

To rebuild a decomposed result:

1. Sort assets by the numeric index in `role` — `image_2` comes before `image_10`, which a plain string sort gets wrong.
2. Start with `canvas.width` × `canvas.height` as the output size.
3. Stack layers in ascending `layer.z_index`.
4. Place each layer at `layer.bounding_box.absolute` = `[x1, y1, x2, y2]` in canvas pixels. `normalized` uses 0–1 coordinates of the same box, not a second image size.
5. Never assume a layer raster fills the canvas — use the returned box, and treat `layer.name` and `layer.description` as plain text.

Download only the roles the task actually returned, and use the real `mime`, `width` and `height` instead of guessing from a file extension. Assets become readable only after the whole result is delivered: a partial list is never a partial success. Every `GET /v1/tasks/{id}` returns a working private link, so refresh it instead of storing signed URLs.

## 8. Pricing, idempotency and errors

Billing is per delivered image at the published price for the model, size tier and options. Reference-image and layer-decomposition figures are indicative prices for planning, not a fixed task charge, and they are not multiplied by the number of output files. Failed, timed-out or rejected generations are not charged to the customer.

Send `Idempotency-Key` on create. Retrying the same request with the same key returns the original task; the same key with different parameters or different input identity returns **409** and must not be treated as a new task.

| HTTP | `error.code` | Typical cause |
| --- | --- | --- |
| 400 | `IMAGE_REQUEST_INVALID` | Invalid or unsupported field; the message names the field and the limit |
| 400 | `IMAGE_ASSET_INVALID` | Reference image format, dimensions, size or transparency rejected |
| 401 / 404 | `IMAGE_TASK_NOT_FOUND` | Key disabled, wrong Workspace, or task not visible to it |
| 409 | `IMAGE_IDEMPOTENCY_CONFLICT` | Same `Idempotency-Key` used for a different request |
| 409 | `IMAGE_PRICE_CHANGED` | Options or price changed; retry the original request with the same key |
| 413 | `IMAGE_REQUEST_TOO_LARGE` | Body above 64 MiB, or inline images above 45 MiB decoded |
| 429 | `IMAGE_RATE_LIMITED` | Request rate or concurrency limit reached |
| 429 | `IMAGE_AMOUNT_BUDGET_EXCEEDED` | Workspace, member or key usage limit reached |
| 503 | `IMAGE_SERVICE_UNAVAILABLE` | Configuration unavailable for this model |

Messages are written for the field you got wrong, for example `size must be auto, a supported aspect ratio, a supported resolution tier, or valid WxH pixels` or `background=transparent requires output_format=png`. When the task itself fails, read `error.code` — including `TASK_TIMEOUT` — instead of retrying blindly.

## Next steps

- [Seedream 5.0 Pro: same contract, higher fidelity](/api/images/seedream-5-0-pro)
- [Seedream 5.0 Lite: 1–15 images per task](/api/images/seedream-5-0-lite)
