# Grok Imagine Extend Video

> Extend videos with xAI's Grok Imagine video model


## Overview

- **Endpoint**: `https://fal.run/xai/grok-imagine-video/extend-video`
- **Model ID**: `xai/grok-imagine-video/extend-video`
- **Category**: video-to-video
- **Kind**: inference
**Tags**: video-edit, v2v, grok, xai



## Pricing

For a 6s 480p video your request will cost **$0.36** (**$0.05** per second of video output + **$0.01** per second of video input). At an output resolution of 480p, every second costs **$0.06** (**$0.05** for output and **$0.01** for input), and at 720p, every second costs **$0.08** (**$0.07** for output and **$0.01** for input)

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`prompt`** (`string`, _required_):
  Text description of what should happen next in the video.
  - Examples: "The camera slowly zooms out to reveal the city skyline at sunset"

- **`video_url`** (`string`, _required_):
  URL of the source video to extend. Must be MP4 format (H.264, H.265, or AV1 codec), 2-15 seconds long.
  - Examples: "https://v3b.fal.media/files/b/0a8b9112/V5Z_NIPE3ppMDWivNo6_q_video_019.mp4"

- **`duration`** (`integer`, _optional_):
  Length of the extension in seconds. Default value: `6`
  - Default: `6`
  - Range: `2` to `10`



**Required Parameters Example**:

```json
{
  "prompt": "The camera slowly zooms out to reveal the city skyline at sunset",
  "video_url": "https://v3b.fal.media/files/b/0a8b9112/V5Z_NIPE3ppMDWivNo6_q_video_019.mp4"
}
```

**Full Example**:

```json
{
  "prompt": "The camera slowly zooms out to reveal the city skyline at sunset",
  "video_url": "https://v3b.fal.media/files/b/0a8b9112/V5Z_NIPE3ppMDWivNo6_q_video_019.mp4",
  "duration": 6
}
```


### Output Schema

The API returns the following output format:

- **`video`** (`VideoFile`, _required_):
  The extended video (original + extension stitched together).
  - Examples: {"num_frames":384,"content_type":"video/mp4","url":"https://v3b.fal.media/files/b/0a8b9113/extended_video.mp4","height":720,"duration":16,"file_name":"extended_video.mp4","fps":24,"width":1280}



**Example Response**:

```json
{
  "video": {
    "num_frames": 384,
    "content_type": "video/mp4",
    "url": "https://v3b.fal.media/files/b/0a8b9113/extended_video.mp4",
    "height": 720,
    "duration": 16,
    "file_name": "extended_video.mp4",
    "fps": 24,
    "width": 1280
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/xai/grok-imagine-video/extend-video \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "The camera slowly zooms out to reveal the city skyline at sunset",
     "video_url": "https://v3b.fal.media/files/b/0a8b9112/V5Z_NIPE3ppMDWivNo6_q_video_019.mp4"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "xai/grok-imagine-video/extend-video",
    arguments={
        "prompt": "The camera slowly zooms out to reveal the city skyline at sunset",
        "video_url": "https://v3b.fal.media/files/b/0a8b9112/V5Z_NIPE3ppMDWivNo6_q_video_019.mp4"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("xai/grok-imagine-video/extend-video", {
  input: {
    prompt: "The camera slowly zooms out to reveal the city skyline at sunset",
    video_url: "https://v3b.fal.media/files/b/0a8b9112/V5Z_NIPE3ppMDWivNo6_q_video_019.mp4"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/xai/grok-imagine-video/extend-video)
- [API Documentation](https://fal.ai/models/xai/grok-imagine-video/extend-video/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=xai/grok-imagine-video/extend-video)

### fal.ai Platform

- [Platform Documentation](https://fal.ai/docs/documentation)
- [Python Client](https://fal.ai/docs/api-reference/client-libraries/python)
- [JavaScript Client](https://fal.ai/docs/api-reference/client-libraries/javascript)

### Other agent-readable surfaces

This file covers one model. To find anything else:

- [Platform overview](https://fal.ai/llms.txt): Entry points and representative endpoint IDs
- [Documentation index](https://fal.ai/docs/llms.txt): Every documentation page
- [Full documentation text](https://fal.ai/docs/llms-full.txt): The whole documentation inlined
- Any other model: `https://fal.ai/models/<endpoint-id>/llms.txt`
