Video Generation
Generate videos from text prompts or input images using Fluxpool's unified API. Supports 5+ video models through a single endpoint.
OpenAI-compatible. This endpoint follows the OpenAI images/generations pattern with video extensions. If you've used the OpenAI SDK, you're ready.
Overview #
Video generation is asynchronous. Unlike image generation, video models take 30–120 seconds to produce output. The flow is:
- Submit a generation request → receive a generation_id
- Poll the status endpoint or receive a webhook callback when complete
- Retrieve the video URL from the completed response
Recommended: Use webhooks instead of polling. They're faster and reduce unnecessary API calls.
Endpoint #
Request Body #
Text-to-Video #
Generate a video from a text prompt.
{
"model": "wan-video-2.1",
"prompt": "A drone shot flying through cherry blossom trees, slow motion, cinematic lighting",
"duration": 5,
"resolution": "1280x720",
"webhook_url": "https://your-app.com/api/webhook"
}
Image-to-Video #
Animate a static image into a video. Pass an image URL or base64 in place of (or alongside) prompt.
{
"model": "kling-v2",
"prompt": "Camera slowly zooms out, leaves rustling in wind",
"image": "https://your-bucket.s3.amazonaws.com/input-image.png",
"duration": 5,
"resolution": "1080p",
"webhook_url": "https://your-app.com/api/webhook"
}
Not all models support image-to-video. See the model table below for supported input types per model.
Available Models #
| Model | ID | Input Types | Max Duration | Max Resolution | Avg. Speed | Cost |
|---|---|---|---|---|---|---|
| Wan Video 2.1 | wan-video-2.1 | Text Image | 10s | 1280×720 | ~45s | $0.15/video |
| Kling v2 | kling-v2 | Text Image | 10s | 1080p | ~60s | $0.20/video |
| Runway Gen-3 Alpha | runway-gen3 | Text Image | 10s | 1080p | ~90s | $0.50/video |
| Hunyuan Video | hunyuan-video | Text | 6s | 720p | ~50s | $0.12/video |
| Luma Dream Machine | luma-dream | Text Image | 5s | 1080p | ~40s | $0.18/video |
Full model details, parameters, and sample outputs: Browse all models →
Response #
A successful request returns a generation object with status processing.
{
"id": "gen_abc123xyz",
"status": "processing",
"model": "wan-video-2.1",
"created_at": "2025-01-15T10:30:00Z",
"estimated_completion": "2025-01-15T10:30:45Z",
"output": null
}
When complete, the output field populates:
{
"id": "gen_abc123xyz",
"status": "completed",
"model": "wan-video-2.1",
"created_at": "2025-01-15T10:30:00Z",
"completed_at": "2025-01-15T10:30:43Z",
"output": {
"url": "https://cdn.fluxpool.ai/v/gen_abc123xyz.mp4",
"duration": 5,
"resolution": "1280x720",
"format": "mp4",
"size_bytes": 4821504
}
}
Possible status values:
| Status | Description |
|---|---|
| processing | Generation is in progress |
| completed | Video is ready. output.url is available. |
| failed | Generation failed. See error field. |
Polling for Results #
If you're not using webhooks, poll the status endpoint:
import time
from openai import OpenAI
client = OpenAI(
base_url="https://api.fluxpool.ai/v1",
api_key="fp_your_api_key"
)
# Submit generation
generation = client.videos.generate(
model="wan-video-2.1",
prompt="A koi fish transforming into a phoenix, slow motion"
)
# Poll until complete
while generation.status == "processing":
time.sleep(5)
generation = client.videos.retrieve(generation.id)
print(generation.output.url)
Polling interval: Wait at least 5 seconds between polls. Excessive polling may trigger rate limits. Webhooks are strongly recommended for production use.
Using Webhooks #
Send a webhook_url in your request. Fluxpool will POST the completed generation object to your URL when the video is ready.
{
"model": "kling-v2",
"prompt": "Timelapse of a flower blooming in a dark room, dramatic lighting",
"duration": 5,
"webhook_url": "https://your-app.com/api/fluxpool-webhook"
}
Your webhook endpoint will receive:
{
"event": "generation.completed",
"data": {
"id": "gen_abc123xyz",
"status": "completed",
"model": "kling-v2",
"output": {
"url": "https://cdn.fluxpool.ai/v/gen_abc123xyz.mp4",
"duration": 5,
"resolution": "1080p",
"format": "mp4"
}
}
}
For webhook security, signature verification, and retry logic, see the full Webhooks documentation →
Code Examples #
from openai import OpenAI
client = OpenAI(
base_url="https://api.fluxpool.ai/v1",
api_key="fp_your_api_key"
)
# Text-to-Video
generation = client.videos.generate(
model="wan-video-2.1",
prompt="A cyberpunk city street in heavy rain, neon reflections, cinematic",
duration=5,
resolution="1280x720",
webhook_url="https://your-app.com/api/webhook" # optional
)
print(f"Generation ID: {generation.id}")
print(f"Status: {generation.status}")
# Image-to-Video
generation = client.videos.generate(
model="kling-v2",
prompt="Camera slowly orbits the subject, shallow depth of field",
image="https://your-bucket.s3.amazonaws.com/photo.png",
duration=5
)
Parameters Reference #
Full list of request body parameters.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | — | Model ID. See Available Models. |
| prompt | string | Yes | — | Text description of the video to generate. Max 1000 characters. |
| image | string | No | null | URL or base64-encoded image for image-to-video generation. Supported by select models. |
| duration | integer | No | 5 | Video duration in seconds. Range depends on model (typically 2–10s). |
| resolution | string | No | Model default | Output resolution. Options: "720p", "1080p", "1280x720", "1920x1080". Availability varies by model. |
| seed | integer | No | Random | Seed for reproducibility. Same seed + same prompt + same model = same output. |
| negative_prompt | string | No | null | What to avoid in the generation. Not supported by all models. |
| webhook_url | string | No | null | URL to receive a POST callback when generation completes. See Webhooks. |
| metadata | object | No | null | Arbitrary key-value pairs attached to the generation. Returned in response and webhook payload. Useful for tracking. |
Error Handling #
If a generation fails, the response status will be "failed" with an error object:
{
"id": "gen_abc123xyz",
"status": "failed",
"model": "wan-video-2.1",
"error": {
"code": "content_policy_violation",
"message": "The prompt was flagged by the content safety filter."
}
}
Common error codes:
| Code | Description |
|---|---|
| content_policy_violation | Prompt or output flagged by safety filters. Revise the prompt. |
| model_unavailable | The requested model is temporarily offline. Check status.fluxpool.ai. |
| invalid_parameters | One or more parameters are invalid for the selected model. |
| insufficient_credits | Your account has insufficient credits. Top up → |
| rate_limit_exceeded | Too many concurrent requests. See Rate Limits. |
| generation_timeout | The generation exceeded the maximum processing time. Retry. |
Cost & Billing #
Each video generation deducts credits from your account balance. Cost varies by model, duration, and resolution.
| Factor | Impact |
|---|---|
| Model | Higher-quality models cost more. runway-gen3 > wan-video-2.1. |
| Duration | Longer videos cost more (roughly linear). |
| Resolution | Higher resolution costs more. 1080p > 720p. |
Credits are deducted when generation begins. If a generation fails, credits are refunded automatically.
Rate Limits #
| Tier | Concurrent Generations | Requests/Minute |
|---|---|---|
| Free | 1 | 5 |
| Pay As You Go | 3 | 20 |
| Enterprise | Custom | Custom |
Rate limit headers are included in every response:
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 17
X-RateLimit-Reset: 1705312200
If you exceed the limit, you'll receive a 429 Too Many Requests response. Implement exponential backoff.
Need higher limits? Contact us →