Source: https://www.tokenify.dev/docs/images/layers/

# Layer decomposition

One image in, a base and up to 16 transparent layers out, each with its position, a name and its own price.

## [What it does](https://www.tokenify.dev/docs/images/layers/#what)

You send one picture. The model returns the background with the objects removed and painted over, plus each object as its own transparent PNG, with the box it came from. Put the base image on a canvas, sort the layers by `z_index` and draw each one into its box and you have the original back — with every piece movable.

Available on `bytedance/seedream-5.0-pro`. Send it on either request shape: `layer_decomposition: true` on [the Seedream format](https://www.tokenify.dev/docs/images/seedream-api/), or the same field through `extra_body` on the OpenAI one.

```bash
curl https://api.tokenify.dev/api/v3/images/generations \
  -H "Authorization: Bearer $TOKENIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedream-5.0-pro",
    "image": "data:image/png;base64,…",
    "size": "2K",
    "layer_decomposition": true
  }'
```

```python
res = client.images.generate(
    model="bytedance/seedream-5.0-pro",
    prompt="Separate the objects on the desk",
    size="2K",
    extra_body={
        "image": f"data:image/png;base64,{source}",
        "layer_decomposition": True,
    },
)
```

## [The reply](https://www.tokenify.dev/docs/images/layers/#reply)

One flat array: the base image first at `z_index` 0, then the layers. Links by default, because 17 images inline is tens of megabytes of JSON — ask for `response_format: "b64_json"` if you would rather have the bytes.

```jsonc
{
  "model": "bytedance/seedream-5.0-pro",
  "created": 1760000000,
  "data": [
    { "url": "https://img.tokenify.dev/…", "size": "2048x2048", "output_format": "jpeg",
      "z_index": 0 },
    { "url": "https://img.tokenify.dev/…", "size": "512x480", "output_format": "png",
      "z_index": 1,
      // Where this layer sits on the base image: in its pixels, and
      // normalised to 0–1000 so it maps onto a canvas of any size.
      "bounding_box": { "absolute": [120, 200, 632, 680],
                        "normalized": [58, 97, 308, 332] },
      "name": "coffee cup",
      "description": "A white ceramic cup, upright, slightly left of centre" }
  ],
  "expires_at": 1760604800,
  "usage": { "generated_images": 2, "input_images": 1, "output_tokens": 18000, "total_tokens": 18000 }
}
```

Layers are always PNG with an alpha channel, whatever `output_format` says — that setting applies to the base image. The model decides how many layers an image has; asking for a picture with three objects in it returns three.

## [What it costs](https://www.tokenify.dev/docs/images/layers/#pricing)

Per output image — the base and each layer — at a cheaper rate than a generated image, and tiered by each output’s own pixel count. Small layers are charged the small-image rate even when the base image is large.

| Output                | Price                           |
| --------------------- | ------------------------------- |
| Up to 2.61 megapixels | $0.018                          |
| Above 2.61 megapixels | $0.036                          |
| The image you send    | $0.0024, after the first 1 free |

A typical decomposition — a 2K base image and a dozen small layers — comes to about $0.25\. Compare a generated image at $0.036.

**Credit is held for the worst case and refunded.** The model decides how many layers it finds, so 17 outputs at the dearest price your size can produce is reserved before the request is sent, and the difference comes back when the reply arrives. A balance that covers one image but not 17 is refused rather than part-served.

It is the only request whose _reservation_ is a worst case rather than the price: everything else on the image API is reserved at exactly what it will cost, because the count and the size are both in the request. One other thing refunds, for a different reason — a set of `n`images where some do not arrive is charged for the ones that did. Both are on [the pricing section](https://www.tokenify.dev/docs/images/#pricing).

## [Limits](https://www.tokenify.dev/docs/images/layers/#limits)

|                |                                                                                             |
| -------------- | ------------------------------------------------------------------------------------------- |
| Images in      | Exactly one. Several is a 400 — layers are lifted off a single picture.                     |
| Smallest input | 512×512\. Below that is a 400 before anything is sent.                                      |
| size           | A tier (1K, 1.5K, 2K) or auto. Not a width and a height: the outputs have different shapes. |
| Layers out     | Up to 16, plus the base image.                                                              |
| With n         | No. A decomposition returns one base image and its layers.                                  |
| Links          | 7 days, then deleted — the same as any other image here.                                    |

A decomposition counts as 17 against your images-a-minute limit, because that is how many it may produce.

## [Putting it back together](https://www.tokenify.dev/docs/images/layers/#recompose)

Draw the base image, then each layer in ascending `z_index` into its own box. The normalised coordinates are the ones to use if your canvas is a different size from the base image: they are thousandths of the width and height, so `[58, 97, 308, 332]` on a 2048-wide canvas is a box from 119 to 631 pixels across.

Last updated 2026-10-13.
