PixMind Docs
API 参考图片模型Seedream 5.0 Pro 图片分层

Seedream 5.0 Pro 图片分层

通过PixMind API将单张图片拆分为底图和透明图层。

将单张图片拆为底图与透明PNG图层,保留位置和堆叠顺序。

提供方

ByteDance

模型 ID

seedream-5.0-pro-layered

请求端点

POST /api-platform/v1/generations

鉴权与请求地址

API 地址为 https://aihub-admin.aimix.pro。创建和查询任务均须传入 Authorization: Bearer <PIXMIND_API_KEY>;提交 JSON 时还须设置 Content-Type: application/json。请将密钥保存在服务端环境变量中。

模型说明

  • 必须输入一张PNG/JPEG图片,提示词可省略。size支持1K、1.5K、2K、auto,分层不支持宽高比或精确像素尺寸。
  • 按包含底图在内最多17张输出预扣。最终费用为APIMart任务实际美元成本×1.15×6.77×140,合计后向上取整到整数积分;退回多预扣的差额,失败退款。API调用不要求站内订阅。
  • 通过GET /api-platform/v1/tasks/{taskId}查询;完成后返回images、layers(url、zIndex、size、outputFormat、boundingBox)及billing.settledPoints。按zIndex从小到大叠加图层。
  • 也可传model=seedream-5.0-pro并设置layer_decomposition=true;普通图片生成继续采用其独立价格。

请求参数

参数类型必填说明
modelstring是

图片分层模型ID。

默认值: seedream-5.0-pro-layered

image_urlsstring[]是

一张公开图片URL或PNG/JPEG Data URL;输入不超过30MB,总像素262144–36000000。

promptstring否

可选的分层指令。

sizestring否

输出分辨率档位。

可选值: 1K, 1.5K, 2K, auto

默认值: auto

numLayersinteger否

可选的输出数量提示,2至17(含底图);实际返回数量可能不同。

请求示例

cURL
curl --request POST 'https://aihub-admin.aimix.pro/api-platform/v1/generations' \
  -H "Authorization: Bearer $PIXMIND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "seedream-5.0-pro-layered",
  "image_urls": [
    "https://example.com/poster.png"
  ],
  "size": "2K"
}'
JavaScript
// Node.js 20+. Keep the API key on your server.
const apiKey = process.env.PIXMIND_API_KEY;
if (!apiKey) throw new Error("PIXMIND_API_KEY is required");

const response = await fetch("https://aihub-admin.aimix.pro/api-platform/v1/generations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "model": "seedream-5.0-pro-layered",
  "image_urls": [
    "https://example.com/poster.png"
  ],
  "size": "2K"
}),
  signal: AbortSignal.timeout(30_000)
});

const task = await response.json();
if (!response.ok || task.code !== 1000) {
  throw new Error(task.message ?? task.error?.message ?? `HTTP ${response.status}`);
}
console.log(task);

任务受理响应

生成任务为异步处理。请保存 taskId,并轮询 GET /api-platform/v1/tasks/{taskId},直到状态为 ready 或 failed。

200 OK
{
  "code": 1000,
  "data": {
    "id": "img_44160",
    "taskId": 44160,
    "type": "image",
    "model": "seedream-5.0-pro-layered",
    "status": "processing"
  }
}

查询任务与获取结果

将示例中的 44160 替换为受理响应中的 data.taskId,并使用同一用户所属的 Key 查询。pending、processing 为进行中状态;ready、failed 为终态。ready 时读取图片的 images 或视频的 videoUrl,failed 时读取 errorMessage。示例最多查询 60 次;超时后请保留 taskId 稍后继续查询,避免重复创建任务。结果 URL 仅为示意。

cURL
curl 'https://aihub-admin.aimix.pro/api-platform/v1/tasks/44160' \
  -H "Authorization: Bearer $PIXMIND_API_KEY"
JavaScript
// Continue after the request example above.
const taskId = task.data?.taskId;
if (!Number.isInteger(taskId)) throw new Error("Missing numeric taskId");

async function waitForTask(taskId) {
  for (let attempt = 0; attempt < 60; attempt++) {
    await new Promise(resolve => setTimeout(resolve, Math.min(2000 * 1.5 ** attempt, 10000)));
    const response = await fetch(`https://aihub-admin.aimix.pro/api-platform/v1/tasks/${taskId}`, {
      headers: { Authorization: `Bearer ${apiKey}` },
      signal: AbortSignal.timeout(30_000)
    });
    const result = await response.json();
    if (!response.ok || result.code !== 1000) {
      throw new Error(result.message ?? `HTTP ${response.status}`);
    }
    const data = result.data;
    if (data.status === "ready") return data;
    if (data.status === "failed") {
      throw new Error(data.errorMessage ?? "Generation failed");
    }
    if (!["pending", "processing"].includes(data.status)) {
      throw new Error(`Unexpected task status: ${data.status}`);
    }
  }
  throw new Error(`Polling timed out; save taskId ${taskId} to query again later`);
}

const result = await waitForTask(taskId);
console.log(result.images);
200 OK · ready
{
  "code": 1000,
  "data": {
    "taskId": 44160,
    "type": "image",
    "model": "seedream-5.0-pro-layered",
    "status": "ready",
    "progress": 100,
    "images": [
      "https://example.com/result.png"
    ]
  }
}

On this page