Use Case
Automate E-commerce Video Ads with the SDK
Your product catalog has hundreds of SKUs. Each one needs video for product pages, Meta Ads, and TikTok. Hiring creators does not scale. agent-media gives you a Python SDK, a TypeScript client, and a CLI to generate UGC-style product videos programmatically. Pass a script, an actor, and a product image. Get a finished mp4 back. ~$3 per video. See pricing.
Python SDK: Generate Videos from Your Product Catalog
Read products from a database or CSV, generate a video for each one. This example loops through a product table and creates UGC videos with product images as B-roll.
import csv
from agent_media import AgentMedia
client = AgentMedia(api_key="your-api-key")
# Read products from CSV
with open("products.csv") as f:
products = list(csv.DictReader(f))
for product in products:
video = client.ugc.create(
script=product["script"],
actor="sofia",
product_image=product["image_url"],
broll=True,
sync=True,
)
print(f"{product['name']}: {video.url}")
TypeScript: Trigger from E-commerce Webhooks
Wire up a Shopify or WooCommerce webhook so every new product automatically gets a video. This example handles a products/create webhook and queues a video generation job.
import { AgentMedia } from "agent-media";
const client = new AgentMedia({ apiKey: process.env.AGENT_MEDIA_KEY });
export async function handleProductCreated(product: {
name: string; description: string; image_url: string;
}) {
const script = `I just tried ${product.name} and it's amazing. `
+ `${product.description}`;
const video = await client.ugc.create({
script,
actor: "sofia",
productImage: product.image_url,
broll: true,
});
return video.url;
}
Batch Generation from CSV or Database
Most e-commerce catalogs live in a database or a product feed CSV. The SDK accepts any iterable of product records. Read from Postgres, a Shopify export, or a plain CSV file. Each record needs three fields: a script (or product description to generate one from), an actor name, and a product image URL or local path.
The --product-image flag (CLI) or product_image parameter (SDK) inserts your product photo as a B-roll cutaway in the video. The actor speaks to camera, then the video cuts to your product image before returning to the actor. No separate B-roll shoot required.
For large catalogs (500+ SKUs), use the SDK's async mode. Submit all jobs without waiting, then poll for completion or register a webhook callback. The platform processes jobs in parallel, so 500 videos complete in hours, not days.
CLI: Quick One-off Generation
For quick tests or one-off videos, use the CLI directly. No code required.
# Install
$ npm install -g agent-media-cli
$ agent-media login
# Generate a single product video
$ agent-media ugc "This moisturizer changed my skin in two weeks." \
--actor sofia \
--product-image ./product.jpg \
--broll --sync
# Batch generate from CSV
$ while IFS=, read -r name script img; do
agent-media ugc "$script" \
--actor sofia --product-image "$img" --broll --sync
done < products.csv
Cost at Scale
| Catalog Size | Freelancer / Agency | agent-media SDK | Time |
|---|---|---|---|
| 10 SKUs | $2,000 - $8,000 | ~$30 | ~30 min |
| 50 SKUs | $10,000 - $40,000 | ~$150 | ~2 hrs |
| 200 SKUs | $40,000 - $160,000 | ~$600 | ~8 hrs |
| 500 SKUs | $100,000+ | ~$1,500 | ~20 hrs |
| Revisions | Extra cost + weeks | Re-run the script | Same |
Credits cost 30 per second of video. A 10-second product video uses 300 credits (~$3). Async batch jobs run in parallel on the platform. View full pricing.
Why Developers Choose agent-media
Python & TypeScript SDKs
First-class clients for both languages. Type-safe, async-ready, with full API coverage. pip install agent-media or npm install agent-media.
Product image as B-roll
Pass --product-image and your product photo appears as a cutaway in the video. No separate media pipeline needed.
Webhook-driven pipelines
Trigger video generation from Shopify, WooCommerce, or any platform that sends webhooks. New product listed? Video generated automatically.
Batch from CSV or database
Read your product feed from any source. Loop through records and submit jobs. The platform handles parallelism and retries.
200 AI actors
A/B test different actors on the same product. Programmatically generate variants and let your ad platform pick the winner.
REST API for custom integrations
Full REST API behind the SDKs. Build custom integrations with any language or platform. OpenAPI spec available.
Integration Patterns
Shopify webhook pipeline. Listen for products/create and products/update events. Extract the product title, description, and featured image. Call the SDK to generate a video. Upload the result back to the product's media via the Shopify Admin API.
Nightly batch job. Query your product database for items without videos. Run a Python script as a cron job that generates videos for new SKUs overnight. Use async mode for throughput.
A/B testing at scale. For each product, generate 3 to 5 variants with different actors and scripts. Upload all variants to your ad account. Let the ad platform's algorithm optimize for the best-performing creative.
Product image quality. The B-roll cutaway displays your product photo at full frame. Use clean, high-resolution product shots. White background images from your store work best.
Related Pages
Last updated: April 2026