Use Case
Build a TikTok Ad Pipeline with the agent-media API
TikTok ad accounts burn through creatives fast. Instead of hiring creators or building a video pipeline from scratch, call the agent-media API. Generate 9:16 UGC videos with lip-synced AI actors, TikTok-style subtitles, and energetic delivery. Batch generate variants, get webhook callbacks when videos are ready, and push directly to your ad platform. $3 per video.
Generate a TikTok Ad in 10 Lines
Install the TypeScript SDK and create a TikTok-optimized UGC video. The SDK handles voiceover generation, lip-sync, subtitle rendering, and final assembly. You get back a download URL.
import { AgentMedia } from "agent-media-sdk";
const client = new AgentMedia(process.env.AGENT_MEDIA_API_KEY);
const video = await client.videos.create({
script: "Stop scrolling. This app saved me two hours every morning.",
actor: "sofia",
aspect_ratio: "9:16",
subtitle_style: "tiktok",
voice_tone: "energetic",
duration: 10,
});
console.log(video.download_url); // → https://cdn.agent-media.ai/v/abc123.mp4
Batch Generate 10 Variants with Different Actors
TikTok ad testing requires volume. Same script, different faces. Use Promise.all to generate multiple variants in parallel. Each variant uses a different AI actor from the 200+ available.
const actors = [ "sofia", "emma", "naomi", "marco", "liam",
"priya", "aisha", "carlos", "mei", "jordan"];
const script = "Stop scrolling. This app saved me two hours every morning.";
const videos = await Promise.all(
actors.map((actor) =>
client.videos.create({
script,
actor,
aspect_ratio: "9:16",
subtitle_style: "tiktok",
voice_tone: "energetic",
duration: 10,
})
)
);
// 10 TikTok-ready videos, each with a different actor
videos.forEach((v) => console.log(v.actor, v.download_url));
Async Pipeline with Webhooks
For production pipelines, use webhook callbacks instead of polling. Submit video jobs with a webhook_url, and agent-media will POST the result when the video is ready. This lets you decouple generation from downstream processing like uploading to TikTok Ads Manager.
// 1. Submit job with webhook callback
const job = await client.videos.create({
script: "This changed everything for me.",
actor: "sofia",
aspect_ratio: "9:16",
subtitle_style: "tiktok",
voice_tone: "energetic",
webhook_url: "https://your-app.com/api/video-ready",
});
// 2. Your webhook receives the completed video
export async function POST(req: Request) {
const { video_id, download_url, status } = await req.json();
// Upload to TikTok Ads Manager, notify Slack, etc.
}
CLI for Quick Iteration
Use the CLI for ad-hoc generation and testing before wiring up the API. Same capabilities, faster feedback loop.
Install and authenticate
Install the agent-media CLI globally and log in with your API key.
$ npm install -g agent-media-cli
$ agent-media login
Generate a TikTok ad
Pass your script, pick an actor, and set TikTok-native defaults. The --sync flag waits for the video to finish and returns the download URL.
$ agent-media ugc "Stop scrolling. This product saved me two hours every morning." \
--actor sofia \
--style tiktok \
--duration 10 \
--tone energetic \
--sync
Batch generate with a loop
Same script, different actors. Use a shell loop to generate multiple variants for A/B testing.
$ for actor in sofia emma naomi marco liam; do
agent-media ugc "Stop scrolling..." \
--actor $actor --style tiktok --tone energetic --sync
done
Cost per Video
| Plan | Cost / Video |
|---|---|
| Pay-as-you-go (300 credits) | ~$3 |
| Creator ($39/mo — 4,000 credits) | ~$3 × 13 videos |
| Pro ($69/mo — 7,000 credits) | ~$3 × 23 videos |
| Pro Plus ($129/mo — 13,000 credits) | ~$3 × 43 videos |
| Credit pack ($39 one-time) | 13 videos, never expires |
At $3 per video, generating 10 TikTok ad variants costs $30. Hiring UGC creators for the same batch: $1,500 to $5,000 plus revision rounds. View full pricing.
Why Developers Build on agent-media
TypeScript SDK + REST API
First-class TypeScript SDK with full type definitions. Or call the REST API directly from any language. No browser or GUI needed.
Webhook callbacks
Submit jobs asynchronously and receive a POST when the video is ready. No polling. Plug into your existing event pipeline.
200 AI actors
Diverse faces, ages, and styles available via the actors endpoint. Programmatically select actors based on campaign targeting.
TikTok-native defaults
9:16 aspect ratio, TikTok subtitle style, energetic voice tone. One config object produces platform-optimized output.
Word count validation
The API rejects scripts that exceed the word limit for the chosen duration. No silent failures or rushed speech.
Idempotent & deterministic
Same inputs produce consistent results. Safe to retry on failure. Built for CI/CD and automated pipelines.
Resources
Last updated: April 2026