# RIFE

> Interpolate images with RIFE - Real-Time Intermediate Flow Estimation


## Overview

- **Endpoint**: `https://fal.run/fal-ai/rife`
- **Model ID**: `fal-ai/rife`
- **Category**: image-to-image
- **Kind**: inference
**Tags**: interpolation



## Pricing

Your request will cost **$0.0013** per compute second.

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:


- **`start_image_url`** (`string`, _required_):
  The URL of the first image to use as the starting point for interpolation.
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/interpolate-start-frame.png"

- **`end_image_url`** (`string`, _required_):
  The URL of the second image to use as the ending point for interpolation.
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/interpolate-end-frame.png"

- **`output_type`** (`OutputTypeEnum`, _optional_):
  The type of output to generate; either individual images or a video. Default value: `"images"`
  - Default: `"images"`
  - Options: `"images"`, `"video"`

- **`output_format`** (`OutputFormatEnum`, _optional_):
  The format of the output images. Only applicable if output_type is 'images'. Default value: `"jpeg"`
  - Default: `"jpeg"`
  - Options: `"png"`, `"jpeg"`

- **`num_frames`** (`integer`, _optional_):
  The number of frames to generate between the input images. Default value: `1`
  - Default: `1`
  - Range: `1` to `64`

- **`include_start`** (`boolean`, _optional_):
  Whether to include the start image in the output.
  - Default: `false`

- **`include_end`** (`boolean`, _optional_):
  Whether to include the end image in the output.
  - Default: `false`

- **`fps`** (`integer`, _optional_):
  Frames per second for the output video. Only applicable if output_type is 'video'. Default value: `8`
  - Default: `8`
  - Range: `1` to `60`

- **`sync_mode`** (`boolean`, _optional_):
  If `True`, the media will be returned as a data URI and the output data won't be available in the request history.
  - Default: `false`



**Required Parameters Example**:

```json
{
  "start_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-start-frame.png",
  "end_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-end-frame.png"
}
```

**Full Example**:

```json
{
  "start_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-start-frame.png",
  "end_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-end-frame.png",
  "output_type": "images",
  "output_format": "jpeg",
  "num_frames": 1,
  "fps": 8
}
```


### Output Schema

The API returns the following output format:

- **`images`** (`list<Image>`, _optional_):
  The generated frames as individual images.
  - Default: `[]`
  - Array of Image
  - Examples: [{"url":"https://storage.googleapis.com/falserverless/example_outputs/rife-mid-frame.jpeg"}]

- **`video`** (`File`, _optional_):
  The generated video file, if output_type is 'video'.



**Example Response**:

```json
{
  "images": [
    {
      "url": "https://storage.googleapis.com/falserverless/example_outputs/rife-mid-frame.jpeg"
    }
  ]
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/rife \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "start_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-start-frame.png",
     "end_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-end-frame.png"
   }'
```

### 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(
    "fal-ai/rife",
    arguments={
        "start_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-start-frame.png",
        "end_image_url": "https://storage.googleapis.com/falserverless/example_inputs/interpolate-end-frame.png"
    },
    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("fal-ai/rife", {
  input: {
    start_image_url: "https://storage.googleapis.com/falserverless/example_inputs/interpolate-start-frame.png",
    end_image_url: "https://storage.googleapis.com/falserverless/example_inputs/interpolate-end-frame.png"
  },
  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/fal-ai/rife)
- [API Documentation](https://fal.ai/models/fal-ai/rife/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/rife)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
