All guides
Make an image and wait for it
Images, videos, voice-overs and transcripts all work the same way: you start one, it runs in the background, and the finished file goes to your Library. This guide makes an image.
1See what it costs (optional)
Send the same body to
/generations/estimatefirst. It answers with the credits it would use and spends nothing.curl -X POST "https://cuil.si/api/v1/generations/estimate" -H "Authorization: Bearer $CUILSI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"kind": "image", "mode": "t2i", "tier": "standard", "prompt": "A lighthouse at dawn"}' # { "credits": ..., "model": { ... } }: what it would use, nothing is spent yet2Start it
POST /generationsanswers at once with202and the generation'sid. The credits are held while it runs. It's a retry-safe request: if your call times out, send it again with the same key and you won't pay twice.curl -X POST "https://cuil.si/api/v1/generations" -H "Authorization: Bearer $CUILSI_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "kind": "image", "mode": "t2i", "tier": "standard", "style": "photoreal", "prompt": "A lighthouse at dawn, soft pastel light", "params": { "aspect_ratio": "4:5" } }' # 202 Accepted: { "id": "...", "status": "queued", "credits_estimated": ..., ... }3Wait for it
Ask for it every few seconds until
statusissucceededorfailed. Wait a little longer each time. If it fails, its credits come back. Rather not ask? Add a webhook forgeneration.completedandgeneration.failed.async function waitForGeneration(id) { for (let wait = 2000; ; wait = Math.min(wait * 1.5, 15000)) { const generation = await fetch(`https://cuil.si/api/v1/generations/${id}`, { headers: { Authorization: `Bearer ${process.env.CUILSI_API_KEY}` } }).then((r) => r.json()); if (generation.status === "succeeded") return generation; if (generation.status === "failed") throw new Error(generation.error); // its credits came back await new Promise((resolve) => setTimeout(resolve, wait)); } }4Use the file
outputslists the new files in your Library, each with a link. You can post them, put them in an edit, or download them.const done = await waitForGeneration(generation.id); for (const file of done.outputs) { console.log(file.id, file.url); // a Library file; GET https://cuil.si/api/v1/assets/{id} gives its download link }