Video generation
Generate videos with audio from text prompts
It takes some time to create the video. Once the request is submitted, I’ll get it ready and send it to you. Please include the details of the conversation and the other address in the template https://alprouter.com/api/v1/videos.
- If you submit the request with
POST /videos, the task number(id) will be returned immediately. - I ask for the status of
GET /videos/{id}. Oncestatusbecomescompleted, then everything is ready. - Download the MP4 video file with
GET /videos/{id}/content.
import time
import requests
BASE = "https://alprouter.com/api/v1"
HEADERS = {"Authorization": "Bearer alp-your-key"}
job = requests.post(f"{BASE}/videos", headers=HEADERS, json={
"model": "google/gemini-omni-1.2-flash",
"prompt": "A paper airplane slowly flies over the calm sea.",
"duration": 5,
"resolution": "720p",
}).json()
# usually 1minutes. 10seconds between polls
while job["status"] in ("pending", "in_progress"):
time.sleep(10)
job = requests.get(job["polling_url"], headers=HEADERS).json()
if job["status"] == "completed":
video = requests.get(job["unsigned_urls"][0], headers=HEADERS)
with open("video.mp4", "wb") as file:
file.write(video.content)
print("pricing", job["usage"]["cost"])
else:
print(job["status"], job.get("error"))Values entered in the request
| Name | Value | Explanation/Description |
|---|---|---|
model | I’ll definitely put it in. | It’s the name of the model who creates the videos. |
prompt | I’ll definitely put it in. | I’ll describe the video in words. The better you can describe the scenes, movements, atmosphere, and sound, the better it will be. |
duration | Seconds (integer) | Each model has a different wavelength it emits. Please take a look at the table below. |
resolution | 360p, 480p, 720p, 1080p, 4k | Defaults to 720p. Supported resolutions vary by model. |
aspect_ratio | Width: Height | The percentage that the model will receive can be selected from the table below. |
size | 1280x720 pixels | It can be represented using size, instead of resolution and aspect ratio. |
seed | An integer greater than or equal to 0 | If the same values are used, similar results will be obtained. |
frame_images | One or two pictures | It’s a painting that will be used as the opening and closing scenes of the video. Here’s an example of what it looks like. |
input_references | Up to Figure 3 | It’s a reference image that helps to match the people or objects that appear in the video. I receive these images from Veo and Wan 3.0, as well as Wan 3.0 Prime. |
Sounds (words, music, sound effects) are always created together.
| Models | Length | Default values | Resolution | Aspect ratio |
|---|---|---|---|---|
google/gemini-omni-1.2-flash | 3~15 seconds | 5 seconds | 360p, 720p, 1080p, 4k | 16:9, 9:16 |
google/veo-3.1 | 4, 6, 8 seconds | 4 seconds | 720p, 1080p, 4k | 16:9, 9:16 |
google/veo-3.1-fast | 4, 6, 8 seconds | 4 seconds | 720p, 1080p, 4k | 16:9, 9:16 |
alibaba/wan-3.0 | 2~30 seconds | 5 seconds | 480p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 |
alibaba/wan-3.0-prime | 2~30 seconds | 5 seconds | 480p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 |
alibaba/wan-2.7 | 2~15 seconds | 5 seconds | 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4 |
alibaba/happyhorse-1.1 | 3~15 seconds | 5 seconds | 480p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4 |
Starting from the picture
When a picture is inserted into frame_images, that picture becomes the first scene of the video. The picture is sent via a https URL or a data URL. If aspect_ratio is not specified, the picture will follow the specified aspect ratio. In the Alibaba Cloud model, the first scene’s picture has a defined aspect ratio. When sending the first scene, please exclude aspect_ratio and size.
{
"model": "google/gemini-omni-1.2-flash",
"prompt": "Leaves sway gently in the wind",
"duration": 5,
"frame_images": [
{ "type": "image_url", "image_url": { "url": "https://example.com/leaf.png" }, "frame_type": "first_frame" }
]
}The final scene and related illustrations
The Veo and Wan models involve putting first_frame and last_frame into each of the frame_images slots. This creates a video that connects from the first scene to the last scene. The last scene needs to be sent along with the first scene.
In Veo and Wan 3.0, as well as Wan 3.0 Prime, you can add up to 3 images in the input_references section. This allows you to specify which people or objects will appear in the video. Please send the reference images separately in the frame_images section. If you use reference images in Veo, the length of each image will be 8 seconds.
{
"model": "google/veo-3.1-fast",
"prompt": "This character walks along the beach",
"input_references": [
{ "type": "image_url", "image_url": { "url": "https://example.com/character.png" } }
]
}When asked about the status, the answer was…
{
"id": "gen-...",
"status": "completed",
"model": "google/gemini-omni-1.2-flash",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"polling_url": "https://alprouter.com/api/v1/videos/gen-...",
"unsigned_urls": ["https://alprouter.com/api/v1/videos/gen-.../content?index=0"],
"usage": {
"cost": 0.354,
"prompt_tokens": 43,
"completion_tokens": 29760,
"completion_tokens_details": { "reasoning_tokens": 800, "video_tokens": 28960 }
}
}statusis one ofin_progress,completed,failed,expired. The last three don’t change at all.- If there’s a failure, the reasons can be written out in
error. It’s alsofailedthat the video doesn’t appear because it violates the safety standards of the supplier. - It usually takes only 1–2 minutes to complete it. Asking questions every 10–30 seconds is sufficient.
- The address of
unsigned_urlsalso requires an API key to be entered in order to access it.
The videos cannot be saved; they can only be received by the supplier during the storage period. The Google model has a storage period of 7 days, while the Alibaba Cloud model has a storage period of 24 hours. Once the processing is complete, the videos can be received and stored immediately. Once the storage period expires, it will be marked as “410”.
Fees
The Veo and Alibaba Cloud models calculate the length of the path based on the resolution level. The length provided by Alibaba Cloud is given in seconds. If a Wan 3.0 Prime request is processed by Wan 3.0, then the price applied is that of Wan 3.0. Gemini Omni combines the video tokens, the description text, and the tokens written in thoughts.
| Models | Per second (360p) | Per second (480p) | Per second (720p) | Per second (1080p) | Per second (4k) | How pricing works |
|---|---|---|---|---|---|---|
google/gemini-omni-1.2-flash | About 37.5 credits | None | About 112.6 credits | About 168.9 credits | About 337.8 credits | Tokens (19,440 credits per million video output tokens) |
google/veo-3.1 | None | None | About 648 credits | About 648 credits | About 972 credits | Generated duration (seconds) |
google/veo-3.1-fast | None | None | About 162 credits | About 194.4 credits | About 486 credits | Generated duration (seconds) |
alibaba/wan-3.0 | None | About 81 credits | About 162 credits | About 324 credits | None | Generated duration (seconds) |
alibaba/wan-3.0-prime | None | About 110.2 credits | About 226.8 credits | About 453.6 credits | None | Generated duration (seconds) |
alibaba/wan-2.7 | None | None | About 162 credits | About 243 credits | None | Generated duration (seconds) |
alibaba/happyhorse-1.1 | None | About 113.4 credits | About 226.8 credits | About 291.6 credits | None | Generated duration (seconds) |
- We reserve the maximum estimated cost when you submit a video request. Once generation finishes, we charge for actual usage and release the remaining balance.
- If generation fails or no video is produced, you are not charged.
- Completed videos incur a charge even if you do not poll their status. Download your video after submitting a request.
- Find the final cost in
usage.cost.
View available models and parameters
GET https://alprouter.com/api/v1/videos/models lists supported durations, resolutions, aspect ratios and per-second prices for each video model. No API key is needed.