Seedream 5.5 Pro · 图生图
curl --request POST \
--url https://api.gravitex.ai/v1/images/generationsimport requests
url = "https://api.gravitex.ai/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.gravitex.ai/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gravitex.ai/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.gravitex.ai/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gravitex.ai/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodySeedream 5.5 Pro
Seedream 5.5 Pro · 图生图
Seedream 5.5 Pro 图生图参数、限制与可直接复制的调用示例
POST
/
v1
/
images
/
generations
Seedream 5.5 Pro · 图生图
curl --request POST \
--url https://api.gravitex.ai/v1/images/generationsimport requests
url = "https://api.gravitex.ai/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.gravitex.ai/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gravitex.ai/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.gravitex.ai/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gravitex.ai/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body简介
传入参考图片和编辑指令,支持单图编辑、多图融合、交互编辑、透明图和图层拆分。普通编辑输出 1 张图片;图层拆分返回底图和多个图层。支持为规整文字图层返回富文本 OCR。接口与认证
POST https://api.gravitex.ai/v1/images/generations
Authorization: Bearer sk-xxxxxxxxxx 和 Content-Type: application/json。图生图也可使用 /v1/images/edits,JSON 请求体相同。认证和接口规则见 参数与计费。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | dola-seedream-5-5-261028 |
prompt | string | 编辑必填 | 描述如何修改参考图;图层拆分时可省略 |
image | string / string[] | 是 | 参考图片 URL 或 Base64;普通编辑最多 10 张,图层拆分只能 1 张 |
size | string | 否 | 普通编辑默认 2K,支持 1K、1.5K、2K 或自定义 宽x高;图层拆分默认 auto |
output_format | string | 否 | jpeg / png,默认 png;透明图使用 png |
response_format | string | 否 | url / b64_json,默认 url |
watermark | boolean | 否 | 默认 true;不添加水印时传 false |
background | string | 否 | 默认 auto,支持 transparent / opaque;图层拆分不能传此字段 |
optimize_prompt_options | object | 否 | mode 仅支持 standard |
layer_decomposition | boolean | 否 | 默认 false;传 true 开启图层拆分 |
layer_decomposition_options | object | 否 | 仅拆分模式生效;max_images 默认 30(范围 2–100,含底图),text_recognition 默认 false |
n 传 1 或不传;需要多张普通生成结果时请分别请求。safety_identifier、完整默认值和参数解释见 通用参数。两版均不支持 quality、组图、流式输出与联网搜索。
prompt
用于描述生成内容,或指定图层拆分意图。- 图片生成场景:必填。图生图时,
prompt同时说明怎么使用和修改参考图。 - 图层拆分场景:可选。用于指定要拆出的元素;不传时模型自动识别图中所有主要元素并拆成独立图层。
- 字数建议:中文不超过 300 字,英文不超过 600 词。字数过多时信息容易分散,模型可能忽略细节。
{
"prompt": "一只戴墨镜的柯基在海边冲浪,插画风格,竖版海报"
}
<bbox>x1 y1 x2 y2</bbox> 指定区域,官方示例用的是 [0, 1000] 的归一化坐标(左上角为原点);也可以直接在参考图上画框、箭头或草图,再在提示词里说明怎么处理标记区域。
{
"prompt": "把 <bbox>120 560 380 900</bbox> 区域里的杯子换成一盆绿植,其余内容保持不变"
}
image
参考图,支持单个字符串或字符串数组。每张图可以是:- 图片 URL:必须能被服务端访问,不能只在本地浏览器有效。
- Base64:格式为
data:image/<图片格式>;base64,<Base64 编码>,<图片格式>需小写,如data:image/png;base64,iVBORw0...。
{
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg"
}
{
"image": [
"https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=1024&fm=jpg"
]
}
| 限制项 | 要求 |
|---|---|
| 格式 | jpeg、png、webp、bmp、tiff、gif、heic、heif |
| 宽高比(宽 / 高) | [1/16, 16] |
| 宽、高 | 均大于 14 px |
| 单张大小 | 不超过 30 MB |
| 总像素(宽 × 高) | [196, 6000×6000] |
| 限制项 | 要求 |
|---|---|
| 格式 | png、jpeg |
| 宽高比(宽 / 高) | [1/16, 16] |
| 单张大小 | 不超过 30 MB |
| 总像素(宽 × 高) | [512×512, 6000×6000] |
总像素是对宽 × 高乘积的限制,不是对宽或高单独限制。
size
普通编辑的尺寸规则见 通用尺寸说明。图层拆分仅支持1K、1.5K、2K、auto,默认 auto;不能传自定义像素尺寸。底图和图层的缩放规则见 尺寸说明。
background
控制输出图片是否带透明通道。| 取值 | 说明 |
|---|---|
auto | 模型根据提示词和 output_format 自动判断,默认值;output_format 为 jpeg 时不带透明通道 |
transparent | 输出带透明通道的 RGBA 图 |
opaque | 输出不带透明通道的 RGB 图 |
- 图生图支持
transparent,最多 10 张参考图,参考图不需要带透明通道。 - 实际是否透明以响应里的
data[].background为准,可能和请求值不同。
transparent不能和output_format: "jpeg"同时用,否则报错。- 图层拆分场景不能传
background,传了报错。
layer_decomposition
是否开启图层拆分。| 取值 | 说明 |
|---|---|
true | 图层拆分模式:把输入图拆成 1 张底图和多个图层 |
false | 图片生成模式,默认值 |
image必填,且只能传 1 张。- 任一图层生成失败,整个请求失败,不支持部分成功。
- 提示词要求的图层数超过上限时,部分图层信息可能丢失。
- 响应
data中会返回每个图层的叠放顺序(z_index)、名称(name)、描述(description)和边界框(bounding_box),开启 OCR 时还会返回text_recognition,见 返回字段。 - 底图和每个图层都算一张生成图片,计入
usage.generated_images。
layer_decomposition_options
图层拆分配置,仅layer_decomposition 为 true 时生效。
| 字段 | 类型 | 默认值 | 取值范围 | 说明 |
|---|---|---|---|---|
max_images | integer | 30 | [2, 100] | 本次最多输出的图片总数,含底图 |
text_recognition | boolean | false | true / false | 是否对规整文字图层额外返回富文本 OCR 结果(data[].text_recognition) |
{
"layer_decomposition_options": {
"max_images": 20,
"text_recognition": true
}
}
- 提示词没说怎么拆或描述不清时,模型会结合
max_images和图片复杂度规划拆分结果;max_images越大,拆得通常越细。 - 上游按
max_images预占 IPM(每分钟图片数)限额,实际生成不足时释放多占的额度。 - 非文字图层,以及艺术字、手写体等非规整文字图层,不返回 OCR 结果。支持识别的字体见官方 Seedream 5.5 OCR 支持字体。
调用示例
每个示例提供可直接复制的完整 JSON 请求 body 和对应 cURL。图片输入使用无需登录的公网 URL;使用 cURL 时,请将sk-xxxxxxxxxx 替换为自己的 API Key。响应中的图片 URL 仅用于展示返回结构,不是请求素材。
单图生图
{
"model": "dola-seedream-5-5-261028",
"prompt": "保持参考图中狗的外形不变,把背景换成雪山",
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"size": "2K"
}
curl --location 'https://api.gravitex.ai/v1/images/generations' \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "dola-seedream-5-5-261028",
"prompt": "保持参考图中狗的外形不变,把背景换成雪山",
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"size": "2K"
}'
多图融合
{
"model": "dola-seedream-5-5-261028",
"prompt": "将图 1 中的狗放到图 2 的湖畔场景中,保持狗的外形,统一光线与透视",
"image": [
"https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=1024&fm=jpg"
],
"size": "2K"
}
curl --location 'https://api.gravitex.ai/v1/images/generations' \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "dola-seedream-5-5-261028",
"prompt": "将图 1 中的狗放到图 2 的湖畔场景中,保持狗的外形,统一光线与透视",
"image": [
"https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=1024&fm=jpg"
],
"size": "2K"
}'
交互编辑
{
"model": "dola-seedream-5-5-261028",
"prompt": "只编辑 <bbox>0 0 1000 300</bbox> 区域,将该区域的背景改为浅蓝色,保持狗和其余区域不变",
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"size": "2K"
}
curl --location 'https://api.gravitex.ai/v1/images/generations' \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "dola-seedream-5-5-261028",
"prompt": "只编辑 <bbox>0 0 1000 300</bbox> 区域,将该区域的背景改为浅蓝色,保持狗和其余区域不变",
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"size": "2K"
}'
图生透明图
{
"model": "dola-seedream-5-5-261028",
"prompt": "提取参考图中的狗,移除背景,输出透明背景图片",
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"background": "transparent",
"output_format": "png",
"size": "2K"
}
curl --location 'https://api.gravitex.ai/v1/images/generations' \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "dola-seedream-5-5-261028",
"prompt": "提取参考图中的狗,移除背景,输出透明背景图片",
"image": "https://images.unsplash.com/photo-1517849845537-4d257902454a?w=1024&fm=jpg",
"background": "transparent",
"output_format": "png",
"size": "2K"
}'
图层拆分与 OCR
{
"model": "dola-seedream-5-5-261028",
"prompt": "将图片中的规整文字按段落拆成独立图层,并识别文字内容和样式",
"image": "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png",
"layer_decomposition": true,
"layer_decomposition_options": {
"max_images": 20,
"text_recognition": true
},
"size": "2K",
"output_format": "jpeg"
}
curl --location 'https://api.gravitex.ai/v1/images/generations' \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "dola-seedream-5-5-261028",
"prompt": "将图片中的规整文字按段落拆成独立图层,并识别文字内容和样式",
"image": "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png",
"layer_decomposition": true,
"layer_decomposition_options": {
"max_images": 20,
"text_recognition": true
},
"size": "2K",
"output_format": "jpeg"
}'
自动图层拆分
{
"model": "dola-seedream-5-5-261028",
"image": "https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=1024&fm=jpg",
"layer_decomposition": true,
"safety_identifier": "5f4dcc3b5aa765d61d8327deb882cf99"
}
curl --location 'https://api.gravitex.ai/v1/images/generations' \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "dola-seedream-5-5-261028",
"image": "https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=1024&fm=jpg",
"layer_decomposition": true,
"safety_identifier": "5f4dcc3b5aa765d61d8327deb882cf99"
}'
prompt,模型自动识别并拆分所有主要元素;size 默认 auto,max_images 默认 30。
成功返回
普通编辑的基础响应与文生图一致,usage.input_images 按实际输入图片数统计,见 基础响应。以下为图层拆分响应的节选,仅展示底图和 1 个图层。usage 为完整响应的用量,因此 generated_images 不等于本节选中的图片数;URL 仅作结构示意:
{
"model": "dola-seedream-5-5-261028",
"created": 1784696685,
"data": [
{
"url": "https://example.com/base.jpeg",
"size": "2048x2048",
"output_format": "jpeg",
"z_index": 0
},
{
"url": "https://example.com/layer-1.png",
"size": "1273x265",
"output_format": "png",
"z_index": 1,
"bounding_box": {
"absolute": [383, 120, 1655, 384],
"normalized": [187, 59, 808, 188]
},
"name": "Seedream标题文字",
"description": "黄色大号衬线字体的Seedream标题文字",
"text_recognition": {
"text": "Seedream",
"lines": [
{
"bounding_box": {
"absolute": [383, 120, 1655, 384],
"normalized": [187, 59, 808, 188]
},
"runs": [
{
"text": "Seedream",
"style": {
"similar_font_family": "Playfair Display",
"foreground_color": "#F5C518",
"bold": true,
"italic": false,
"underline": false,
"strikethrough": false,
"shadow": false,
"translucent": false
}
}
]
}
]
}
}
],
"usage": {
"input_images": 1,
"generated_images": 8,
"output_tokens": 23107,
"total_tokens": 23107
}
}
返回字段
除 基础响应字段 外,图层拆分额外返回:| 字段 | 类型 | 说明 |
|---|---|---|
data[].z_index | integer | 图层叠放顺序,底图为 0,图层从 1 递增,越大越靠上(仅图层拆分) |
data[].name | string | 图层名称,由模型生成(仅图层拆分) |
data[].description | string | 图层描述,比 name 更详细(仅图层拆分) |
data[].bounding_box.absolute | integer[4] | 图层在输出底图中的像素坐标 [left, top, right, bottom];底图不返回(仅图层拆分) |
data[].bounding_box.normalized | integer[4] | 同上,换算到 [0, 1000] 的归一化坐标;底图不返回(仅图层拆分) |
data[].text_recognition | object | 富文本 OCR 结果,字段见下表;仅开启 text_recognition 且当前图层是规整文字时返回 |
| 字段 | 类型 | 说明 |
|---|---|---|
text | string | 该文字图层的完整纯文本,从上到下、从左到右,行间用 \n 分隔 |
lines[] | array | 文字行,多行文字对应多个元素 |
lines[].bounding_box.absolute / .normalized | integer[4] | 该行在输出底图中的坐标,规则同 data[].bounding_box |
lines[].runs[] | array | 该行的样式片段;整行样式一致时只有 1 个元素 |
lines[].runs[].text | string | 片段文本,不含换行符 |
lines[].runs[].style.similar_font_family | string | 最相似的字体名;识别不出或置信度不足时为 unknown |
lines[].runs[].style.foreground_color | string | 文字颜色,大写 #RRGGBB,不含透明度 |
lines[].runs[].style.bold | boolean | 是否粗体 |
lines[].runs[].style.italic | boolean | 是否斜体(仅字形本身倾斜;图层整体旋转或透视倾斜不算) |
lines[].runs[].style.underline | boolean | 是否带下划线(独立分割线、表格线不算) |
lines[].runs[].style.strikethrough | boolean | 是否带删除线 |
lines[].runs[].style.shadow | boolean | 是否带明显投影、阴影或发光偏移 |
lines[].runs[].style.translucent | boolean | 文字本身是否半透明(实心浅色字不算) |
样式信息由模型自动识别,可能与原图的精确属性有偏差。
还原图层:用
absolute 坐标时,把图层缩放到 (right - left) × (bottom - top),放到底图的 (left, top);用 normalized 坐标还原到 W × H 的任意画布时,左上角为 (left / 1000 × W, top / 1000 × H)。多个图层按 z_index 从小到大叠放。data[].url 是临时地址,24 小时后失效。收到响应后请立即下载并转存到自己的对象存储。