Create Generation
Request a new asynchronous AI generation job for an image or video. The API immediately returns a job ID with PENDING status — poll the GET endpoint to retrieve results.
POST/api/generations
Parameters
modelIdstringRequired
The ID of the AI model to use (e.g. sora-2, kling-v2-6, gemini-2.5-flash-image). See the Overview for the full list.
promptstringRequired
The text prompt describing the desired image or video output. Max 2000 characters.
type"image" | "video"Required
Must be exactly 'image' or 'video'. Must match the capabilities of the chosen model.
aspectRatio"16:9" | "9:16" | "1:1"Optional
Desired output aspect ratio. Defaults to 16:9 if omitted.
negativePromptstringOptional
A description of elements to avoid in the generation. Max 1000 characters.
Request Body
Content-Type:
application/json{
"modelId": "veo-3.1-generate-preview",
"prompt": "A futuristic city with flying cars.",
"type": "video",
"aspectRatio": "16:9",
"negativePrompt": "dark, blurry, text"
}Responses
202Accepted — job successfully enqueued.
{
"jobId": "cmr1aot6r000004i87w38n1f6",
"status": "PENDING"
}400Bad Request — validation failed.
{
"error": "Validation failed",
"details": [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"prompt"
],
"message": "Required"
}
]
}401Unauthorized — missing or invalid API key.
{
"error": "Invalid or missing API key"
}402Payment Required — insufficient credit balance.
{
"error": "Insufficient credits to perform this generation"
}curl -X POST https://editlyplatform-ed06row0u-editly.vercel.app/api/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"modelId": "sora-2",
"prompt": "A highly detailed majestic lion roaring in the savanna, cinematic lighting.",
"type": "video",
"aspectRatio": "16:9"
}'