Prompt
rest endpoint for ai image generation
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
A simple REST endpoint for AI image generation usually looks like this:
Endpoint
POST /v1/images/generate
Request body
{
"prompt": "A futuristic city at sunset, ultra detailed",
"size": "1024x1024",
"style": "cinematic",
"num_images": 1,
"seed": 42
}
Response
{
"id": "imggen_12345",
"status": "completed",
"images": [
{
"url": "https://cdn.example.com/images/imggen_12345_1.png",
"width": 1024,
"height": 1024
}
]
}
Suggested behavior
- POST to create a generation job
- Return either:
- synchronous result if generation is fast, or
- job ID with pending status for async processing
- Use a GET endpoint to fetch results:
GET /v1/images/generate/{id}
Example cURL
curl -X POST https://api.example.com/v1/images/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A futuristic city at sunset, ultra detailed",
"size": "1024x1024",
"num_images": 1
}'
If you want, I can also give you:
- a FastAPI implementation,
- an OpenAPI spec, or
- a Node/Express example.