โ† Back to blog

AI Video Generation API: Text-to-Video for AI Agents (Wan 2.5)

July 13, 2026 ยท Eric ยท 7 min read

Your AI agent just wrote a script, generated an image, and composed a tweet โ€” but what if it could also create a short video clip from a text description? Imagine an agent that generates product demos, social media snippets, explainer animations, or creative visualizations on the fly.

Agent Media Tools now offers an AI video generation API powered by Wan 2.5 via fal.ai. Submit a text prompt, wait a minute or two, and download the resulting MP4. It works from curl, Python, n8n, or directly from an AI agent via MCP โ€” and since it's an async job, your agent can poll for status or register a webhook to get notified when the video is ready.

Why AI Video Generation for Agents?

Text-to-image is everywhere now. Text-to-video is the next frontier โ€” and it's finally practical for API-driven workflows. Here's why your agent should be able to generate video:

How It Works

Unlike instant APIs that return results in milliseconds, AI video generation is compute-intensive. Each request takes 1โ€“3 minutes depending on the duration and complexity. That's why the video generation API uses Agent Media Tools' async job queue:

  1. You submit a text prompt (and optionally a starting image) as a job
  2. You get a job_id back immediately
  3. You poll GET /api/jobs/:id to track progress (0โ€“100%)
  4. When the job completes, the response includes download URLs for the generated MP4
  5. Videos are available for 1 hour โ€” download immediately

Optionally, you can register a webhook and get a POST notification when generation finishes โ€” no polling required.

API Overview

PropertyValue
EndpointPOST /api/agent/generate-video
Content-Typeapplication/json
Auth requiredYes โ€” Bearer API key
Required fieldprompt (text description of the video)
Optional fieldsnum_seconds (3โ€“10, default 5), image_url (image-to-video)
Responsejob_id โ€” poll for result
Duration1โ€“3 minutes typical
OutputMP4 video, downloadable for 1 hour
Pricing3 credits per second of generated video
ModelWan 2.5 (via fal.ai)

๐Ÿ’ก Need an API key? Sign up free at agentmediatools.com and generate a key from your account settings. Free accounts can use credits to generate videos.

curl Examples

๐Ÿ’ก Windows users: Run these from Git Bash or WSL โ€” PowerShell's curl is an alias for Invoke-WebRequest. Or use Invoke-RestMethod with the same URL/body.

Submit a Text-to-Video Job

curl -X POST https://agentmediatools.com/api/agent/generate-video \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "prompt": "A serene mountain lake at sunset, with golden light reflecting on the water and pine trees swaying in the breeze",
    "num_seconds": 5
  }'

Response (immediate โ€” job queued):

{
  "success": true,
  "job_id": "job_v001_a1b2c3d4e5",
  "status": "queued",
  "position": 1,
  "estimated_seconds": 90
}

You'll get a job_id back. Now poll for the result:

curl -s https://agentmediatools.com/api/jobs/job_v001_a1b2c3d4e5 \
  -H "Authorization: Bearer YOUR_API_KEY"

Polling response while processing:

{
  "job_id": "job_v001_a1b2c3d4e5",
  "status": "processing",
  "progress": 65,
  "progress_label": "Generating video frames..."
}

Polling response when complete:

{
  "job_id": "job_v001_a1b2c3d4e5",
  "status": "completed",
  "result": {
    "video_url": "https://agentmediatools.com/download/video_a1b2c3d4e5.mp4",
    "duration_seconds": 5,
    "size_bytes": 2843168,
    "format": "mp4",
    "prompt": "A serene mountain lake at sunset, with golden light reflecting on the water and pine trees swaying in the breeze"
  },
  "created_at": "2026-07-13T14:30:00Z",
  "completed_at": "2026-07-13T14:31:25Z"
}

Download with curl:

curl -o sunset_lake.mp4 \
  "https://agentmediatools.com/download/video_a1b2c3d4e5.mp4"

โฑ๏ธ Pro tip: Poll every 10โ€“15 seconds with a short timeout. Add ?scroll=true for longer timeouts on slow connections. Or skip polling entirely by registering a webhook โ€” we'll POST the result to your URL when generation finishes.

Generate a Longer Clip (10 seconds)

curl -X POST https://agentmediatools.com/api/agent/generate-video \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "prompt": "Cyberpunk city street at night, neon signs reflecting on wet pavement, flying cars in the distance, cinematic lighting",
    "num_seconds": 10
  }'

10-second videos cost 30 credits (3 credits ร— 10 seconds) and take 2โ€“3 minutes to generate.

Image-to-Video (Animation from a Starting Frame)

If you already have an image โ€” maybe one generated by the image generation API โ€” you can animate it by passing an image_url:

curl -X POST https://agentmediatools.com/api/agent/generate-video \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "prompt": "The character waves gently at the camera, smiling",
    "image_url": "https://agentmediatools.com/download/artwork_xyz789.png",
    "num_seconds": 4
  }'

This creates a short animation that brings your still image to life โ€” the model uses the image as the starting frame and generates motion based on the prompt.

Python Examples

Submit a Video Generation Job and Poll for Results

import requests
import time
import sys

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://agentmediatools.com"

# Step 1: Submit the job
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_KEY}"
}

payload = {
    "prompt": "A cat wearing a detective hat, walking through a noir-style rainy alley, dramatic shadows",
    "num_seconds": 5
}

resp = requests.post(
    f"{BASE_URL}/api/agent/generate-video",
    headers=headers,
    json=payload
)
data = resp.json()
job_id = data["job_id"]
print(f"๐ŸŽฌ Job submitted: {job_id}")
print(f"   Estimated: {data.get('estimated_seconds', 90)} seconds")

# Step 2: Poll until complete
while True:
    poll = requests.get(
        f"{BASE_URL}/api/jobs/{job_id}",
        headers=headers
    )
    status = poll.json()

    if status["status"] == "completed":
        print(f"\nโœ… Video ready!")
        video_url = status["result"]["video_url"]
        print(f"   Duration: {status['result']['duration_seconds']}s")
        print(f"   Size: {status['result']['size_bytes'] / 1024 / 1024:.1f} MB")
        print(f"   Download: {video_url}")

        # Download the video
        video_resp = requests.get(video_url)
        filename = f"detective_cat_{status['result']['duration_seconds']}s.mp4"
        with open(filename, "wb") as f:
            f.write(video_resp.content)
        print(f"   Saved as: {filename}")
        break

    elif status["status"] == "failed":
        print(f"\nโŒ Failed: {status.get('error', 'Unknown error')}")
        sys.exit(1)

    else:
        progress = status.get("progress", 0)
        label = status.get("progress_label", "Queued...")
        print(f"   [{progress}%] {label}", end="\r")
        time.sleep(10)

Using the Python SDK

The upcoming agentmediatools Python package will make video generation simpler after registry publication. Until then, use the REST example above:

from agentmediatools import Client

client = Client(api_key="YOUR_API_KEY")

# Submit the job
job = client.generate_video(
    prompt="Slow motion waves crashing on a tropical beach at golden hour",
    num_seconds=5
)

# Wait for result (polls automatically)
result = job.wait(timeout=180)

# Download the video
result.download("beach_waves.mp4")
print(f"Downloaded {result.duration_seconds}s video to beach_waves.mp4")

Via MCP (for Claude Desktop / Cursor)

If you use the Agent Media Tools MCP server, your agent can generate videos directly from natural language:

"Create a 5-second video of a futuristic city with flying cars and neon lights"

The MCP server exposes the generate_video tool. Claude will submit the job, poll for progress, and when the video is ready, it can show you the download link โ€” all from a single instruction.

This is especially powerful in multi-step workflows:

"Generate an image of a sci-fi spaceship, then animate it with a slow flyby effect"

Claude will call generate_image first, grab the output URL, then call generate_video with that URL as the image_url parameter โ€” all orchestrated automatically.

Image-to-Video vs. Text-to-Video

ModeInputBest For
Text-to-videoPrompt onlyGenerating scenes from scratch โ€” landscapes, abstract concepts, atmospheric clips
Image-to-videoPrompt + image URLAnimating existing artwork, adding motion to AI-generated images, content repurposing

Both modes use the same endpoint and accept the same parameters โ€” just include image_url when you want to animate from a starting frame.

Progress Monitoring via Webhooks

Polling is simple, but webhooks are better. If you've registered a webhook URL in the Webhooks UI, video generation jobs automatically fire job.completed and job.failed events.

This means you can:

See the webhooks guide for setup instructions and receiver examples.

Pricing and Limits

AI video generation is a premium, credits-based tool:

DurationCostTypical Wait
3 seconds9 credits~45โ€“60 seconds
5 seconds15 credits~60โ€“90 seconds
10 seconds30 credits~2โ€“3 minutes

Purchase credit packs on the Pricing page:

Credits never expire and are shared across all your API keys. You can check your balance anytime with GET /api/agent/status or in your account settings.

Practical Use Cases

1. Social Media Content Batching

An agent generates 10 short video clips from a list of product features, each 5 seconds long, then uploads them to a scheduling platform. Total time: ~15 minutes of generation for a week's worth of content.

2. Automated Newsletter Previews

A weekly newsletter agent writes the edition, generates a matching 3-second animated intro clip, attaches the video to the email, and sends โ€” all without human involvement.

3. Concept Storyboarding

A creative director describes a scene in text, the agent generates a 5-second video, and the team reviews it before committing to full production. Iterate on prompts until the motion matches the vision.

4. Multi-Modal Agent Demos

An AI agent explains a complex topic (e.g., "how a combustion engine works") by generating a short animated diagram video from a text description, then presenting it alongside the written explanation.

Comparison: Why Use This Over Direct API Access?

FeatureAgent Media ToolsDirect fal.ai / Wan API
Auth setupSingle API keyOAuth / complex auth flow
Job managementBuilt-in async queueMust build your own
Progress pollingBuilt-in, returns % and labelMust implement yourself
Webhook on completeAutomatic (if configured)Must build your own
MCP integrationBuilt-in toolNot available
BillingCredit packs, never expiresPay-per-request + data egress
Unified ecosystemSame key for 70+ toolsVideo-only service

The value isn't just the model โ€” it's the pipeline infrastructure built around it. Async jobs, progress tracking, webhooks, and MCP integration turn a raw model API into something your agent can actually rely on.

Getting Started

  1. Sign up at agentmediatools.com โ€” it's free
  2. Generate an API key from your account settings
  3. Buy credits on the Pricing page (100 credits = $5 โ€” enough for 33 videos)
  4. Submit your first video job using the curl command above
  5. Poll or wait โ€” your video will be ready in 1โ€“3 minutes
  6. Download and share โ€” videos auto-delete after 1 hour

โšก Want to see it in action? Use the web UI at agentmediatools.com โ†’ Video Tools โ†’ โœจ AI Generate. Type a prompt, select a duration, and watch the progress bar fill up. No coding required to try it.

What's Next?

AI video generation is evolving fast. Here's what's on the roadmap:

All of these will be accessible through the same POST /api/agent/generate-video endpoint when they launch.

๐ŸŽฌ Generate Your First AI Video

Sign up at agentmediatools.com, grab your API key, buy a small credit pack, and run the curl command above. In under two minutes you'll have a video generated from your description โ€” no GPU needed, no model setup, no infrastructure.

โ†’ Visit Agent Media Tools  ยท  ๐Ÿ“– API Docs  ยท  ๐Ÿ’ฌ Discord

Tags: video generation, text-to-video, AI video, Wan 2.5, AI agent API, async jobs, MCP video generation, generative AI, video API