Skip to content

Seededit API Examples

Seededit 是 BytePlus 提供的图像编辑模型,支持基于参考图进行图像编辑与重绘(i2i)。

基础配置

在开始使用API之前,请确保您已经获取了API Key。如果还没有,请参考创建API Key

基础信息

  • API Base URL: https://api.agentsflare.com/byteplus/v3/images/edits
  • 认证方式: Bearer Token
  • 内容类型: application/json

请求示例

bash
curl --location --request POST 'https://api.agentsflare.com/byteplus/v3/images/edits' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer {API-KEY}' \
    --data-raw '{
        "model": "seededit-3-0-i2i-250628",
        "image": "https://example.com/source-image.jpg",
        "prompt": "将背景改为星空,保持主体不变",
        "size": "2K",
        "stream": true,
        "watermark": false
    }'
python
import requests
import json

url = "https://api.agentsflare.com/byteplus/v3/images/edits"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer {API-KEY}"
}

payload = {
    "model": "seededit-3-0-i2i-250628",
    "image": "https://example.com/source-image.jpg",
    "prompt": "将背景改为星空,保持主体不变",
    "size": "2K",
    "stream": True,
    "watermark": False
}

response = requests.post(url, headers=headers, json=payload)

if payload["stream"]:
    for line in response.iter_lines():
        if line:
            print(line.decode('utf-8'))
else:
    print(response.json())
javascript
const fetch = require('node-fetch');

const url = 'https://api.agentsflare.com/byteplus/v3/images/edits';

const payload = {
    model: 'seededit-3-0-i2i-250628',
    image: 'https://example.com/source-image.jpg',
    prompt: '将背景改为星空,保持主体不变',
    size: '2K',
    stream: true,
    watermark: false
};

const options = {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {API-KEY}'
    },
    body: JSON.stringify(payload)
};

fetch(url, options)
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

响应实例

响应中包含编辑后图片的下载地址,您可以直接访问该地址下载图片。

event: image_generation.partial_succeeded
data: {"type":"image_generation.partial_succeeded","model":"seededit-3-0-i2i-250628","created":1768273118,"image_index":0,"url":"https://example.com/edited-image.jpg","size":"2848x1600"}

event: image_generation.completed
data: {"type":"image_generation.completed","model":"seededit-3-0-i2i-250628","created":1768273118,"usage":{"generated_images":1,"output_tokens":17800,"total_tokens":17800}}

data: [DONE]

请求参数

参数类型必填说明
modelstring模型名称,如 seededit-3-0-i2i-250628
imagestring源图片 URL
promptstring编辑提示词
sizestring输出分辨率,如 2K
streamboolean是否流式返回,默认 true
watermarkboolean是否添加水印,默认 false

支持的模型

以下模型可通过本接口调用(按推荐程度排序):

  • seededit-3-0-i2i-250628 New

💡 提示

请求示例中的 model 字段可替换为上方任意模型名称。

本文档遵循 CC BY-SA 4.0 协议。