cURL
curl --request POST \
--url https://api.ttapi.io/sd/api/v3/images/generations \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"model": "doubao-seedream-5-0-pro-260628",
"prompt": "充满活力的特写肖像,色彩丰富",
"size": "2K",
"watermark": false
}
'import requests
url = "https://api.ttapi.io/sd/api/v3/images/generations"
payload = {
"model": "doubao-seedream-5-0-pro-260628",
"prompt": "充满活力的特写肖像,色彩丰富",
"size": "2K",
"watermark": False
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'doubao-seedream-5-0-pro-260628',
prompt: '充满活力的特写肖像,色彩丰富',
size: '2K',
watermark: false
})
};
fetch('https://api.ttapi.io/sd/api/v3/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.ttapi.io/sd/api/v3/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'doubao-seedream-5-0-pro-260628',
'prompt' => '充满活力的特写肖像,色彩丰富',
'size' => '2K',
'watermark' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ttapi.io/sd/api/v3/images/generations"
payload := strings.NewReader("{\n \"model\": \"doubao-seedream-5-0-pro-260628\",\n \"prompt\": \"充满活力的特写肖像,色彩丰富\",\n \"size\": \"2K\",\n \"watermark\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.ttapi.io/sd/api/v3/images/generations")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"doubao-seedream-5-0-pro-260628\",\n \"prompt\": \"充满活力的特写肖像,色彩丰富\",\n \"size\": \"2K\",\n \"watermark\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/sd/api/v3/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"doubao-seedream-5-0-pro-260628\",\n \"prompt\": \"充满活力的特写肖像,色彩丰富\",\n \"size\": \"2K\",\n \"watermark\": false\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"created": 123,
"data": [
{
"url": "<string>",
"size": "<string>"
}
],
"usage": {
"generated_images": 123,
"total_tokens": 123
}
}Seedream
文生图(同步)
文生图(同步) - 直接返回生成结果
POST
/
sd
/
api
/
v3
/
images
/
generations
cURL
curl --request POST \
--url https://api.ttapi.io/sd/api/v3/images/generations \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"model": "doubao-seedream-5-0-pro-260628",
"prompt": "充满活力的特写肖像,色彩丰富",
"size": "2K",
"watermark": false
}
'import requests
url = "https://api.ttapi.io/sd/api/v3/images/generations"
payload = {
"model": "doubao-seedream-5-0-pro-260628",
"prompt": "充满活力的特写肖像,色彩丰富",
"size": "2K",
"watermark": False
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'doubao-seedream-5-0-pro-260628',
prompt: '充满活力的特写肖像,色彩丰富',
size: '2K',
watermark: false
})
};
fetch('https://api.ttapi.io/sd/api/v3/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.ttapi.io/sd/api/v3/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'doubao-seedream-5-0-pro-260628',
'prompt' => '充满活力的特写肖像,色彩丰富',
'size' => '2K',
'watermark' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ttapi.io/sd/api/v3/images/generations"
payload := strings.NewReader("{\n \"model\": \"doubao-seedream-5-0-pro-260628\",\n \"prompt\": \"充满活力的特写肖像,色彩丰富\",\n \"size\": \"2K\",\n \"watermark\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.ttapi.io/sd/api/v3/images/generations")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"doubao-seedream-5-0-pro-260628\",\n \"prompt\": \"充满活力的特写肖像,色彩丰富\",\n \"size\": \"2K\",\n \"watermark\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/sd/api/v3/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"doubao-seedream-5-0-pro-260628\",\n \"prompt\": \"充满活力的特写肖像,色彩丰富\",\n \"size\": \"2K\",\n \"watermark\": false\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"created": 123,
"data": [
{
"url": "<string>",
"size": "<string>"
}
],
"usage": {
"generated_images": 123,
"total_tokens": 123
}
}这是 Seedream 图片生成 API 的文生图同步接口。仅通过
prompt 生成图片,不传入任何媒体文件。请求后直接返回生成结果,无需额外查询。
同步接口说明
同步接口请求后直接返回生成结果,无需通过查询接口轮询。以下所有场景均使用同一接口POST /sd/api/v3/images/generations,仅参数不同:
| 使用场景 | 参数差异 | 说明 |
|---|---|---|
| 文生图 | 仅需 prompt | 仅通过文本提示词生成图片 |
| 图生图 | 需 prompt + image(单张) | 基于单张参考图片进行风格转换或内容编辑,支持透明背景 |
| 多图融合 | 需 prompt + image(2-10 张数组) | 基于多张参考图融合生成新图片 |
| 图层拆分 | 需 prompt + image + layer_decomposition: true | 将图片拆解为底图和多个图层,仅 5.0 pro / flash 支持 |
| 交互编辑 | 需 prompt + image | 通过坐标、框选等方式精准编辑图片,仅 5.0 pro / flash 支持 |
推荐异步接口:生产环境建议使用异步接口(返回
id,通过查询接口获取结果),支持 webhook 回调通知,更适合大批量生成场景。请求体
application/json
模型名称。
可用选项:
doubao-seedream-5-0-pro-260628, doubao-seedream-5-0-flash-260915 文本提示词。
图像尺寸。5.0 pro/flash 可选:1K、1.5K、2K(默认 2K),或指定像素值。
可用选项:
1K, 1.5K, 2K 输出图像格式。
可用选项:
png, jpeg 返回格式。url 返回图片下载链接(24h 有效),b64_json 返回 Base64 编码。
可用选项:
url, b64_json 图片透明通道设置。transparent=透明背景(仅图生图场景),opaque=不透明背景。仅 5.0 pro/flash 支持。
可用选项:
transparent, opaque 是否添加水印。true=右下角显示「AI 生成」,false=不添加。
可用选项:
true, false 示例:
false
提示词优化配置
Show child attributes
Show child attributes
最后修改于 2026年10月23日