This model produces high-quality character animations, accurately capturing expressions and movements from reference videos.
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.
How to Make a Call
Step-by-Step Instructions
Generating a video using this model involves sequentially calling two endpoints:
The first one is for creating and sending a video generation task to the server (returns a generation ID).
The second one is for requesting the generated video from the server using the generation ID received from the first endpoint.
Below, you can find two corresponding API schemas and examples for both endpoint calls.
API Schemas
Video Generation
This endpoint creates and sends a video generation task to the server — and returns a generation ID.
post
Body
modelstring · enumRequiredPossible values:
video_urlstring · uriRequired
A HTTPS URL pointing to a video or a data URI containing a video. This video will be used as a reference during generation.
image_urlstring · uriRequired
A direct link to an online image or a Base64-encoded local image. If the input image does not match the chosen aspect ratio, it is resized and center cropped
resolutionstring · enumOptional
The resolution of the output video, where the number refers to the short side in pixels.
Default: 480pPossible values:
num_inference_stepsintegerOptional
Number of inference steps for sampling. Higher values give better quality but take longer
Default: 20
enable_safety_checkerbooleanOptional
If set to true, the safety checker will be enabled.
shiftnumberOptional
Shift value for the video.
Default: 5
video_qualitystring · enumOptional
The quality of the generated video.
Default: highPossible values:
video_write_modestring · enumOptional
The write mode of the output video. Faster write mode means faster results but larger file size, balanced write mode is a good compromise between speed and quality, and small write mode is the slowest but produces the smallest file size
Default: balancedPossible values:
Responses
200Success
application/json
post
/v2/video/generations
200Success
Fetch the video
After sending a request for video generation, this task is added to the queue. This endpoint lets you check the status of a video generation task using its id, obtained from the endpoint described above.
If the video generation task status is completed, the response will include the final result — with the generated video URL and additional metadata.
import requests
import time
# replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key
api_key = "<YOUR_AIMLAPI_KEY>"
base_url = "https://api.aimlapi.com/v2"
# Creating and sending a video generation task to the server
def generate_video():
url = f"{base_url}/video/generations"
headers = {
"Authorization": f"Bearer {api_key}",
}
data = {
"model": "alibaba/wan2.2-14b-animate-move",
"video_url": "https://storage.googleapis.com/falserverless/example_inputs/wan_animate_input_video.mp4",
"image_url": "https://s2-111386.kwimgs.com/bs2/mmu-aiplatform-temp/kling/20240620/1.jpeg",
"resolution": "720p",
}
response = requests.post(url, json=data, headers=headers)
if response.status_code >= 400:
print(f"Error: {response.status_code} - {response.text}")
else:
response_data = response.json()
print(response_data)
return response_data
# Requesting the result of the task from the server using the generation_id
def get_video(gen_id):
url = f"{base_url}/video/generations"
params = {
"generation_id": gen_id,
}
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.get(url, params=params, headers=headers)
return response.json()
def main():
# Running video generation and getting a task id
gen_response = generate_video()
gen_id = gen_response.get("id")
print("Generation ID: ", gen_id)
# Trying to retrieve the video from the server every 10 sec
if gen_id:
start_time = time.time()
timeout = 600
while time.time() - start_time < timeout:
response_data = get_video(gen_id)
if response_data is None:
print("Error: No response from API")
break
status = response_data.get("status")
print("Status:", status)
if status == "waiting" or status == "active" or status == "queued" or status == "generating":
print("Still waiting... Checking again in 10 seconds.")
time.sleep(10)
else:
print("Processing complete:\n", response_data)
return response_data
print("Timeout reached. Stopping.")
return None
if __name__ == "__main__":
main()
const https = require("https");
const { URL } = require("url");
// Replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key
const apiKey = "<YOUR_AIMLAPI_KEY>";
const baseUrl = "https://api.aimlapi.com/v2";
// Creating and sending a video generation task to the server
function generateVideo(callback) {
const data = JSON.stringify({
model: "alibaba/wan2.2-14b-animate-move",
video_url: "https://storage.googleapis.com/falserverless/example_inputs/wan_animate_input_video.mp4",
image_url: "https://s2-111386.kwimgs.com/bs2/mmu-aiplatform-temp/kling/20240620/1.jpeg",
resolution: "720p",
});
const url = new URL(`${baseUrl}/video/generations`);
const options = {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
"Content-Length": Buffer.byteLength(data),
},
};
const req = https.request(url, options, (res) => {
let body = "";
res.on("data", (chunk) => body += chunk);
res.on("end", () => {
if (res.statusCode >= 400) {
console.error(`Error: ${res.statusCode} - ${body}`);
callback(null);
} else {
const parsed = JSON.parse(body);
callback(parsed);
}
});
});
req.on("error", (err) => console.error("Request error:", err));
req.write(data);
req.end();
}
// Requesting the result of the task from the server using the generation_id
function getVideo(genId, callback) {
const url = new URL(`${baseUrl}/video/generations`);
url.searchParams.append("generation_id", genId);
const options = {
method: "GET",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
};
const req = https.request(url, options, (res) => {
let body = "";
res.on("data", (chunk) => body += chunk);
res.on("end", () => {
const parsed = JSON.parse(body);
callback(parsed);
});
});
req.on("error", (err) => console.error("Request error:", err));
req.end();
}
// Initiates video generation and checks the status every 10 seconds until completion or timeout
function main() {
generateVideo((genResponse) => {
if (!genResponse || !genResponse.id) {
console.error("Failed to start generation");
return;
}
const genId = genResponse.id;
console.log("Gen_ID:", genId);
const startTime = Date.now();
const timeout = 600000;
const checkStatus = () => {
if (Date.now() - startTime > timeout) {
console.log("Timeout reached. Stopping.");
return;
}
getVideo(genId, (responseData) => {
if (!responseData) {
console.error("Error: No response from API");
return;
}
const status = responseData.status;
console.log("Status:", status);
if (["waiting", "active", "queued", "generating"].includes(status)) {
console.log("Still waiting... Checking again in 10 seconds.");
setTimeout(checkStatus, 10000);
} else {
console.log("Processing complete:\n", responseData);
}
});
};
checkStatus();
});
}
main();
Generation ID: b5592d70-dd31-4e5a-bc5c-5063660c001b:alibaba/wan2.2-14b-animate-move
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: completed
Processing complete:\n {"id":"b5592d70-dd31-4e5a-bc5c-5063660c001b:alibaba/wan2.2-14b-animate-move","status":"completed","video":{"url":"https://v3b.fal.media/files/b/panda/4VjTJeQXFX3183b8Xe3d2_wan_animate_output.mp4"}}