Skip to content

Image Generation

POST/v1/run

Generate images using AI models like FLUX, Stable Diffusion, DALL-E, and more.

For an image model that runs asynchronously, you may either set webhook_url on one request or register an organization Model Webhook. Synchronous calls and LLM calls do not support task callbacks; if they contain this field, SandBase ignores it and schedules no callback. See Webhooks.

Parameters

ParameterTypeRequiredDescription
modelstringModel name (e.g. flux/schnell, dall-e-3)
promptstringText description of the image
widthintegerImage width in pixels
heightintegerImage height in pixels
num_imagesintegerNumber of images to generate (default: 1)
modestringSet to async only when the selected model supports asynchronous execution
webhook_urlstringPublic HTTPS callback URL for this async task only

Example

python
response = client.post("/v1/run", json={
    "model": "flux/schnell",
    "prompt": "A futuristic city at sunset, cyberpunk style",
    "width": 1024,
    "height": 1024
})
print(response.json()["outputs"][0]["url"])

Per-task callback (async only)

Set webhook_url when the selected image model resolves to asynchronous execution:

python
response = client.post("/v1/run", json={
    "model": "example/async-image-model",
    "mode": "async",
    "prompt": "A futuristic city at sunset, cyberpunk style",
    "webhook_url": "https://hooks.example.com/sandbase/task?token=opaque-token"
})
generation_id = response.json()["id"]

SandBase sends the completed, failed, or timeout event to that URL with X-Event-ID. Delivery is at-least-once, so deduplicate by that ID and return 2xx quickly. The URL must be public HTTPS. When webhook_url is present, it is the only callback target for this task and registered organization Model Webhooks are skipped; failures retry the same task URL without fallback. Per-task callbacks do not include X-Signature; omit webhook_url and use an organization Model Webhook when HMAC verification is required.

Available Models

ModelProviderPrice per image
flux/schnellBlack Forest Labs$0.003
flux/devBlack Forest Labs$0.025
dall-e-3OpenAI$0.04–$0.12
stable-diffusion-3Stability AI$0.03
ideogram/v2Ideogram$0.05

Browse all image models