Image Generation
Create images with AI models.
Image generation uses an asynchronous two-step workflow: create a task, then poll for the result.
Step 1 — Create a Task
curl -X POST https://api.leaper.one/v1/images/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-image",
"prompt": "A watercolor painting of a mountain lake at sunrise"
}'{
"id": "img-abc123",
"status": "pending"
}Step 2 — Poll for Status
Use the returned id to check progress:
curl https://api.leaper.one/v1/images/generations/img-abc123 \
-H "Authorization: Bearer sk-your-api-key"{
"id": "img-abc123",
"status": "completed",
"data": [
{
"url": "https://cdn.leaper.one/images/abc123.png"
}
]
}Status Values
| Status | Meaning |
|---|---|
pending | Task queued, not yet started. |
processing | Model is generating the image. |
uploading | Image is being uploaded to storage. |
partial | Some images ready (for multi-image requests). |
completed | All images ready. |
failed | Generation failed. |
Webhook Callback
Instead of polling, you can provide a callbackUrl to receive a POST notification when the task finishes:
{
"model": "gpt-4o-image",
"prompt": "A neon-lit cyberpunk cityscape",
"callbackUrl": "https://your-server.com/webhook/image"
}Each generated image costs 0.5 credits.
Image URLs are temporary and expire after 1 hour. Download or cache them promptly.
For the full parameter list and response schema, see the API Reference.