Automate UGC Video Ads with the agent-media API
The problem: manual UGC does not scale
A typical paid social workflow looks like this: write a script, hire a creator, wait for delivery, request revisions, export variants. For a single video that takes days. For a campaign with 50 variants across different looks and hooks, it takes weeks and thousands of dollars.
The solution: generate UGC videos programmatically
The agent-media API generates a video of an AI person from a text description or a reference photo, with native audio and subtitles burned in by default, as a single API call. You send a description of the actor and a script, and you get back a finished MP4. No editor, no uploads, no waiting for human creators.
Everything below works with the TypeScript SDK, the Python SDK, or raw HTTP calls. Pick whichever fits your stack.
Get your API key
Sign up at agent-media.ai, go to your dashboard, and copy your API key. It starts with ma_. Set it as an environment variable so your code can pick it up:
AGENT_MEDIA_API_KEY=ma_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Install the SDK
Install the official SDK for your language. Both packages wrap the REST API with typed helpers and automatic retries.
npm install @agentmedia/sdk
pip install agent-media
Generate your first video
A single call to POST /v2/generate/video sends your description and script to the generator and returns a job you can poll until the clip is ready.
curl -X POST https://api.agent-media.ai/v2/generate/video \
-H "Authorization: Bearer $AGENT_MEDIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A woman in her late 20s, warm and natural, kitchen morning light, says: I tried this protein powder for 30 days and the results were insane. It mixes clean, no chalky taste, and I actually look forward to drinking it. Link in bio.",
"seconds": 10,
"aspect": "9:16"
}'
{
"job_id": "job_abc123",
"status": "submitted",
"kind": "video",
"model": "seedance-2.0",
"credits_deducted": 600,
"status_url": "https://api.agent-media.ai/v1/videos/job_abc123"
}
Poll the status URL until the job completes:
curl https://api.agent-media.ai/v1/videos/job_abc123 \
-H "Authorization: Bearer $AGENT_MEDIA_API_KEY"
That is it. One API call, one finished video. The response includes the video URL, duration, credit cost, and metadata.
Batch generate variants
The real power of API-driven UGC is batch generation. Loop over a matrix of person descriptions and scripts to produce dozens of variants in parallel. Each combination becomes a unique ad creative you can A/B test.
import { AgentMedia } from "@agentmedia/sdk";
const descriptions = [
"woman in her late 20s, warm and natural, kitchen morning light",
"man in his 30s, confident and direct, home office",
"woman in her early 20s, energetic, bedroom mirror",
];
const scripts = [
"This changed my morning routine. I wake up, one scoop, done.",
"I was skeptical but after two weeks the results speak for " +
"themselves. Just try it.",
"My trainer recommended this and honestly it is the best " +
"supplement I have ever used. Link in bio.",
];
const jobs = descriptions.flatMap((description) =>
scripts.map((script) =>
fetch("https://api.agent-media.ai/v2/generate/video", {
method: "POST",
headers: {
Authorization: `Bearer \${process.env.AGENT_MEDIA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: `\${description}, says: \${script}`,
seconds: 10,
aspect: "9:16",
}),
}).then((res) => res.json())
)
);
// 9 variants generated in parallel
const jobResults = await Promise.all(jobs);
for (const job of jobResults) {
console.log(job.status_url);
}
3 descriptions multiplied by 3 scripts equals 9 unique ad creatives, generated with a single script run. Scale the matrix to 10 descriptions and 10 scripts for 100 variants.
Check job status for async processing
For production pipelines, you probably do not want to hold a connection open while the video renders. Submit the job, store the job_id, and poll the status URL from a background worker.
// Fire and forget: submit, store the job id, poll later
const job = await fetch("https://api.agent-media.ai/v2/generate/video", {
method: "POST",
headers: {
Authorization: `Bearer \${process.env.AGENT_MEDIA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "woman in her late 20s, warm and natural, kitchen morning light, says: This serum changed my skin in two weeks.",
seconds: 10,
aspect: "9:16",
}),
}).then((res) => res.json());
console.log(job.job_id); // "job_abc123", track it in your DB
With the CLI, wait for a job and save the result in two commands:
agent-media status job_abc123 --watch
agent-media download job_abc123 -o clip.mp4
Once the job reports completed, the status response includes the finished video URL, duration, and credit cost.
Python example
The same flow works from Python with httpx or any HTTP client. The request and response shapes are identical, just a different language.
import asyncio
import httpx
API_KEY = "ma_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
descriptions = [
"woman in her late 20s, warm and natural, kitchen morning light",
"man in his 30s, confident and direct, home office",
"woman in her early 20s, energetic, bedroom mirror",
]
script = (
"I tried this protein powder for 30 days and the "
"results were insane. It mixes clean, no chalky taste."
)
async def generate(client, description):
response = await client.post(
"https://api.agent-media.ai/v2/generate/video",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"prompt": f"{description}, says: {script}",
"seconds": 10,
"aspect": "9:16",
},
)
return response.json()
async def main():
async with httpx.AsyncClient() as client:
jobs = await asyncio.gather(
*(generate(client, description) for description in descriptions)
)
for job in jobs:
print(job["status_url"])
asyncio.run(main())
CLI: one command, one video
If you prefer the terminal over code, the agent-media CLI wraps the same generator in a single command. Great for quick tests, shell scripts, and CI/CD pipelines.
$ agent-media selfie \
--description "woman in her late 20s, warm and natural, kitchen morning light" \
--script "I tried this protein powder for 30 days and the results were insane." \
--duration 10
Submitted job_def456
$ agent-media status job_def456 --watch
Generating portrait...
Generating character sheet...
Generating storyboard...
Animating with Seedance 2.0...
Burning subtitles (hormozi)...
Completed in 58s | 325 credits
$ agent-media download job_def456 -o clip.mp4
Saved clip.mp4
The CLI submits the job and returns right away. Chain status --watch and download into a loop, a Makefile, or a GitHub Action to wait for and collect the finished clip.
Real-world use cases
Teams are using the agent-media API across industries to automate creative production at scale.
Pricing: credits per second
The API uses the same credit system as the dashboard. A finished talking-head video costs 45 credits plus 28 per second, so a 10-second ad is 325 credits. A raw Seedance 2.0 clip is 30 credits per second at 480p and 60 at 720p.
Need more? Add credits from $50 for 5,000, on any plan. Credits you buy never expire. See the full breakdown on the pricing page.
Start automating UGC video creation
One API call. One finished video. Scale to hundreds of variants per campaign without touching a video editor.
Published April 14, 2026 by the agent-media team. Code examples use the latest SDK versions as of publication. Check the API docs for the most up-to-date reference.
Related: Best AI UGC Generator for Developers Create a UGC Video from Your Terminal AI UGC Pricing Comparison 2026
What do you sell?
First video free, no card