Skip to content

AI Generation

All generation endpoints require authentication and deduct credits from your balance. Insufficient credits returns a 402 response.

Generates 5 platform-optimized copy variants. Synchronous — returns results immediately.

POST /api/generate/copy
Authorization: Bearer <token>
Content-Type: application/json
{
"projectId": "uuid",
"productId": "uuid",
"platform": "meta",
"format": "short",
"tone": "bold",
"customInstructions": "Focus on the summer sale",
"idempotencyKey": "user-session-abc123"
}
FieldTypeRequiredOptions
projectIduuidYes
productIduuidYes
platformstringYesmeta, tiktok, google, linkedin, pinterest, universal
formatstringYesshort, long, hook, story
tonestringYesprofessional, casual, urgent, luxe, playful, bold
customInstructionsstringNoMax 500 chars
idempotencyKeystringNoMax 128 chars

Response (200): 1 credit deducted

{
"jobId": "uuid",
"status": "completed",
"creditsUsed": 1,
"creditsRemaining": 24,
"variants": [
{
"hook": "Summer just got hotter.",
"body": "Our best-selling widget is now 50% off...",
"cta": "Shop the Sale",
"hashtags": ["#SummerSale", "#LimitedTime"]
}
]
}

Creates an AI-generated ad image. Asynchronous — returns a job ID for polling.

POST /api/generate/static-ad
Authorization: Bearer <token>
Content-Type: application/json
{
"projectId": "uuid",
"productId": "uuid",
"style": "modern",
"aspectRatio": "1:1",
"prompt": "Summer vibes, bright background",
"idempotencyKey": "static-abc123"
}
FieldTypeRequiredOptions
projectIduuidYes
productIduuidYes
stylestringNoproduct_hero, lifestyle, minimal, bold, seasonal
aspectRatiostringNo1:1, 9:16, 4:5, 16:9 (default: 1:1)
promptstringNo5-1000 chars
idempotencyKeystringNoMax 128 chars

Response (200): 3 credits deducted

{
"jobId": "uuid",
"status": "queued",
"creditsUsed": 3,
"creditsRemaining": 21
}

Creates an AI avatar video with lip-synced speech. Asynchronous — typically takes 1-3 minutes.

POST /api/generate/video
Authorization: Bearer <token>
Content-Type: application/json
{
"projectId": "uuid",
"productId": "uuid",
"script": "Hey! You need to check out this amazing product...",
"avatarUrl": "https://example.com/avatar.jpg",
"voiceId": "male-1",
"aspectRatio": "9:16",
"idempotencyKey": "video-abc123"
}
FieldTypeRequiredOptions
projectIduuidYes
productIduuidYes
scriptstringYes10-2000 chars
avatarUrlurlNoCustom avatar image
voiceIdstringNoDefault: male-1
aspectRatiostringNo9:16, 1:1, 16:9 (default: 9:16)
idempotencyKeystringNoMax 128 chars

Response (200): 40 credits deducted

{
"jobId": "uuid",
"status": "queued",
"creditsUsed": 40,
"creditsRemaining": 60
}

Check the status of an async generation job.

GET /api/generate/status?jobId=<uuid>
Authorization: Bearer <token>

Response (200):

{
"id": "uuid",
"type": "static_ad",
"status": "completed",
"assets": [
{ "id": "uuid", "type": "image", "url": "https://..." }
],
"createdAt": "2026-03-09T10:00:00Z",
"completedAt": "2026-03-09T10:00:25Z"
}
StatusMeaning
pendingCreated, not yet queued
queuedIn the processing queue
processingActively being generated
completedDone — assets available
failedError occurred (credits refunded)
canceledCanceled by user or admin
expiredTimed out

All generation endpoints accept an optional idempotencyKey. If a non-terminal job exists with the same key for your user, the existing job is returned instead of creating a new one — no duplicate credit charge.

// First request: creates job, deducts credits
{ "idempotencyKey": "my-key-123", ... }
// Response: { "jobId": "abc", "creditsUsed": 3 }
// Duplicate request: returns existing job, 0 credits
{ "idempotencyKey": "my-key-123", ... }
// Response: { "jobId": "abc", "creditsUsed": 0, "status": "reused" }
StatusMeaning
400Invalid input (Zod validation error)
401Not authenticated
402Insufficient credits
404Product or project not found