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

# reve

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/reve.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# <span style={{ 'color': 'gray' }}>module</span>  pixeltable.functions.reve

Pixeltable [UDFs](https://docs.pixeltable.com/platform/udfs-in-pixeltable) that wrap [Reve](https://app.reve.com/) image
generation API. In order to use them, the API key must be specified either with `REVE_API_KEY` environment variable,
or as `api_key` in the `reve` section of the Pixeltable config file.

## <span style={{ 'color': 'gray' }}>udf</span>  create()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
create(
    prompt: pxt.String,
    *,
    references: pxt.Json[(Image, ...)] | None = None,
    aspect_ratio: pxt.String | None = None,
    postprocessing: pxt.Json[(Json, ...)] | None = None,
    version: pxt.String | None = None,
    model_kwargs: pxt.Json | None = None
) -> ImageResponse
```

Creates an image from a text prompt, optionally guided by reference images.

The prompt may include `<frame>0</frame>`, `<frame>1</frame>`, etc. tags to refer to the reference images.

This UDF wraps the `https://api.reve.com/v2/image/create` endpoint. For more information, refer to the official
[API documentation](https://api.reve.com/console/docs/v2/create).

**Parameters:**

* **`prompt`** (`pxt.String`): prompt describing the desired image
* **`references`** (`pxt.Json[(Image`): optional list of reference images to guide the model
* **`aspect_ratio`** (`Any`): desired image aspect ratio, e.g. '3:2', '16:9', '1:1', etc.
* **`postprocessing`** (`Any`): optional list of postprocessing operations to apply to the generated image
  e.g. `[{'process': 'effect', 'effect_name': 'low_light'}]`.
* **`version`** (`Any`): specific model version to use. Latest if not specified.
* **`model_kwargs`** (`Any`): additional keyword arguments to pass to the Reve API.

**Returns:**

* `ImageResponse`: A dictionary containing the generated image (`'image'` key) and layout metadata
  (`'layout'` key) returned by the Reve API.

**Examples:**

Add a computed column with generated images from text prompts:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
t.add_computed_column(img=reve.create(t.prompt, aspect_ratio='1:1'))
```

Remove the background from an image:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
t.add_computed_column(
    img=reve.create(
        'Remove the background from <frame>0</frame> and replace it with a clean white background',
        references=[t.product_img],
    )
)
```

Add a computed column that generates product shots in the style of a brand reference image:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
t.add_computed_column(
    img=reve.create(
        'Generate a product shot of <frame>0</frame> styled to match the aesthetic of <frame>1</frame>',
        references=[t.product_img, t.brand_reference_img],
    )
)
```
