Image
This quickstart walks you through generating your first image with SIRAYA Model Router.
Image generation
curl https://llm.siraya.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: <API_KEY>" \
-d '{
"model": "imagen-4.0-generate-001",
"prompt": "A cute baby sea otter",
}'
https://llm.siraya.ai/v1/images/generationsis the base URL<API_KEY>is your API Key generated in API page.modelis the model name, such asgpt-image-2, available model list can be access in Model page.promptis the prompt.async(boolean, optional, defaultfalse) — whenfalse, the request waits for generation to finish and returns the finished image. Whentrue, the request returns immediately with an imageidwhile generation runs in the background; there's no status/poll endpoint for images, so passcallbackUrlto receive the result.callbackUrl(string, optional) — only used whenasyncistrue. The full URL the router willPOSTto once generation completes (or fails). This is the only way to retrieve the result of an async image job.
Example response
{
"created": 1774716098,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAAAg3..."
}
]
}
Asynchronous generation
Some image models can take a while. Set async: true to return immediately with an image
id instead of waiting, and get 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 and have no way to retrieve the
generated image.
curl https://llm.siraya.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer " \
-d '{
"model": "imagen-4.0-generate-001",
"prompt": "A cute baby sea otter",
"async": true,
"callbackUrl": "https://your-app.com/webhooks/siraya-image"
}'
Example response — the job is accepted; status is processing and no image yet:
{
"id": "img_n6Sn-1aIT3z8x-QF3xxD0wiUTjl6s31...",
"object": "image",
"status": "processing",
"created_at": 1779869107,
"model": "imagen-4.0-generate-001"
}
Callback
When the job finishes, the router sends a POST to your callbackUrl. The request body
is identical to the synchronous response — the finished image as base64 under data[],
not a URL:
{
"created": 1779869112,
"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.