Python SDK
Generate UGC video ads from Python.
Last updated: May 2026
Sync and async Python client with full type hints. One import, one method call, one finished MP4. Polling helpers for show-your-app, laptop-ugc, and product-acting flows. Works with FastAPI, Django, Flask, Jupyter, and async agent loops.
Install
pip install agent-media # or poetry add agent-media uv add agent-media
Generate a UGC ad
Sync version blocks; async version yields. Both fully typed.
from agent_media import AgentMedia
client = AgentMedia(api_key="...")
# create_video() submits + polls + returns the finished result
video = client.create_video(
actor_slug="sofia",
script="Try this AI tool that builds your UGC ads in seconds.",
target_duration=10,
subtitle_style="hormozi",
)
print(video["video_url"])
# → https://r2.../video.mp4import asyncio
from agent_media import AsyncAgentMedia
async def main():
async with AsyncAgentMedia(api_key="...") as client:
# Submit and poll separately, or use a wrapper helper
job = await client.submit_video(
actor_slug="sofia",
script="Try this AI tool...",
target_duration=10,
)
# Poll until done
while True:
status = await client.get_video_status(job["job_id"])
if status["status"] in ("completed", "failed"):
break
await asyncio.sleep(5)
print(status["video_url"])
asyncio.run(main())What you get
Full type hints
Type hints on every method and response. Works with mypy, pyright, and IDE autocomplete.
Sync + async clients
AgentMedia for scripts, AsyncAgentMedia for asyncio / FastAPI / agent loops.
Polling helpers
create_video(), create_show_your_app(), and create_laptop_ugc() submit + poll + return the finished video URL.
Webhook delivery
Pass webhook_url in any submit call; we POST job-completion events to your HTTPS endpoint.
Context-manager friendly
with AgentMedia(...) as client closes connections cleanly. Async equivalent via async with.
Python 3.9+
Wide runtime support. Pure Python, no native deps.
Frequently Asked Questions
Is there a Python SDK for AI UGC video generation?
Yes. agent-media ships agent-media on PyPI — sync and async Python clients with full type hints. Other UGC video tools either have no Python SDK (Arcads, MakeUGC) or only an unofficial wrapper.
Does it support asyncio / FastAPI?
Yes. AsyncAgentMedia works in any asyncio context. Use it directly in FastAPI route handlers or agent loops without blocking the event loop.
Can I use this from a Jupyter notebook?
Yes. The sync client works in any notebook cell. For async, use await directly in cells (Jupyter supports top-level await).
Does the SDK work with LangChain or LlamaIndex?
Yes. The Python SDK is plain Python; wrap it in a LangChain tool or LlamaIndex action. For Claude Code or Cursor, prefer our MCP server — it's purpose-built for agent loops.
Is the SDK open source?
Yes. Apache-2.0. Source on GitHub. PRs welcome.