Skip to content

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.

POST https://llm.siraya.ai/v1/images/generations
Authorization string Required
Your API Key (e.g., Bearer <API_KEY>).

Body

model string Required
The ID of the model to use (e.g. gpt-image-2, imagen-4.0-generate-001).
prompt string Required
A text description of the desired image.
n integer Default: 1
The number of images to generate (1-10).
size string
The dimensions of the generated image (e.g. 1024x1024, 1792x1024, 1024x1792).
quality string
The quality of the generated image. Possible values: standard, hd, low, medium, high.
style string
The style of the generated image. Possible values: vivid, natural.
response_format string
The format in which the generated image is returned. Possible values: b64_json, url.
user string
A unique identifier representing your end-user.
background string
The background type for the generated image. Possible values: transparent, opaque, auto.
output_compression integer
The compression level for the output image (0-100). Applicable to jpeg and webp formats.
moderation string
The content moderation level. Possible values: low, auto.
negative_prompt string
Negative prompt describing content to exclude from the generated image. Supported by Imagen models.
seed integer
Random seed for reproducibility. The same seed produces the same image. Supported by Imagen models.
A reference image for image-to-image generation (URL or base64 data URL). Supported by Seedream models.
sequential_image_generation string
Controls batch image generation mode. Possible values: auto, disabled. Supported by Seedream models.
async boolean Default: false
When 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.
callbackUrl string
Only used when 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.
extra_body object
Additional model-specific parameters passed directly to the provider. Unknown top-level fields are also automatically captured into this object.
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"
  }'
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

{
    "created": 1774716098,
    "data": [
        {
            "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAAAg3..."
        }
    ]
}

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.