Automate E-commerce Video Ads with the SDK

First video free, no card

Use Case

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 and an actor description (or a saved actor for consistency across your catalog). Get a finished mp4 back. 45 credits plus 28 per second, so a 10-second video is 325 credits. 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 generates a video for each product using the product's script text.

import csv
import requests
API_KEY = "your-api-key"
# Read products from CSV
with open("products.csv") as f:
{' '}products = list(csv.DictReader(f))
for product in products:
{' '}resp = requests.post(
{' '}"https://api.agent-media.ai/v2/generate/video",
{' '}headers={'{'}"Authorization": f"Bearer {'{'}API_KEY{'}'}"{'}'},
{' '}json={'{'}
{' '}"prompt": product["script"],
{' '}"seconds": 10,
{' '}"aspect": "9:16",
{' '}{'}'},
{' '})
{' '}video = resp.json()
{' '}print(f"{'{'}product['name']{'}'}: {'{'}video['status_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.

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 resp = await fetch("https://api.agent-media.ai/v2/generate/video", {'{'}
{' '}method: "POST",
{' '}headers: {'{'} "Authorization": `Bearer ${'{'}process.env.AGENT_MEDIA_KEY{'}'}`, "Content-Type": "application/json" {'}'},
{' '}body: JSON.stringify({'{'} prompt: script, seconds: 10, aspect: "9:16" {'}'}),
{' '}{'}'});
{' '}const video = await resp.json();
{' '}return video.status_url;
{'}'}

Batch Generation from CSV or Database

Most e-commerce catalogs live in a database or a product feed CSV. The API accepts any iterable of product records. Read from Postgres, a Shopify export, or a plain CSV file. Each record needs two fields: a script (or product description to generate one from) and a target duration.

Save an actor once with agent-media character create --description "..." and reuse the same --character <id> across every video in the batch. The actor stays consistent across the whole catalog run, no separate photoshoot required.

For large catalogs (500+ SKUs), submit all jobs without waiting, then poll for completion with agent-media status <job-id> --watch 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 selfie \
{' '}--description "woman in her late 20s, warm and natural, kitchen morning light" \
{' '}--script "This moisturizer changed my skin in two weeks." \
{' '}--duration 10
$ agent-media status <job-id> --watch
$ agent-media download <job-id> -o clip.mp4
# Batch generate from CSV
$ while IFS=, read -r
 name script; do
{' '}agent-media selfie --description "woman in her late 20s, warm and natural, kitchen morning light" \
{' '}--script "$script" --duration 10
{' '}done {'<'} products.csv

Cost at Scale

A selfie video costs 45 credits plus 28 per second, on either engine. A 10-second selfie video uses 325 credits. Async batch jobs run in parallel on the platform. View full pricing.

Why Developers Choose agent-media

Integration Patterns

Shopify webhook pipeline. Listen for products/create and products/update events. Extract the product title, description, and featured image. Call the API 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 script as a cron job that generates videos for new SKUs overnight. Poll job status for throughput.

A/B testing at scale. For each product, generate 3 to 5 variants with different actor descriptions and scripts. Upload all variants to your ad account. Let the ad platform's algorithm optimize for the best-performing creative.

Actor description quality. Be specific about age, vibe, and setting when writing --description. Concrete details on lighting, wardrobe, and energy produce a more consistent on-model result across your catalog than a generic prompt.

Related Pages

Last updated: April 2026

What do you sell?

First video free, no card