Text to Image
Generating high-quality images from natural language descriptions is easy with SIRAYA Model Router. Our unified API allows you to access various state-of-the-art image generation models using a single interface.
https://llm.siraya.ai/v1/images/generations
Header
Bearer <API_KEY>).
Body
gpt-image-2, imagen-4.0-generate-001).
1024x1024, 1792x1024, 1024x1792).
standard, hd, low, medium, high.
vivid, natural.
b64_json, url.
transparent, opaque, auto.
jpeg and webp formats.
low, auto.
auto, disabled. Supported by Seedream models.
false, the request waits for generation to finish and returns the completed image. When true, it returns immediately with an image id while generation runs in the background. There's no status/poll endpoint for images — pass callbackUrl to receive the result. See Asynchronous generation.
async is true. A URL the router will POST to once generation completes (or fails). This is the only way to retrieve the result of an async image job.
import requests
url = "https://llm.siraya.ai/v1/images/generations"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <API_KEY>"
}
data = {
"model": "imagen-4.0-generate-001",
"prompt": "A cat is playing piano in a cozy room",
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
Example Response
Asynchronous generation
Image generation is normally fast, but some models can take a while. By default the request is synchronous — it waits for generation to finish and returns the completed image. For slower models, set async: true to return immediately with an image id and receive the result later via a callback.
No poll or download endpoint
Unlike video generation, async image generation has no status/poll endpoint and no separate download endpoint. callbackUrl is required to actually get the result — without it you only get the initial acknowledgment below and have no way to retrieve the generated image.
Submit an async job
curl https://llm.siraya.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"model": "imagen-4.0-generate-001",
"prompt": "A cat is playing piano in a cozy room",
"async": true,
"callbackUrl": "https://your-app.com/webhooks/siraya-image"
}'
The job is accepted immediately. status is processing and no image is returned yet:
{
"id": "img_n6Sn-1aIT3z8x-QF3xxD0wiUTjl6s31...",
"object": "image",
"status": "processing",
"created_at": 1774716098,
"model": "imagen-4.0-generate-001"
}
Callback
When the job finishes, the router sends a POST to callbackUrl. The request body is identical to the synchronous response — the finished image as base64 under data[], not a URL:
{
"created": 1774716103,
"data": [
{ "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAAAg3..." }
],
"error": {}
}
Your endpoint should respond 2xx to acknowledge receipt. If generation failed, the error object is populated and data is empty.
For a list of all available image models, visit the Models Directory.