Skip to content
all work

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

source
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

AI-generated
The single product image given to the pipeline: a CoreBand box, band and companion app
input → output
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.

Planning graph · LangGraph StateGraph, 26 nodes
  1. Creative strategymultimodal

    Reads the script and looks at the product image

  2. Narrative + formatLLM

    Story structure, one of 7 UGC formats, beat-level blueprint

  3. Casting + production planLLM

    Who presents, where, how the camera behaves, how cuts land

  4. Master scriptaligned

    Dialogue locked back onto the client's words

  5. || audio + visual timelines

    Audio events

    Lines, character and environment SFX

    Visual segments

    What's on screen for each beat

  6. Locked master timelinejoin

    Single source of truth for timing downstream

  7. || reference plates

    Creator
    Environment
    Product
    Wardrobe
  8. Shot blueprint → prompts → keyframesimages

    Every keyframe conditioned on all four plates

Asset pipeline · 13 checkpointed steps
  1. VoiceSarvam

    Hinglish transliterated to Devanagari, then a gender-aware Indian TTS voice

  2. || sound

    Character SFX
    Environmental SFX
  3. Audio timing manifestsync

    Real speech durations re-time the visual plan

  4. Image-to-video + lip-syncSeedance

    Each keyframe animated against its own line of audio

  5. 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.

AI-generated creator identity plate: a young man in a grey t-shirt on a studio backdrop

creator

AI-generated environment plate: a sunlit home office with a desk and shelves

environment

AI-generated product packshot of the CoreBand box and band

product

AI-generated wardrobe plate: grey long-sleeve top and trousers

wardrobe

Reference plates cast by the planning graph. Every shot is conditioned on all four.
Frame 1 of the final ad: the same AI-generated creator in the same roomFrame 2 of the final ad: the same AI-generated creator in the same roomFrame 3 of the final ad: the same AI-generated creator in the same roomFrame 4 of the final ad: the same AI-generated creator in the same roomFrame 5 of the final ad: the same AI-generated creator in the same roomFrame 6 of the final ad: the same AI-generated creator in the same room
One frame every 8 seconds of the final cut: same face, same room, same band.

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.