API > Integrate API into your product
Video Generation API v2 — Generative & Performance Video
Base URL: https://api.phantaisia.com
All requests require a Bearer token in the Authorization header.
Authorization: Bearer <your_token>
Looking for the previous video endpoints?
single_frame_videoandfirst_last_frame_videoare deprecated but still documented in How to Use the Video API Endpoint. The earlier v2 endpointstext_to_video,image_to_videoandreference_to_videohave been replaced by the two endpoints on this page: per-second pricing, free duration from 5 to 15 seconds and a selectable resolution tier (Draft or HD+).
Overview
There are two ways to generate a personalized video:
| Endpoint | What it does | Input you provide |
|---|---|---|
POST /v1/run/generative_video |
AI Generative Video — turns the guest's photo into a video. The Video Filter decides how: face swapping the guest into a start (and end) frame, or using the photo as the first reference image | Guest photo + Video Filter (recommended), or the photo plus your own prompt and settings |
POST /v1/run/performance_video |
AI Performance Video — restyles the guest's recorded video while keeping their performance | Guest video (public URL) + Video Filter (recommended), or the video plus your own prompt and settings |
Every run endpoint returns a job ID immediately. Each endpoint has its own status endpoint — see Check Job Status.
Two ways to call each endpoint
Every endpoint can be called with a Video Filter or directly.
| Mode | How | When to use it |
|---|---|---|
| Video Filter | You send a video_filter_id (UUID of a Video AI Filter created in the Filter Creator) plus the guest's input. The gateway pulls the prompt, duration, resolution, aspect ratio, reference media and face swap filters from the filter |
Recommended. Set up the look once in the Filter Creator, then only send the guest's photo or video |
| Direct | You send the prompt and all render settings in the request | Full control, you manage prompts and settings in your own system |
Video Filters are created in the Filter Creator — see Faceswap: Video Filter. Each Video Filter has a generation mode that determines which endpoint it works with:
| Video Filter generation mode | Endpoint to call | What the filter supplies |
|---|---|---|
single_frame |
/v1/run/generative_video |
Prompt, duration, resolution, aspect ratio, one face swap filter (start frame) |
first_last_frame |
/v1/run/generative_video |
Prompt, duration, resolution, aspect ratio, two face swap filters (start + end frame) |
reference_to_video |
/v1/run/generative_video or /v1/run/performance_video |
Prompt, duration, resolution, aspect ratio, reference images, reference video, audio |
text_to_video |
— | Not supported on these endpoints; rejected with 400 VIDEO_FILTER_WRONG_MODE |
Override rules when a filter is used:
- The filter's prompt is always used; a
promptin the request is ignored. - The filter's duration wins over
durationin the request. Filters saved before a duration was stored use the request'sdurationinstead, so always send one. resolution_mpandaspect_ratiosent in the request override the filter's values.- On
performance_videothe guest'svideois always the request's.reference_imagesin the request are only used when the filter has none of its own.
Shared parameters
These fields behave the same on both endpoints.
| Field | Type | Description |
|---|---|---|
video_filter_id |
string |
UUID of a Video AI Filter. Optional — see Two ways to call each endpoint |
duration |
integer |
Video length in seconds, 5 to 15. Required on direct calls; with a filter, the filter's stored duration wins |
resolution_mp |
number |
Output size in megapixels: 0.7 (Draft), 0.9 (HD), 1.5 (HD+, default), 2.0 (Full HD). Falls back to the filter's quality, then 1.5. Also selects the price tier, see Pricing |
aspect_ratio |
string |
"1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", "21:9". Falls back to the filter's ratio, then "16:9" |
prompt |
string |
Required on direct calls. Ignored when a filter is used |
email |
string |
Optional. When set, the finished video link is emailed to this address once, as soon as the job completes. Useful for guests who leave the booth before the video is ready |
Images (image, first_frame, last_frame, reference_images) accept either a base64 data URI (data:image/jpeg;base64,...) or a publicly accessible URL. Base64 images are uploaded to our storage before generation. Videos and audio (video, audio) must be public URLs.
Pricing
Both endpoints are billed per second of generated video, so the cost scales linearly with duration. The rate depends on the endpoint and on the resolution tier: 0.7 MP bills as Draft, every other resolution (0.9, 1.5, 2.0) bills as HD+.
Credits are deducted when the job is accepted; if you do not have enough credits the request fails with 422 INSUFFICIENT_CREDITS before any job is created.
| Endpoint | Draft (0.7 MP) | HD+ (1.5 MP) | Face swaps |
|---|---|---|---|
generative_video |
1 credit / second | 1.5 credits / second | + 1 credit per face swap run by the filter (1 for a single_frame filter, 2 for a first_last_frame filter; none for reference_to_video) |
performance_video |
2 credits / second | 2.5 credits / second | none |
Examples
| Request | Calculation | Cost |
|---|---|---|
generative_video, Draft, 10 s |
10 × 1 | 10 credits |
generative_video, HD+, 10 s |
10 × 1.5 | 15 credits |
generative_video, HD+, 7 s |
7 × 1.5 | 10.5 credits |
generative_video, first_last_frame filter, HD+, 10 s |
2 face swaps + 10 × 1.5 | 17 credits |
performance_video, Draft, 10 s |
10 × 2 | 20 credits |
performance_video, HD+, 5 s |
5 × 2.5 | 12.5 credits |
For general credit information see What are the API prices and how much are my credits worth.
1. Generative Video
POST /v1/run/generative_video
Generates a video from the guest's photo. With a single_frame or first_last_frame Video Filter the gateway face swaps the guest into the filter's frame(s) and animates them; with a reference_to_video filter the photo becomes the first reference image and no face swap is run.
Request body — with a Video Filter
{
"video_filter_id": "uuid-of-video-ai-filter",
"image": "<base64-or-url-of-guest-photo>",
"gender": 1
}
Request body — direct
Without a filter, sending first_frame (and optionally last_frame) selects frame animation; otherwise the photo is used as the first reference image.
{
"prompt": "The subject turns towards the camera and smiles.",
"duration": 8,
"resolution_mp": 1.5,
"aspect_ratio": "9:16",
"image": "<base64-or-url-of-guest-photo>",
"first_frame": "<base64-or-url>",
"last_frame": "<base64-or-url>"
}
| Field | Type | Required | Description |
|---|---|---|---|
video_filter_id |
string |
No | UUID of a single_frame, first_last_frame or reference_to_video Video Filter |
image |
string |
Yes | The guest's photo, base64 or public URL — the face that gets swapped in, or the first reference image |
gender |
integer |
No (default 0) |
0 = Male, 1 = Female, 2 = Boy, 3 = Girl. Used for the face swaps |
prompt |
string |
Direct: Yes | Text description of the scene and motion. Ignored when a filter is used |
duration |
integer |
Direct: Yes | 5–15 seconds. With a filter, the filter's stored duration wins |
resolution_mp |
number |
Direct (frames): Yes | 0.7, 0.9, 1.5 or 2.0. Optional otherwise, default 1.5 |
aspect_ratio |
string |
Direct (frames): Yes | See Shared parameters |
first_frame |
string |
No | Start image, base64 or public URL. Selects frame animation on a direct call |
last_frame |
string |
No | End image, base64 or public URL. Omit to animate from the start frame only |
reference_images |
string[] |
No | Up to 2 further reference images after the guest photo (reference mode). Ignored when the filter has its own |
audio |
string |
No | Public URL of an audio track for the generated video (reference mode) |
email |
string |
No | Finished video link is emailed here once |
Response — 200 OK
{
"id": "i2v-8c21e4a90b7f",
"status": "IN_QUEUE",
"output": {}
}
The job ID starts with i2v- for frame animation and r2v- for reference-to-video. Poll POST /v1/status/generative_video/{job_id} with the id.
Errors
| HTTP | error_code |
Meaning |
|---|---|---|
400 |
VIDEO_FILTER_WRONG_MODE |
The Video Filter is a text_to_video filter, which takes no image |
400 |
VIDEO_FILTER_MISSING_FILTER |
The frame-based Video Filter has no AI filter attached, so there is nothing to face swap |
404 |
VIDEO_FILTER_NOT_FOUND |
No Video Filter with that video_filter_id |
422 |
INSUFFICIENT_CREDITS |
Not enough credits for face swap(s) + video |
422 |
VIDEO_DURATION_REQUIRED |
Neither the filter nor the request carries a duration |
422 |
INVALID_VIDEO_DURATION |
duration is not a whole number of seconds between 5 and 15 |
422 |
— | Validation error: image missing, more than 2 reference_images, or prompt / duration (and resolution_mp / aspect_ratio for frame animation) missing on a direct call |
If a face swap fails, the video job ends in failed — see Check Job Status.
2. Performance Video
POST /v1/run/performance_video
Restyles the guest's recorded video while keeping their performance: the look and the scene come from the Video Filter's prompt and reference images, the movement from the guest's video. No face swap is run in this mode.
Request body — with a Video Filter
{
"video_filter_id": "uuid-of-video-ai-filter",
"video": "https://example.com/guest-recording.mp4"
}
Request body — direct
{
"prompt": "The subject dances through a neon-lit street.",
"duration": 8,
"resolution_mp": 1.5,
"aspect_ratio": "9:16",
"video": "https://example.com/guest-recording.mp4",
"reference_images": ["<base64-or-url-of-ref-1>", "<base64-or-url-of-ref-2>"]
}
| Field | Type | Required | Description |
|---|---|---|---|
video_filter_id |
string |
No | UUID of a reference_to_video Video Filter |
video |
string |
Yes | Public URL of the guest's recorded video. Drives the motion of the result |
prompt |
string |
Direct: Yes | Text description of the look and scene. Ignored when a filter is used |
duration |
integer |
Direct: Yes | 5–15 seconds. With a filter, the filter's stored duration wins |
resolution_mp |
number |
No | 0.7, 0.9, 1.5 or 2.0. Falls back to the filter's quality, then 1.5 |
aspect_ratio |
string |
No | Falls back to the filter's ratio, then "16:9". See Shared parameters |
reference_images |
string[] |
No | Up to 2 reference images for the look. Ignored when the filter has its own |
email |
string |
No | Finished video link is emailed here once |
Response — 200 OK
{
"id": "r2v-5d0b7e3a1c48",
"status": "IN_QUEUE",
"output": {}
}
Poll POST /v1/status/performance_video/{job_id} with the id.
Errors
| HTTP | error_code |
Meaning |
|---|---|---|
400 |
VIDEO_FILTER_WRONG_MODE |
The Video Filter is not a reference_to_video filter |
404 |
VIDEO_FILTER_NOT_FOUND |
No Video Filter with that video_filter_id |
422 |
REFERENCE_VIDEO_REQUIRED |
No video was sent |
422 |
INSUFFICIENT_CREDITS |
Not enough credits for this request |
422 |
VIDEO_DURATION_REQUIRED / INVALID_VIDEO_DURATION |
No usable duration on the filter or in the request |
422 |
— | Validation error: more than 2 reference_images, or prompt / duration missing on a direct call |
3. Check Job Status
Each endpoint has its own status endpoint. Use the one matching the run endpoint you called:
| Run endpoint | Status endpoint |
|---|---|
/v1/run/generative_video |
POST /v1/status/generative_video/{job_id} |
/v1/run/performance_video |
POST /v1/status/performance_video/{job_id} |
The status endpoints are non-blocking — they return the current state immediately. Keep polling until the job reaches a terminal status.
Recommended polling interval: every 5–10 seconds. Video jobs typically take 1–3 minutes; longer and higher-resolution videos take longer. A job that has not finished after 6 minutes of generation is marked failed.
Path parameter
| Parameter | Type | Description |
|---|---|---|
job_id |
string |
The id returned from the run endpoint (i2v-… or r2v-…) |
Response — in progress
{
"id": "r2v-5d0b7e3a1c48",
"status": "processing",
"output": null
}
Response — completed
{
"id": "r2v-5d0b7e3a1c48",
"status": "completed",
"output": {
"video_url": "https://..."
}
}
Response — failed
{
"id": "r2v-5d0b7e3a1c48",
"status": "failed",
"output": null
}
Status values
| Status | Terminal | Meaning |
|---|---|---|
pending |
No | Job is queued (including any face swaps that run first) |
processing |
No | Job is actively generating |
completed |
Yes | Video is ready — output.video_url contains the download link |
failed |
Yes | Generation failed or timed out — stop polling. Credits are not refunded automatically; contact support if a job fails repeatedly |
Note: The run endpoints answer with
"status": "IN_QUEUE", while the status endpoints report the job state in lowercase (pending,processing,completed,failed). Compare statuses case-insensitively to be safe.
End-to-end example (JavaScript)
const TOKEN = 'your_token_here';
const BASE = 'https://api.phantaisia.com';
async function generateVideo(mode, body) {
// 1. Submit job
const runRes = await fetch(`${BASE}/v1/run/${mode}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${TOKEN}`,
},
body: JSON.stringify(body),
});
if (!runRes.ok) throw new Error(`Submit failed: ${await runRes.text()}`);
const { id } = await runRes.json();
console.log('Job submitted:', id);
// 2. Poll for result on the matching status endpoint
while (true) {
await new Promise(r => setTimeout(r, 7000));
const statusRes = await fetch(`${BASE}/v1/status/${mode}/${id}`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${TOKEN}` },
});
if (!statusRes.ok) throw new Error(`Status error: ${await statusRes.text()}`);
const data = await statusRes.json();
const status = String(data.status).toLowerCase();
console.log('Status:', status);
if (status === 'completed') {
return data.output.video_url;
}
if (status === 'failed') {
throw new Error('Generation failed');
}
}
}
// Generative video with a Video Filter (guest photo in, video out)
const guestUrl = await generateVideo('generative_video', {
video_filter_id: 'uuid-of-video-ai-filter',
image: 'https://example.com/selfie.jpg',
gender: 1,
email: 'guest@example.com', // optional: emails the link when ready
});
// Performance video with a Video Filter (guest recording in, restyled video out)
const performanceUrl = await generateVideo('performance_video', {
video_filter_id: 'uuid-of-video-ai-filter',
video: 'https://example.com/guest-recording.mp4',
});
// Generative video, direct (frame animation; Draft resolution)
const directUrl = await generateVideo('generative_video', {
prompt: 'The subject turns towards the camera and smiles.',
duration: 8,
resolution_mp: 0.7,
aspect_ratio: '9:16',
image: 'https://example.com/selfie.jpg',
first_frame: 'https://example.com/start.jpg',
});
Migrating from the previous endpoints
| Previous endpoints | New endpoints |
|---|---|
/v1/run/image_to_video with img + video_filter_id |
/v1/run/generative_video with image + video_filter_id |
/v1/run/image_to_video with first_frame (+ last_frame) |
/v1/run/generative_video with image + first_frame (+ last_frame) |
/v1/run/reference_to_video with prompt_image (generative) |
/v1/run/generative_video with image |
/v1/run/reference_to_video with video (performance) |
/v1/run/performance_video with video |
/v1/run/single_frame_video / /v1/run/first_last_frame_video |
/v1/run/generative_video with a single_frame / first_last_frame Video Filter |
model: simple / advanced / performance |
No model field. The price tier comes from resolution_mp: Draft (0.7) or HD+ |
Quick / Advanced rate by the filter's video_model |
Draft / HD+ rate by resolution, see Pricing |
duration: "4s" / "6s" / "8s" |
duration: integer 5–15 |
/v1/status/image_to_video/{job_id}, /v1/status/reference_to_video/{job_id} |
/v1/status/generative_video/{job_id}, /v1/status/performance_video/{job_id} |