> ## Documentation Index
> Fetch the complete documentation index at: https://www.krea.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Video

> Generate videos from text with the Krea API using ByteDance Seedance, Veo, Kling, and Hailuo. Follow REST and SDK examples to create and retrieve clips.

<video autoPlay muted loop playsInline>
  <source src="https://s.krea.ai/docs-text-to-video-new.webm" type="video/webm" />
</video>

![](https://s.krea.ai/docs-text-to-video.webp)

# Text to Video

Generate videos from text. Create cinematic sequences, animations, and visual stories with advanced video generation models.

# Text to Video

Generate videos from text. Create cinematic sequences, animations, and visual stories with advanced video generation models.

For ByteDance video generation, see the [Seedance text-to-video API quickstart](https://www.krea.ai/docs/developers/seedance.md#generate-a-video). It includes Seedance 2.5 and 2.0 endpoints, authentication, and job completion.

## Popular Models

Veo 3.1 logo

### [Veo 3.1](https://www.krea.ai/docs/api-reference/video/veo-31.md)

Google's video model with exceptional prompt adherence and cinematic quality.

Kling 2.5 logo

### [Kling 2.5](https://www.krea.ai/docs/api-reference/video/kling-25.md)

Advanced motion control with temporal consistency and realistic physics.

Hailuo 2.3 logo

### [Hailuo 2.3](https://www.krea.ai/docs/api-reference/video/hailuo-23.md)

Fast generation with smooth motion and natural scene transitions.

Wan 2.5 logo

### [Wan 2.5](https://www.krea.ai/docs/api-reference/video/wan-25.md)

High-resolution video synthesis with style control and detail preservation.

***

> [!NOTE]
>
> Video generation typically takes longer than image generation. Be prepared for longer processing times depending on video length and quality settings.

## Step 1: Generate a Video

Make a POST request to `/generate/video/kling/kling-2.5` with your prompt and video parameters. The API returns a job ID immediately.

```javascript Node.js theme={"theme":{"light":"github-light-default","dark":"vesper"}}
// npm install @krea-ai/sdk
import { Krea } from "@krea-ai/sdk";

const krea = new Krea({ apiKey: process.env.KREA_API_KEY });

const job = await krea.video("kling/kling-2.5", {
  prompt: "a majestic eagle soaring over snow-capped mountains at sunrise",
  duration: 5,
  aspect_ratio: "16:9"
});

console.log(`Job ID: ${job.job_id}`);
```

```bash cURL theme={"theme":{"light":"github-light-default","dark":"vesper"}}
curl -X POST https://api.krea.ai/generate/video/kling/kling-2.5 \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a majestic eagle soaring over snow-capped mountains at sunrise",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'
```

```python Python theme={"theme":{"light":"github-light-default","dark":"vesper"}}
import requests

API_BASE = "https://api.krea.ai"
API_TOKEN = "YOUR_API_TOKEN"

response = requests.post(
    f"{API_BASE}/generate/video/kling/kling-2.5",
    headers={
        "Authorization": f"Bearer {API_TOKEN}",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "a majestic eagle soaring over snow-capped mountains at sunrise",
        "duration": 5,
        "aspect_ratio": "16:9"
    }
)

job = response.json()
print(f"Job ID: {job['job_id']}")
```

```go Go theme={"theme":{"light":"github-light-default","dark":"vesper"}}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    apiBase := "https://api.krea.ai"
    apiToken := "YOUR_API_TOKEN"

    payload := map[string]interface{}{
        "prompt": "a majestic eagle soaring over snow-capped mountains at sunrise",
        "duration": 5,
        "aspect_ratio": "16:9",
    }

    jsonData, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", apiBase+"/generate/video/kling/kling-2.5", bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer "+apiToken)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var job map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&job)
    fmt.Printf("Job ID: %s\n", job["job_id"])
}
```

> [!NOTE]
>
> **Replace with your API Token**
>
> To replace the YOUR\_API\_TOKEN placeholder in the above examples, you'll need to generate an API token in [krea.ai/settings/api-tokens](https://www.krea.ai/settings/api-tokens). Follow the instructions on the [API Keys & Billing](https://www.krea.ai/docs/developers/api-keys-and-billing.md) page if you need help.

**Example Response**

```json theme={"theme":{"light":"github-light-default","dark":"vesper"}}
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "scheduled",
  "created_at": "2025-01-15T10:30:00.000Z",
  "estimated_time": "60-120 seconds"
}
```

***

## Step 2: Poll for Results

Video generation takes longer than image generation. Poll `/jobs/{job_id}` every 5 seconds to check progress.

> [!NOTE]
>
> **Webhooks available!**
>
> Set up webhooks to receive notifications when jobs complete. See the [Webhooks guide](https://www.krea.ai/docs/developers/webhooks.md) to get started.

```javascript Node.js theme={"theme":{"light":"github-light-default","dark":"vesper"}}
// npm install @krea-ai/sdk
import { Krea } from "@krea-ai/sdk";

const krea = new Krea({ apiKey: process.env.KREA_API_KEY });

async function waitForVideo(jobId) {
  const completed = await krea.jobs.wait(jobId, { intervalMs: 5000 });
  return completed.result.urls[0];
}

const videoUrl = await waitForVideo(job.job_id);
console.log(`Video ready: ${videoUrl}`);
```

```bash cURL theme={"theme":{"light":"github-light-default","dark":"vesper"}}
curl -X GET https://api.krea.ai/jobs/YOUR_JOB_ID \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

```python Python theme={"theme":{"light":"github-light-default","dark":"vesper"}}
import time

def wait_for_video(job_id):
    while True:
        response = requests.get(
            f"{API_BASE}/jobs/{job_id}",
            headers={"Authorization": f"Bearer {API_TOKEN}"}
        )
        job = response.json()

        if job["status"] == "completed":
            return job["result"]["urls"][0]
        if job["status"] in ("failed", "cancelled"):
            raise Exception(f"Job failed: {job['status']}")

        # Show progress if available
        if "progress" in job:
            print(f"Progress: {job['progress']}%")
        else:
            print(f"Status: {job['status']}")

        time.sleep(5)

video_url = wait_for_video(job["job_id"])
print(f"Video ready: {video_url}")
```

```go Go theme={"theme":{"light":"github-light-default","dark":"vesper"}}
func waitForVideo(jobID string) (string, error) {
    for {
        req, _ := http.NewRequest("GET", apiBase+"/jobs/"+jobID, nil)
        req.Header.Set("Authorization", "Bearer "+apiToken)

        resp, _ := client.Do(req)
        var job map[string]interface{}
        json.NewDecoder(resp.Body).Decode(&job)
        resp.Body.Close()

        switch job["status"] {
        case "completed":
            result := job["result"].(map[string]interface{})
            urls := result["urls"].([]interface{})
            return urls[0].(string), nil
        case "failed", "cancelled":
            return "", fmt.Errorf("job failed: %s", job["status"])
        }

        // Show progress if available
        if progress, ok := job["progress"]; ok {
            fmt.Printf("Progress: %.0f%%\n", progress)
        } else {
            fmt.Printf("Status: %s\n", job["status"])
        }

        time.Sleep(5 * time.Second)
    }
}
```

**Example Completed Response**

```json theme={"theme":{"light":"github-light-default","dark":"vesper"}}
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "created_at": "2025-01-15T10:30:00.000Z",
  "completed_at": "2025-01-15T10:31:45.000Z",
  "result": {
    "urls": ["https://gen.krea.ai/videos/your-video.mp4"]
  }
}
```

> [!NOTE]
>
> **Webhooks available!**
>
> Set up webhooks to receive notifications when jobs complete. See the [Webhooks guide](https://www.krea.ai/docs/developers/webhooks.md) to get started.

***

## Common Parameters

> [!TIP]
>
> For a list of detailed parameters for all models, see the [Model APIs](https://www.krea.ai/docs/api-reference/introduction.md) page.

| Parameter | Type | Description |
| - | - | - |
| `prompt` | string | Detailed description of the video content |
| `duration` | number | Video length in seconds. Supported values depend on the model. |
| `aspect_ratio` | string | Video aspect ratio, such as `16:9`, `9:16`, or `1:1` |
| `start_image` | string | Optional source image URL for image-to-video models |
| `end_image` | string | Optional ending frame URL for supported models |
| `mode` | string | Optional quality mode for models that expose one |
| `model` | string | Video generation model to use |

> [!TIP]
>
> **Prompt Tips for Better Videos:**
>
> * Be specific about motion and camera movement
> * Describe the scene, lighting, and atmosphere
> * Mention timing (e.g., "slowly panning", "quick zoom")
> * Include style references (e.g., "cinematic", "documentary style")

> [!WARNING]
>
> Video generation costs more than image generation. See [API Keys & Billing](https://www.krea.ai/docs/developers/api-keys-and-billing.md) for per-model pricing and how to top up your API balance.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.