Blog

AI Video Generator API (2026): 8 Models, Prices and Code

Unicorn API Team · · 11 min read

AI video generator API turning a code request into a finished video clip

An AI video generator API is a web endpoint that takes a text prompt, a still image or a set of reference frames and returns a generated video file. Your app can produce clips with no one opening an editor. This post covers how these APIs work, which models are worth calling right now, what each clip costs, and the code that takes you from a prompt to an MP4.

The phrase covers several different products, so the first job is to sort out which one you need.

What is an AI video generator API?

Search for “AI video generator API” and the results mix three or four kinds of product that solve different problems:

  • Generative model APIs. A diffusion model creates every frame from your prompt or start image. A diffusion model is a neural network trained to turn random noise into an image step by step, and video versions do this across many frames at once. Grok Imagine, Kling, PixVerse and Vidu belong here. OpenAI’s Sora did too, until OpenAI shut down the Sora API in September 2026.
  • Template rendering APIs. Creatomate and similar tools take a template designed by a person, fill it with your text, images and data, and render the result. Nothing new is invented. It is programmatic video editing, and it works well for personalised videos built from CRM data.
  • Avatar and ad tools. Creatify and similar products focus on talking characters and on turning a product URL into an ad. They are narrower and more opinionated about the output.
  • Video infrastructure APIs. api.video hosts, encodes and streams video and adds AI features such as transcription and summaries. It does not generate footage.

This article is about the first group: models that create new footage. Plenty of teams combine groups. They generate b-roll or animated product shots with a model, then assemble the final ad in a template renderer with captions and a logo.

Unicorn API is a generative model API of this kind. One key and one bill give you access to video models from several labs, alongside image, audio and chat models, all priced in the same credits. The rest of the post uses it for the concrete examples.

How does an AI video generator API work?

Video generation takes far longer than a normal web request should stay open, so nearly every AI video generator API is asynchronous. You never wait on a single call for the finished file. The flow looks like this:

  1. Submit a job. Send POST /v1/jobs with a model ID and an input object holding your prompt, image URL, duration, resolution and so on.
  2. Get a job ID. The response comes back right away with an ID for the job.
  3. Poll the status. Call GET /v1/jobs/{id} every few seconds. While the model works, the job reports that it is still in progress.
  4. Download the output. When status is "succeeded", the video URL is at job.outputs[0].url. Copy the file to your own storage.

Input modes you will see

Video models differ mainly in what you can give them as a starting point:

  • Text-to-video: a written prompt only. The model invents the subject, the setting and the style. It is fast to try and the hardest to control.
  • Image-to-video: you supply a still image (the start frame) and a prompt describing the motion. The model animates your image, so the product, face or scene stays recognisable.
  • Keyframe-to-video: you supply the first frame, the last frame, and sometimes frames in between. The model fills in the motion between them. Use it when a shot has to start and end in exact positions.
  • Reference-to-video: you supply images or short videos of a subject or style, and the model uses them as references while composing a new shot. It suits keeping a character or product consistent across many clips.

Two settings drive cost on almost every model: duration in seconds and resolution (480p, 720p, 1080p and higher). Some models add an audio switch, which also changes the price.

Diagram of the asynchronous job flow used by video generation APIs
Video generation is asynchronous: submit a job, poll its status, then download the output.

Which video models can you call through one API?

These are the video models on Unicorn API covered in this guide. Prices are in credits. The example column uses a 5-second clip so the models can be compared directly. Allowed durations differ by model, so check each model’s page before you build around a length.

ModelInputResolutionsPrice basisExample: 5 s clip
Grok Imagine Video 1.5Image-to-video, 1-15 s480p, 720p, 1080pPer clip, by length and resolution720p: 22.5, billed as 23
Grok Imagine Video 1.0Text or image, 6-30 s480p, 720p, 1080pPer clip, same per-second rateMin. 6 s; 6 s 720p: 27
PixVerse V6 Max Image To VideoImage(s) + prompt, optional audio360p to 1080pPer second720p: 44 silent, 60 with audio
Kling 4.0 Keyframe To VideoFirst, last and key frames720p, 1080p28.5 or 42.5 per second720p: 142.5, billed as 143
Kling 4.0 Flash Keyframe To VideoFirst frame720p17 per second85
Kling 4.0 Reference To VideoReference images, videos, elements, voices720p, 1080pPer second, cheaper with video references720p with video refs: 85
Kling 4.0 Flash Reference to VideoReference images, videos, elements720p11.3 or 17 per secondWith video refs: 56.5, billed as 57
Vidu Q4 Image To VideoImage + prompt, optional audio field540p up to 4k7.2 to 62.4 per second1080p: 96

Grok Imagine: the low-cost workhorse

xAI’s Grok Imagine Video 1.5 has a very low cost per second and strong motion quality. It only does image-to-video, so it always needs a start frame. It can be busy at peak times, which is worth planning for (more on that below). Grok Imagine Video 1.0 charges the same per-second rate, accepts text-only prompts, and runs from 6 to 30 seconds, which makes it the option here for longer single shots.

Kling 4.0: control and consistency

The Kling 4.0 family splits into keyframe models, where you pin the start and end of the shot, and reference models, where you feed in images or clips of a subject to keep it consistent. The Flash versions run at 720p and cost less per second. The reference models are cheaper per second when you include video_urls.

PixVerse V6 Max and Vidu Q4

PixVerse V6 Max animates images and can generate audio with the clip through generate_audio_switch. Vidu Q4 has the widest resolution range in this list, from 540p up to 4k, so it is the one to choose when you need delivery masters larger than 1080p. For the full list, including image and audio models, browse the model catalog.

How much does an AI video generator API cost?

Every AI video generator API prices by some mix of seconds, resolution and features. On Unicorn API all of it is expressed in credits:

  • Monthly plans give you credits at $0.01 each: Starter $25, Creator $50, Studio $100, Pro $200 per month.
  • Top-ups cost $0.015 per credit and never expire.
  • The exact price of any request is available before you run it from POST /v1/models/price, so your app can show a cost or enforce a budget before it spends anything. The request format is in the API documentation.

Prices are rounded up to whole credits per output. A 22.5-credit clip bills as 23 credits.

Worked example: 200 vertical product clips

Say you run a store and want 200 six-second 9:16 clips at 720p, each animated from an existing product photo. Here is what the same batch costs on four image-to-video models:

ModelCredits per 6 s 720p clipCredits for 200 clipsCost at plan rate ($0.01)
Grok Imagine Video 1.5275,400$54
PixVerse V6 Max (no audio)52.8, billed as 5310,600$106
Vidu Q491.2, billed as 9218,400$184
Kling 4.0 Flash Keyframe10220,400$204

The Grok batch fits a Creator plan (5,000 credits) plus 400 top-up credits at $6, for $56 in total. The Kling batch needs a Pro plan plus a 400-credit top-up. That spread of nearly 4x for the same clip spec is why it pays to test several models before you commit.

Budget for retakes, too. You rarely keep the first generation of every clip. If you expect to keep one take in three, triple the figure in the table. Drafting at a lower resolution cuts the cost of that exploration sharply, and the mistakes section below shows how.

Code: calling the AI video generator API step by step

You need an API key and an image the model can reach over HTTPS. Create a key on the API keys page, then export it:

export UNICORN_API_KEY="your-key-here"

Submit a job with curl

This asks Grok Imagine Video 1.5 to animate a product photo into a 6-second vertical clip at 720p (27 credits):

curl -X POST https://api.unicornapi.net/v1/jobs \
  -H "Authorization: Bearer $UNICORN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1-5-preview",
    "input": {
      "image": "https://example.com/sneaker.png",
      "prompt": "The sneaker rotates slowly on a turntable, soft studio light, shallow depth of field",
      "duration": 6,
      "resolution": "720p",
      "aspect_ratio": "9:16"
    }
  }'

# Then poll with the id from the response:
curl https://api.unicornapi.net/v1/jobs/JOB_ID \
  -H "Authorization: Bearer $UNICORN_API_KEY"

A complete Python script

This version submits the job, polls until it finishes, and saves the MP4 locally. It needs the requests package.

import os
import time
import requests

API = "https://api.unicornapi.net"
HEADERS = {"Authorization": f"Bearer {os.environ['UNICORN_API_KEY']}"}


def generate_video(image_url, prompt, duration=6, resolution="720p", aspect_ratio="9:16"):
    body = {
        "model": "grok-imagine-video-1-5-preview",
        "input": {
            "image": image_url,
            "prompt": prompt,
            "duration": duration,
            "resolution": resolution,
            "aspect_ratio": aspect_ratio,
        },
    }
    r = requests.post(f"{API}/v1/jobs", json=body, headers=HEADERS, timeout=30)
    r.raise_for_status()
    job_id = r.json()["id"]

    deadline = time.time() + 15 * 60
    while time.time() < deadline:
        r = requests.get(f"{API}/v1/jobs/{job_id}", headers=HEADERS, timeout=30)
        r.raise_for_status()
        job = r.json()
        if job["status"] == "succeeded":
            return job["outputs"][0]["url"]
        if job["status"] in ("failed", "canceled"):
            raise RuntimeError(f"Job {job_id} ended as {job['status']}: {job}")
        time.sleep(5)
    raise TimeoutError(f"Job {job_id} did not finish within 15 minutes")


if __name__ == "__main__":
    url = generate_video(
        "https://example.com/sneaker.png",
        "The sneaker rotates slowly on a turntable, soft studio light",
    )
    video = requests.get(url, timeout=120)
    video.raise_for_status()
    with open("sneaker.mp4", "wb") as f:
        f.write(video.content)
    print("Saved sneaker.mp4")

The same flow in JavaScript (Node 18+)

const API = "https://api.unicornapi.net";
const headers = {
  Authorization: `Bearer ${process.env.UNICORN_API_KEY}`,
  "Content-Type": "application/json",
};

async function generateVideo(imageUrl, prompt) {
  const res = await fetch(`${API}/v1/jobs`, {
    method: "POST",
    headers,
    body: JSON.stringify({
      model: "grok-imagine-video-1-5-preview",
      input: { image: imageUrl, prompt, duration: 6, resolution: "720p", aspect_ratio: "9:16" },
    }),
  });
  if (!res.ok) throw new Error(`Submit failed: ${res.status} ${await res.text()}`);
  const { id } = await res.json();

  for (let i = 0; i < 180; i++) {
    const poll = await fetch(`${API}/v1/jobs/${id}`, { headers });
    if (!poll.ok) throw new Error(`Poll failed: ${poll.status}`);
    const job = await poll.json();
    if (job.status === "succeeded") return job.outputs[0].url;
    if (job.status === "failed" || job.status === "canceled") {
      throw new Error(`Job ${id} ended as ${job.status}`);
    }
    await new Promise((r) => setTimeout(r, 5000));
  }
  throw new Error(`Job ${id} timed out`);
}

generateVideo("https://example.com/sneaker.png", "The sneaker rotates slowly on a turntable")
  .then((url) => console.log("Video:", url))
  .catch(console.error);

To switch models, change the model string and the input fields. Vidu Q4 takes image_url, PixVerse V6 Max takes an image_urls array plus quality, and the Kling keyframe models take first_frame_url. Each model page lists its exact fields. If you would rather try prompts by hand first, the browser playground runs the same models. If you work in Cursor or Claude Code, you can connect the API to your coding agent.

Bar chart comparing the credit cost of a 6-second 720p clip across video models
The same 6-second 720p clip ranges from 27 to 102 credits depending on the model.

How to choose a video model for your use case

No single model wins on every axis. Match the model to the job:

  • High-volume social clips from existing images: Grok Imagine Video 1.5. It has the lowest price here and strong motion. Draft at 480p and render finals at 720p or 1080p.
  • Text-only prompts or shots longer than 15 seconds: Grok Imagine Video 1.0, which takes text or images and runs up to 30 seconds.
  • Shots that must start and end on exact frames: Kling 4.0 Keyframe To Video, or the Flash version when 720p is enough and cost matters.
  • The same character or product across a series: Kling 4.0 Reference To Video or its Flash sibling. Supplying reference videos lowers the per-second price on both.
  • Clips with generated sound: PixVerse V6 Max with generate_audio_switch turned on.
  • Masters above 1080p: Vidu Q4 at 2k or 4k. At 62.4 credits per second, 4k costs about 3x what 1080p does on the same model, so reserve it for final renders.

Plan for a fallback model

Any single model can be slow, rate-limited or retired. Grok Imagine Video 1.5 can be busy at peak times, and the Sora API shutdown showed that an entire product line can disappear. Because every model sits behind the same key and the same job endpoints, a fallback is just a second model ID. If a job on your primary model fails or times out, resubmit with the next model in your list and map the input fields accordingly.

Is there a free AI video generator API?

Not in any lasting sense. Every second of output runs on expensive GPUs, so “free” offers fall into three groups. The first is trial credits that run out. The second is free tiers with tight rate limits or reduced resolution. The third is open-weight models you host yourself, where the API is free and the GPU bill is not. Self-hosting can make sense at very large volume, but you take on setup, scaling and model updates.

For most projects, pay-per-clip is the cheaper way to start. A 5-second 480p clip from Grok Imagine Video 1.5 costs 12 credits, which is $0.12 at plan rates. A Starter plan’s 2,500 credits covers about 200 of those drafts. See plans and credit prices for the current options. If you are focused on animating stills, our guide to Wan 2.7 image to video covers another model family in depth.

Common mistakes when using an AI video generator API

  1. Drafting at final resolution. On Grok Imagine Video 1.5, a 5-second clip costs 12 credits at 480p and 40 at 1080p, about 3.3x more. Lock the prompt and motion at 480p, then re-render the winner.
  2. Generating the wrong aspect ratio. Cropping a 16:9 clip down to 9:16 throws away most of the frame and often cuts off the subject. Set aspect_ratio for the platform you are publishing to.
  3. Sending text-only prompts to image-to-video models. Grok Imagine Video 1.5 needs a start frame. If you have no image, use a model that accepts text alone, such as Grok Imagine Video 1.0, or generate a still first with an image model.
  4. Writing a whole storyboard in one prompt. These models produce single shots. Describe one subject, one motion and one camera move per clip, then cut the clips together.
  5. Polling too aggressively, or not at all. Hammering the job endpoint every few hundred milliseconds wastes requests. Waiting on a single long request breaks on timeouts. Poll every few seconds with an overall deadline.
  6. Hotlinking the output URL. Download each finished video into your own storage or CDN as soon as the job succeeds, then serve it from there.
  7. Exposing the API key in the browser. Call the API from your server and pass only the finished video URL to the front end.
  8. Ignoring rounding on short clips. Prices round up per output, so many 1-second clips cost slightly more than their per-second rate suggests. Check totals with the price endpoint before launching a large batch.

Get these right and an AI video generator API becomes a dependable part of your pipeline: a predictable cost per clip, a fallback when a model is busy, and output you control. Start with a few drafts in the playground, pick the cheapest model that meets your quality bar, and move the script above into production.

Frequently asked questions

Is there a free AI video generator API?

Not in any lasting sense. Every clip runs on expensive GPUs, so free offers are trial credits, heavily rate-limited tiers, or open-weight models you host yourself and pay for in GPU time. A pay-per-clip API is usually cheaper than it sounds: on Unicorn API a 5-second 480p clip from Grok Imagine Video 1.5 costs 12 credits, which is $0.12 at plan rates.

How do I get an AI video generator API key?

Create an account, then generate a key on the API keys page and store it as an environment variable such as UNICORN_API_KEY. Send it in the Authorization header as a Bearer token on every request. Never put the key in front-end code or a public repository; call the API from your server and pass only the finished video URL to the browser.

How long does an AI video generator API take to make a video?

Generation time depends on the model, the clip length, the resolution and how busy the provider is, so treat it as variable. That is why video APIs are asynchronous: you submit a job, receive an ID immediately, and poll the job endpoint every few seconds until its status is succeeded. Build a timeout and a retry path rather than assuming a fixed wait.

What is the difference between text-to-video and image-to-video APIs?

Text-to-video creates a clip from a written prompt alone, so the model invents the subject, setting and style. Image-to-video starts from a still frame you supply and animates it, which gives far more control over what appears on screen. For products, brand assets and recurring characters, image-to-video is usually the more reliable choice.

Which AI video model is cheapest to call through an API?

On Unicorn API, Grok Imagine Video 1.5 has the lowest prices among the video models covered here: 2.4 credits for a 1-second 480p clip and 22.5 credits for 5 seconds at 720p, rounded up to whole credits. It is image-to-video only, so you need a start frame. Grok Imagine Video 1.0 uses the same per-second rate and also accepts text-only prompts.