Skip to Content
Uncodie Market Fit está disponible 🎉
Rest APIAiAI Video Generation API

AI Video Generation (/api/ai/video)

Generate short clips (up to ~60 seconds) using Google’s Gemini Veo 3.1 model. The route mirrors the /api/ai/image flow: it validates the payload, invokes Gemini, polls until the job finishes, stores the resulting file in Supabase Storage (generative_videos bucket), and returns a public URL.

Try it

AI Video Generation

Generate a short clip with Gemini Veo 3.1.

Endpoint

POST /api/ai/video

Request Body

FieldTypeDescriptionRequired
promptstringNatural-language description of the video.Yes
site_idstring (UUID)Site used for storage ownership & billing.Yes
provider’gemini’Provider identifier (currently Gemini only).No (default ‘gemini’)
duration_secondsnumberDesired length in seconds (capped at 60).No
aspect_ratio’1:1’ | ‘4:3’ | ‘3:4’ | ‘16:9’ | ‘9:16’ | ‘3:2’ | ‘2:3’Target aspect ratio.No
reference_imagesstring[]Up to 3 HTTPS URLs used as visual references.No
quality’preview’ | ‘standard’ | ‘pro’Informative hint passed to the prompt.No
modelstringOverride Gemini model (default veo-3.1-generate-preview).No

Example Request

curl -X POST https://your-api.com/api/ai/video \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{ "prompt": "Handheld shot of an explorer walking through neon-lit ruins", "site_id": "f12a0f69-70f4-4d70-9e55-3c86d3c8c111", "duration_seconds": 20, "aspect_ratio": "9:16", "reference_images": [ "https://cdn.example.com/concepts/explorer.jpg" ] }'

Example Response

{ "provider": "gemini", "videos": [ { "url": "https://supabase.example.com/storage/v1/object/public/generative_videos/f12a0f69/1729100590000.mp4", "mimeType": "video/mp4" } ], "metadata": { "model": "veo-3.1-generate-preview", "duration_seconds": 20, "aspect_ratio": "9:16", "quality": null, "generated_at": "2025-03-15T12:34:56.789Z" } }

Note: Generation is asynchronous; the server polls Gemini every ~10 seconds (up to 10 minutes). The response returns a hosted URL once the file is saved to Supabase.

Last updated on