---
title: "Video Generation API for Text to Video and Image to Video | Rendley API Docs"
description: "A video generation API: create AI video from a text prompt (text to video), a still image (image to video) or existing footage. Kling, Veo, Wan and Seedance share one endpoint, so switching model is one field."
url: https://docs.rendley.com/api/generate-video/
---

# Video generation API

A video generation API: create AI video from a text prompt (text to video), a still image (image to video) or existing footage. Kling, Veo, Wan and Seedance share one endpoint, so switching model is one field.

## Generate a video

Enqueue a job to generate a video clip from a text prompt, optionally animating a starting/ending image.

POST`https://api.rendley.com/v1/ai/generate-video`

\"\n}","grok-imagine-video-extension":"{\n \"prompt\": \"A slow aerial push over a city at sunset\",\n \"video\": \"

Body

`model_id`optionalstring

Which model to use. Changing it updates the params below.

`params`requiredjson

Model-specific parameters. The fields listed for the selected model.

>>; <<>> and the reference video as <<

`project_id`optionalstring

`workspace_id`optionalstring

```
const res = await fetch("https://api.rendley.com/v1/ai/generate-video", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
    "params": {
      "prompt": "A slow aerial push over a city at sunset"
    },
    "model_id": "kling-v2.6"
  }),
});
const { data } = await res.json();
```

```
curl -X POST "https://api.rendley.com/v1/ai/generate-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "prompt": "A slow aerial push over a city at sunset"
    },
    "model_id": "kling-v2.6"
  }'
```

```
import requests

res = requests.post(
    "https://api.rendley.com/v1/ai/generate-video",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "params": {
            "prompt": "A slow aerial push over a city at sunset"
        },
        "model_id": "kling-v2.6"
    },
)
data = res.json()["data"]
```

```
$ch = curl_init("https://api.rendley.com/v1/ai/generate-video");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["params" => ["prompt" => "A slow aerial push over a city at sunset"], "model_id" => "kling-v2.6"]));

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true)["data"];
```

```
package main

import (
	"fmt"
	"io"
	"net/http"
	"bytes"
)

func main() {
	body := bytes.NewBufferString(`{
  "params": {
    "prompt": "A slow aerial push over a city at sunset"
  },
  "model_id": "kling-v2.6"
}`)
	req, _ := http.NewRequest("POST", "https://api.rendley.com/v1/ai/generate-video", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")
	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	b, _ := io.ReadAll(res.Body)
	fmt.Println(string(b))
}
```

```
require "net/http"
require "json"

uri = URI("https://api.rendley.com/v1/ai/generate-video")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer YOUR_API_KEY"
req["Content-Type"] = "application/json"
req.body = { params: { prompt: "A slow aerial push over a city at sunset" }, model_id: "kling-v2.6" }.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)["data"]
```

Response 200

```
{
  "data": {
    "job_id": "d97241f2-e1e4-4651-b078-8663fc35c584"
  }
}
```

## Calculate video generation cost

Calculate the credit cost of generating a video clip.

POST`https://api.rendley.com/v1/ai/generate-video/cost`

\"\n}","grok-imagine-video-extension":"{\n \"prompt\": \"A slow aerial push over a city at sunset\",\n \"video\": \"

Body

`model_id`optionalstring

Which model to use. Changing it updates the params below.

`params`requiredjson

Model-specific parameters. The fields listed for the selected model.

>>; <<>> and the reference video as <<

`project_id`optionalstring

`workspace_id`optionalstring

```
const res = await fetch("https://api.rendley.com/v1/ai/generate-video/cost", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
    "params": {
      "prompt": "A slow aerial push over a city at sunset"
    },
    "model_id": "kling-v2.6"
  }),
});
const { data } = await res.json();
```

```
curl -X POST "https://api.rendley.com/v1/ai/generate-video/cost" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "prompt": "A slow aerial push over a city at sunset"
    },
    "model_id": "kling-v2.6"
  }'
```

```
import requests

res = requests.post(
    "https://api.rendley.com/v1/ai/generate-video/cost",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "params": {
            "prompt": "A slow aerial push over a city at sunset"
        },
        "model_id": "kling-v2.6"
    },
)
data = res.json()["data"]
```

```
$ch = curl_init("https://api.rendley.com/v1/ai/generate-video/cost");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["params" => ["prompt" => "A slow aerial push over a city at sunset"], "model_id" => "kling-v2.6"]));

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true)["data"];
```

```
package main

import (
	"fmt"
	"io"
	"net/http"
	"bytes"
)

func main() {
	body := bytes.NewBufferString(`{
  "params": {
    "prompt": "A slow aerial push over a city at sunset"
  },
  "model_id": "kling-v2.6"
}`)
	req, _ := http.NewRequest("POST", "https://api.rendley.com/v1/ai/generate-video/cost", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")
	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	b, _ := io.ReadAll(res.Body)
	fmt.Println(string(b))
}
```

```
require "net/http"
require "json"

uri = URI("https://api.rendley.com/v1/ai/generate-video/cost")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer YOUR_API_KEY"
req["Content-Type"] = "application/json"
req.body = { params: { prompt: "A slow aerial push over a city at sunset" }, model_id: "kling-v2.6" }.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)["data"]
```

Response 200

```
{
  "data": 0
}
```

Generation is asynchronous. These endpoints return a `job_id`, so poll [GET /v1/jobs/{id}](https://docs.rendley.com/api/jobs/) until the job completes and read the download URL off the finished job. [Jobs and polling](https://docs.rendley.com/api/polling/) covers the loop, and [Generate and download](https://docs.rendley.com/api/examples/generate-and-download/) is a script that runs it end to end.

[Previous pageImage generation](https://docs.rendley.com/api/generate-image/) [Next pageLip sync](https://docs.rendley.com/api/lipsync/)
