01 / multi-agent · video / 2025
UGC Ads Agent
A product photo and a rough script in; a lip-synced 9:16 creator-style video ad out. A LangGraph pipeline that plans, casts, shoots, voices and edits the whole spot.
Role
Solo build
Stack
LangGraph / FastAPI / AWS Lambda / S3 / DynamoDB / OpenAI / Gemini / Seedance / Sarvam / ElevenLabs / ffmpeg
- model spend for a 47 s ad
$1.38
model spend for a 47 s ad
- lower generation cost
30–40%
lower generation cost
- providers metered live
6+
providers metered live

The only visual input was this product image, plus a short Hinglish script. Everything in the ad (casting, set, wardrobe, shots, voice, lip-sync, sound and edit) was produced by the pipeline.
Overview
Creator-style (UGC) video is the best-performing ad format for direct-to-consumer brands, and the slowest to make. You brief a creator, ship the product, wait for footage, edit, then repeat for every variant you want to test.
This pipeline takes a product image and a rough script (Hinglish and Hindi included) and returns a finished, lip-synced 9:16 ad. It handles strategy, casting, set design, shots, voice, sound and the final edit. The ad above is a real output: a 47-second Hinglish spot for a fictional fitness band called CoreBand, made end to end for $1.38 in model spend.
How it works
There are two halves. A planning graph decides what to make. A resumable asset pipeline then makes it, without re-planning.
- Creative strategymultimodal
Reads the script and looks at the product image
- Narrative + formatLLM
Story structure, one of 7 UGC formats, beat-level blueprint
- Casting + production planLLM
Who presents, where, how the camera behaves, how cuts land
- Master scriptaligned
Dialogue locked back onto the client's words
|| audio + visual timelines
Audio eventsLines, character and environment SFX
Visual segmentsWhat's on screen for each beat
- Locked master timelinejoin
Single source of truth for timing downstream
|| reference plates
CreatorEnvironmentProductWardrobe- Shot blueprint → prompts → keyframesimages
Every keyframe conditioned on all four plates
- VoiceSarvam
Hinglish transliterated to Devanagari, then a gender-aware Indian TTS voice
|| sound
Character SFXEnvironmental SFX- Audio timing manifestsync
Real speech durations re-time the visual plan
- Image-to-video + lip-syncSeedance
Each keyframe animated against its own line of audio
- Edit timeline → stitchffmpeg
Trims, audio mix, 24 fps normalisation, concat
↺ Any step can resume from saved state, and a single segment can be re-rolled without touching the rest.
The reference sheet
The hard part of AI video is consistency: the same face, the same room and the same product in every cut. Before generating any shot, the graph casts a creator, designs one primary environment, packshots the product and picks a wardrobe. Every keyframe is then generated against those plates.

creator

environment

product

wardrobe






Hard parts and decisions
- The model doesn't get to rewrite the client's script. After each planning step, a script-alignment pass (
script_timeline.py) forces the dialogue text and timing back onto the user's script. The LLM still decides emotion, blocking and transitions. - Labels in, definitions out. Nodes choose from category labels: UGC formats, camera styles, cut behaviours. Code-side lookup tables then expand each label into a full definition for the next node, so an early choice means the same thing everywhere downstream.
- Consistency lives in state, not in hope. Each ad gets one primary environment, camera style and cut behaviour. Creator and product visibility have targets, and the presenter is normalised to one person. All of this is enforced in state rather than requested in a prompt.
- Providers fail; the pipeline keeps going. Image generation falls back across three providers, with a shared cooldown and back-off on 429s, and reuses anything already on disk. When the video model rejects a photoreal face, the frame is stylised and retried, or sent to a fallback model.
- Working around Lambda's 15-minute limit. The job API runs as FastAPI on AWS Lambda. The worker watches its own time budget, checkpoints state to S3 at 80% and re-invokes itself, so multi-minute renders resume where they stopped.
- Cost is an output, not an afterthought. LangGraph reducers add up spend per category across 6+ providers as the run progresses. Tiered run modes (
none→references→shots→full) and on-disk asset reuse cut generation cost by 30–40%.
Results
- model spend, 47 s ad
$1.38
model spend, 47 s ad
- lower generation cost
30–40%
lower generation cost
- providers metered
6+
providers metered
- tests in the suite
176
tests in the suite
CoreBand cost breakdown, as metered by the pipeline: video $1.00, LLM planning $0.28, images $0.105.