Skip to content
Docs ·Video generation

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}. Once status becomes completed, 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

NameValueExplanation/Description
modelI’ll definitely put it in.It’s the name of the model who creates the videos.
promptI’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.
durationSeconds (integer)Each model has a different wavelength it emits. Please take a look at the table below.
resolution360p, 480p, 720p, 1080p, 4kDefaults to 720p. Supported resolutions vary by model.
aspect_ratioWidth: HeightThe percentage that the model will receive can be selected from the table below.
size1280x720 pixelsIt can be represented using size, instead of resolution and aspect ratio.
seedAn integer greater than or equal to 0If the same values are used, similar results will be obtained.
frame_imagesOne or two picturesIt’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_referencesUp to Figure 3It’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.

ModelsLengthDefault valuesResolutionAspect ratio
google/gemini-omni-1.2-flash3~15 seconds5 seconds360p, 720p, 1080p, 4k16:9, 9:16
google/veo-3.14, 6, 8 seconds4 seconds720p, 1080p, 4k16:9, 9:16
google/veo-3.1-fast4, 6, 8 seconds4 seconds720p, 1080p, 4k16:9, 9:16
alibaba/wan-3.02~30 seconds5 seconds480p, 720p, 1080p16:9, 9:16, 1:1, 4:3, 3:4, 21:9
alibaba/wan-3.0-prime2~30 seconds5 seconds480p, 720p, 1080p16:9, 9:16, 1:1, 4:3, 3:4, 21:9
alibaba/wan-2.72~15 seconds5 seconds720p, 1080p16:9, 9:16, 1:1, 4:3, 3:4
alibaba/happyhorse-1.13~15 seconds5 seconds480p, 720p, 1080p16: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 }
  }
}
  • status is one of in_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 also failed that 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_urls also 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.

ModelsPer second (360p)Per second (480p)Per second (720p)Per second (1080p)Per second (4k)How pricing works
google/gemini-omni-1.2-flashAbout 37.5 creditsNoneAbout 112.6 creditsAbout 168.9 creditsAbout 337.8 creditsTokens (19,440 credits per million video output tokens)
google/veo-3.1NoneNoneAbout 648 creditsAbout 648 creditsAbout 972 creditsGenerated duration (seconds)
google/veo-3.1-fastNoneNoneAbout 162 creditsAbout 194.4 creditsAbout 486 creditsGenerated duration (seconds)
alibaba/wan-3.0NoneAbout 81 creditsAbout 162 creditsAbout 324 creditsNoneGenerated duration (seconds)
alibaba/wan-3.0-primeNoneAbout 110.2 creditsAbout 226.8 creditsAbout 453.6 creditsNoneGenerated duration (seconds)
alibaba/wan-2.7NoneNoneAbout 162 creditsAbout 243 creditsNoneGenerated duration (seconds)
alibaba/happyhorse-1.1NoneAbout 113.4 creditsAbout 226.8 creditsAbout 291.6 creditsNoneGenerated 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.