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

# 原生 RGBA 图片（透明背景）

> 由文字或参考图直接生成带透明通道的 RGBA 图片，适用于贴纸、图标、商品素材等需要透明背景的场景。

Seedream 5.5 可以通过文生图和图生图直接生成带透明通道的 RGBA 图片，不需要再做抠图。把 `background` 设为 `transparent`、`output_format` 设为 `png` 即可。

| 能力 | Seedream 5.5 |
| - | - |
| 文生 RGBA | 支持 |
| 图生 RGBA | 支持，最多 10 张参考图 |
| 对输入图片的要求 | 参考图不需要带透明通道 |

[观看演示视频](https://arkdocs-en.tos-ap-southeast-1.volces.com/videos/image-generation/seedream-5-5-rgba-demo-en.mp4)

## 文生 RGBA

不传 `image`，在提示词里描述主体，并说明需要透明背景。

| 提示词 | 输出 |
| - | - |
| 一个圣诞主题的透明亚克力立牌……透明背景。（完整提示词见下方请求） | ![文生 RGBA 输出](https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/seedream-5-5-text-to-image-output.png) |

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/api/v3/images/generations" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-5.5",
    "prompt": "一个圣诞主题的透明亚克力立牌，矩形轮廓，四周有一圈细白边以突出透明材质。采用剪贴簿拼贴风格：中间是一张带金色边缘的红绿双色黑胶唱片，周围环绕由橡果叶和松枝组成的立体圣诞花环，花环上点缀手绘的红色浆果、金色四角星、驯鹿和雪花贴纸。下方叠加极简的白色音乐播放器界面，包含播放/暂停按钮、进度条（01:24 / 04:32）和音量图标。配色为复古红、森林绿、香槟金和米白色，偶尔出现亚克力厚度折射的高光，呈现真实的产品质感。透明背景。",
    "size": "2K",
    "output_format": "png",
    "background": "transparent",
    "response_format": "url",
    "watermark": true
  }'
```

```python Python theme={null}
import os

import requests

URL = "https://api.dreamto.ai/api/v3/images/generations"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "seedream-5.5",
    "prompt": "一个圣诞主题的透明亚克力立牌，矩形轮廓，四周有一圈细白边以突出透明材质。采用剪贴簿拼贴风格：中间是一张带金色边缘的红绿双色黑胶唱片，周围环绕由橡果叶和松枝组成的立体圣诞花环，花环上点缀手绘的红色浆果、金色四角星、驯鹿和雪花贴纸。下方叠加极简的白色音乐播放器界面，包含播放/暂停按钮、进度条（01:24 / 04:32）和音量图标。配色为复古红、森林绿、香槟金和米白色，偶尔出现亚克力厚度折射的高光，呈现真实的产品质感。透明背景。",
    "size": "2K",
    "output_format": "png",
    "background": "transparent",
    "response_format": "url",
    "watermark": True
}

result = requests.post(URL, headers=HEADERS, json=payload, timeout=600).json()
for image in result["data"]:
    print(image["url"])
```

```python OpenAI SDK theme={null}
import os

from openai import OpenAI

client = OpenAI(base_url="https://api.dreamto.ai/api/v3", api_key=os.environ["DREAMTO_API_KEY"])

response = client.images.generate(
    model="seedream-5.5",
    prompt="一个圣诞主题的透明亚克力立牌，矩形轮廓，四周有一圈细白边以突出透明材质。采用剪贴簿拼贴风格：中间是一张带金色边缘的红绿双色黑胶唱片，周围环绕由橡果叶和松枝组成的立体圣诞花环，花环上点缀手绘的红色浆果、金色四角星、驯鹿和雪花贴纸。下方叠加极简的白色音乐播放器界面，包含播放/暂停按钮、进度条（01:24 / 04:32）和音量图标。配色为复古红、森林绿、香槟金和米白色，偶尔出现亚克力厚度折射的高光，呈现真实的产品质感。透明背景。",
    size="2K",
    output_format="png",
    background="transparent",
    response_format="url",
    extra_body={
        "watermark": True,
    },
)
for item in response.data:
    print(item)
```

## 图生 RGBA

用 `image` 传一张或最多 10 张参考图。下面的例子从两张图片中提取贴纸，放到同一张透明背景图片里。

| 输入图 1 | 输入图 2 | 输出 |
| - | - | - |
| ![第一张参考图](https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test3.png) | ![第二张参考图](https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test4.png) | ![由两张参考图生成的透明背景图片](https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/seedream-5-5-transparent-stickers-output-20261103.png) |

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/api/v3/images/generations" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-5.5",
    "prompt": "分别提取图1和图2中的贴纸元素，把提取出的所有贴纸放在同一张透明背景图片中。保留每张贴纸原有的文字、颜色、形状和细节，去掉贴纸以外的所有背景内容。贴纸之间分开排列、互不重叠，边缘清晰完整。",
    "image": [
      "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test3.png",
      "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test4.png"
    ],
    "size": "2K",
    "output_format": "png",
    "background": "transparent",
    "response_format": "url",
    "watermark": true
  }'
```

```python Python theme={null}
import os

import requests

URL = "https://api.dreamto.ai/api/v3/images/generations"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "seedream-5.5",
    "prompt": "分别提取图1和图2中的贴纸元素，把提取出的所有贴纸放在同一张透明背景图片中。保留每张贴纸原有的文字、颜色、形状和细节，去掉贴纸以外的所有背景内容。贴纸之间分开排列、互不重叠，边缘清晰完整。",
    "image": [
        "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test3.png",
        "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test4.png"
    ],
    "size": "2K",
    "output_format": "png",
    "background": "transparent",
    "response_format": "url",
    "watermark": True
}

result = requests.post(URL, headers=HEADERS, json=payload, timeout=600).json()
for image in result["data"]:
    print(image["url"])
```

```python OpenAI SDK theme={null}
import os

from openai import OpenAI

client = OpenAI(base_url="https://api.dreamto.ai/api/v3", api_key=os.environ["DREAMTO_API_KEY"])

response = client.images.generate(
    model="seedream-5.5",
    prompt="分别提取图1和图2中的贴纸元素，把提取出的所有贴纸放在同一张透明背景图片中。保留每张贴纸原有的文字、颜色、形状和细节，去掉贴纸以外的所有背景内容。贴纸之间分开排列、互不重叠，边缘清晰完整。",
    size="2K",
    output_format="png",
    background="transparent",
    response_format="url",
    extra_body={
        "image": [
            "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test3.png",
            "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test4.png"
        ],
        "watermark": True,
    },
)
for item in response.data:
    print(item)
```

## 响应

响应中的 `data[].background` 是图片**实际**的透明类型：包含透明或半透明像素时为 `transparent`，整张不透明时为 `opaque`，可能与请求值不同。

```json theme={null}
{
  "model": "seedream-5.5",
  "created": 1794846488,
  "data": [
    {
      "url": "https://files.dreamto.ai/images/seedream_3d8a51c7.png",
      "size": "2048x2048",
      "output_format": "png",
      "background": "transparent"
    }
  ],
  "usage": {
    "input_images": 2,
    "generated_images": 1,
    "output_tokens": 16384,
    "total_tokens": 16384
  }
}
```

## 注意事项

* `background` 为 `transparent` 时，`output_format` 必须是 `png`；设为 `jpeg` 会返回 400。
* `background` 的默认值是 `auto`：由模型根据提示词和 `output_format` 决定是否输出透明通道；想确保得到透明背景请显式传 `transparent`，想确保不透明请传 `opaque`。
* `background` 只用于图片生成。图层分解会自动返回透明 PNG 图层，传 `background` 会返回 400，见 [精细图层分解](https://docs.dreamto.ai/image/models/seedream-5-5/layer-decomposition.md)。
* 计费与普通图片生成相同：按输出图片的像素档位计一张，每张参考图另计输入图片。


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