Query image generation task
curl --request GET \
--url https://api.siray.ai/v1/images/generations/async/{task_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.siray.ai/v1/images/generations/async/{task_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.siray.ai/v1/images/generations/async/{task_id}', 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.siray.ai/v1/images/generations/async/{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.siray.ai/v1/images/generations/async/{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.siray.ai/v1/images/generations/async/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.siray.ai/v1/images/generations/async/{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": "video_69196fafcc9c8190acccf32e9b560c3f0da8a6d1948cfaa5",
"status": "SUCCESS",
"progress": "100%",
"outputs": [
"https://api.siray.ai/redirect/example-output"
],
"outputs_metadata": [
{
"url": "https://api.siray.ai/redirect/example-background",
"size": "1024x1024",
"output_format": "jpeg",
"z_index": 0
},
{
"url": "https://api.siray.ai/redirect/example-layer",
"size": "951x918",
"output_format": "png",
"z_index": 1,
"bounding_box": {
"absolute": [
43,
55,
994,
973
],
"normalized": [
42,
54,
971,
950
]
},
"name": "foreground subject",
"description": "Foreground subject extracted from the image"
}
],
"start_time": 1763274702,
"finish_time": 1763274838,
"submit_time": 1763274672,
"fail_code": "",
"fail_reason": ""
}
}API documentation
Image Task Status API
Check asynchronous t2i/i2i generation tasks and retrieve the generated image URLs.
GET
/
v1
/
images
/
generations
/
async
/
{task_id}
Query image generation task
curl --request GET \
--url https://api.siray.ai/v1/images/generations/async/{task_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.siray.ai/v1/images/generations/async/{task_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.siray.ai/v1/images/generations/async/{task_id}', 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.siray.ai/v1/images/generations/async/{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.siray.ai/v1/images/generations/async/{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.siray.ai/v1/images/generations/async/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.siray.ai/v1/images/generations/async/{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": "video_69196fafcc9c8190acccf32e9b560c3f0da8a6d1948cfaa5",
"status": "SUCCESS",
"progress": "100%",
"outputs": [
"https://api.siray.ai/redirect/example-output"
],
"outputs_metadata": [
{
"url": "https://api.siray.ai/redirect/example-background",
"size": "1024x1024",
"output_format": "jpeg",
"z_index": 0
},
{
"url": "https://api.siray.ai/redirect/example-layer",
"size": "951x918",
"output_format": "png",
"z_index": 1,
"bounding_box": {
"absolute": [
43,
55,
994,
973
],
"normalized": [
42,
54,
971,
950
]
},
"name": "foreground subject",
"description": "Foreground subject extracted from the image"
}
],
"start_time": 1763274702,
"finish_time": 1763274838,
"submit_time": 1763274672,
"fail_code": "",
"fail_reason": ""
}
}Overview
When you submit an image generation task (text-to-image or image-to-image) you receive atask_id. Use this endpoint to poll the execution lifecycle until the task either completes successfully or fails.
Query every 3–5 seconds to maintain responsiveness without exceeding rate limits.
Endpoint
GET https://api.siray.ai/v1/images/generations/async/{task_id}
Authorization: Bearer <SIRAY_API_TOKEN>
| Name | Description |
|---|---|
task_id | ID returned in the async submission response. |
Response structure
{
"code": "success",
"message": "",
"data": {
"task_id": "image_a8813a4b4c9",
"status": "SUCCESS",
"progress": "100%",
"outputs": [
"https://api.siray.ai/redirect/example-output"
],
"outputs_metadata": [
{
"url": "https://api.siray.ai/redirect/example-background",
"size": "1024x1024",
"output_format": "jpeg",
"z_index": 0
},
{
"url": "https://api.siray.ai/redirect/example-layer",
"size": "951x918",
"output_format": "png",
"z_index": 1,
"bounding_box": {
"absolute": [43, 55, 994, 973],
"normalized": [42, 54, 971, 950]
},
"name": "foreground subject",
"description": "Foreground subject extracted from the image"
}
],
"start_time": 1763274702,
"finish_time": 1763274838,
"submit_time": 1763274672,
"fail_code": "",
"fail_reason": ""
}
}
Fields
code/message: Service-level indicators for the request outcome.data.task_id: Echoes the submitted task identifier.data.status: Current lifecycle state — see the table below.data.progress: Human-readable percentage for UI display.data.outputs: Array of public URLs that host the generated image assets (present whenstatusisSUCCESS).data.outputs_metadata: Per-layer metadata for layered image outputs. Only the Layerize model returns this field; see Layered image metadata below.data.fail_code: Machine-readable failure code whenstatusisFAILURE. See fail_code.data.fail_reason: Populated if generation fails.data.submit_time,data.start_time,data.finish_time: Unix timestamps for auditing latency.
Layered image metadata (Layerize)
When the Layerize model returns a layered image,data.outputs_metadata describes each layer while data.outputs still holds the composed image URLs.
| Field | Type | Description |
|---|---|---|
url | string | Public URL to the layer asset. |
size | string | Layer dimensions, e.g. 1024x1024. |
output_format | string | File format, e.g. jpeg or png. |
z_index | integer | Stacking order of the layer; 0 is the bottom-most layer. |
bounding_box.absolute | integer[4] | Bounding box in pixels as [x1, y1, x2, y2]. |
bounding_box.normalized | integer[4] | Bounding box scaled to 0–1000 as [x1, y1, x2, y2]. |
name | string | Layer name. |
description | string | Description of the layer content. |
Status values
| Status | Meaning |
|---|---|
NOT_START | Task accepted but preprocessing has not started yet. |
SUBMITTED | Request stored and waiting to enter the queue. |
QUEUED | Task is scheduled and waiting for compute resources. |
IN_PROGRESS | Generation is currently running. |
SUCCESS | Outputs are ready; download them via the URLs in outputs. |
FAILURE | Irrecoverable error; inspect fail_code and fail_reason for remediation steps. |
Usage example
curl -X GET "https://api.siray.ai/v1/images/generations/async/${TASK_ID}" \
-H "Authorization: Bearer ${SIRAY_API_TOKEN}"
OncestatusbecomesSUCCESS, fetch the image(s) via the URLs inoutputs. If the task fails, retry only after resolving the reportedfail_code/fail_reason.
Response
200 - application/json
Task status and (if available) generated outputs
