Skip to main content

POST /api/analyze-video

Accepts a video clip and a product name. Sends the clip to Gemini for scene analysis, then returns a full scene breakdown, an ad placement recommendation with timestamp and visual instructions, and a video_id to use in POST /api/generate-ad-video.
The video_id returned by this endpoint expires after 30 minutes. Calls to /api/generate-ad-video with an expired or unknown video_id will return 404.

Request

Send the request as multipart/form-data.
video
file
required
The video clip to analyze. Accepted formats: MP4, MOV, MPEG, WEBM, MKV, AVI. Maximum size is MAX_VIDEO_UPLOAD_MB (default 200 MB).
product_name
string
required
The product to advertise. Typically the product_name returned by POST /api/identify-product.

Response

scene_breakdown
string
required
Detailed scene-by-scene analysis with timestamps and transcript.
ad_placement
object
required
Placement recommendation produced by Gemini.
product
string
required
The product_name value echoed back from the request.
video_id
string
required
UUID identifying the cached video on the server. Pass this to /api/generate-ad-video. Valid for 30 minutes.

Example

curl -X POST http://127.0.0.1:8000/api/analyze-video \
  -F "video=@/path/to/clip.mp4" \
  -F "product_name=2025 Toyota RAV4 XLE Hybrid AWD"

Errors

StatusCause
400product_name is missing.
400Uploaded file is empty.
413File exceeds MAX_VIDEO_UPLOAD_MB.
503GEMINI_API_KEY is not configured.
502Gemini video analysis request failed.

Build docs developers (and LLMs) love