Seedream
Retrieve a Seedream image task
Use CometAPI GET /v1/images/generations/ to poll an async Seedream image generation task and retrieve final image data.
GET
/
v1
/
images
/
generations
/
{task_id}
cURL
curl "https://api.cometapi.com/v1/images/generations/<task_id>" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import time
import requests
task_id = "<task_id>"
headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}
for _ in range(60):
response = requests.get(
f"https://api.cometapi.com/v1/images/generations/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = task["data"]["status"]
print(status)
if status == "success":
print(task["data"]["data"][0]["url"])
break
if status == "failure":
raise RuntimeError(task["data"].get("fail_reason", "Seedream task failed"))
time.sleep(5)
else:
raise TimeoutError("Seedream task did not finish in time")
const taskId = "<task_id>";
const headers = { Authorization: `Bearer ${process.env.COMETAPI_KEY}` };
for (let attempt = 0; attempt < 60; attempt += 1) {
const response = await fetch(
`https://api.cometapi.com/v1/images/generations/${taskId}`,
{ headers, signal: AbortSignal.timeout(30_000) },
);
if (!response.ok) throw new Error(await response.text());
const task = await response.json();
const status = task.data.status;
console.log(status);
if (status === "success") {
console.log(task.data.data[0].url);
break;
}
if (status === "failure") {
throw new Error(task.data.fail_reason ?? "Seedream task failed");
}
if (attempt === 59) throw new Error("Seedream task did not finish in time");
await new Promise((resolve) => setTimeout(resolve, 5000));
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/v1/images/generations/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.cometapi.com/v1/images/generations/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/v1/images/generations/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/v1/images/generations/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": "success",
"message": "",
"data": {
"task_id": "<task_id>",
"status": "pending",
"data": []
}
}Use this endpoint after you create a Seedream image with
POST /v1/images/generations and async: true. The create request returns data.task_id, and this endpoint returns the task state plus final image data when the task succeeds.
This workflow supports doubao-seedream-4-0-250828, doubao-seedream-4-5-251128, doubao-seedream-5-0-260128, and seedream-5-0-pro-260628. Check the Models page or /v1/models for account availability.
Poll a Seedream image task
1
Create the task
Send
POST /v1/images/generations with async: true, then store data.task_id.2
Poll the task
Call this endpoint with the stored task ID until
data.status is success or failure.3
Read the image data
When
data.status is success, read data.data[0].url. Other result fields, including b64_json and revised_prompt, can be empty in the URL workflow.Download or transfer the returned image promptly. The result URL is temporary; do not rely on a fixed lifetime.
Status values
pending: The task is queued or generating.success: The task finished anddata.datacontains the generated image data.failure: The task failed. Checkdata.fail_reasonwhen it is returned.
Authorizations
Bearer token authentication. Use your CometAPI key.
Path Parameters
Task ID returned in data.task_id by the async create request.
Last modified on July 31, 2026
⌘I
cURL
curl "https://api.cometapi.com/v1/images/generations/<task_id>" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import time
import requests
task_id = "<task_id>"
headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}
for _ in range(60):
response = requests.get(
f"https://api.cometapi.com/v1/images/generations/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = task["data"]["status"]
print(status)
if status == "success":
print(task["data"]["data"][0]["url"])
break
if status == "failure":
raise RuntimeError(task["data"].get("fail_reason", "Seedream task failed"))
time.sleep(5)
else:
raise TimeoutError("Seedream task did not finish in time")
const taskId = "<task_id>";
const headers = { Authorization: `Bearer ${process.env.COMETAPI_KEY}` };
for (let attempt = 0; attempt < 60; attempt += 1) {
const response = await fetch(
`https://api.cometapi.com/v1/images/generations/${taskId}`,
{ headers, signal: AbortSignal.timeout(30_000) },
);
if (!response.ok) throw new Error(await response.text());
const task = await response.json();
const status = task.data.status;
console.log(status);
if (status === "success") {
console.log(task.data.data[0].url);
break;
}
if (status === "failure") {
throw new Error(task.data.fail_reason ?? "Seedream task failed");
}
if (attempt === 59) throw new Error("Seedream task did not finish in time");
await new Promise((resolve) => setTimeout(resolve, 5000));
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/v1/images/generations/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.cometapi.com/v1/images/generations/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/v1/images/generations/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/v1/images/generations/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": "success",
"message": "",
"data": {
"task_id": "<task_id>",
"status": "pending",
"data": []
}
}