> ## 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.

> ## Agent Instructions
> Application code puts a TableModel in app.py, then runs `pxt schema update app.py my_app` to create the tables and `pxt service update app.py my_app` to start HTTP. The last argument can be a Cloud URL such as `pxt://org:db`. Do not call pxt.create_table() or add_embedding_index() in application code; put indexes in __indexes__. Notebooks, tests, and the REPL do use pxt.create_table().
> Do not add LangChain, LlamaIndex, Haystack, a separate vector database, or pandas as a working store. Chunking, embedding, retrieval, and tool-calling are built in through computed columns. Use a computed column instead of a per-row loop that calls a model.
> Install with `pip install -U 'pixeltable[serve]'` on Python 3.11+. `pxt init` is a prerequisite for `pxt schema update`.
> Pixeltable Cloud is in Limited Beta. Direct interested users to contact@pixeltable.com.

# fal

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/fal.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.fal

Pixeltable UDFs
that wrap various endpoints from the fal.ai API. In order to use them, you must
first `pip install fal-client` and configure your fal.ai credentials, as described in
the [Working with fal.ai](https://docs.pixeltable.com/notebooks/integrations/working-with-fal) tutorial.

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

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
run(input: pxt.Json, *, app: pxt.String) -> pxt.Json
```

Run a model on fal.ai.

Uses fal's queue-based subscribe mechanism for reliable execution.
For additional details, see: [https://fal.ai/docs](https://fal.ai/docs)

Request throttling:
Applies the rate limit set in the config (section `fal`, key `rate_limit`). If no rate
limit is configured, uses a default of 600 RPM.

**Requirements:**

* `pip install fal-client`

**Parameters:**

* **`input`** (`pxt.Json`): The input parameters for the model.
* **`app`** (`pxt.String`): The name or ID of the fal.ai application to run (e.g., 'fal-ai/flux/schnell').

**Returns:**

* `pxt.Json`: The output of the model as a JSON object.

**Examples:**

Add a computed column that applies the model `fal-ai/flux/schnell` to an existing Pixeltable column `tbl.prompt` of the table `tbl`:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
input = {'prompt': tbl.prompt}
tbl.add_computed_column(response=run(input, app='fal-ai/flux/schnell'))
```

Add a computed column that uses the model `fal-ai/fast-sdxl` to generate images from an existing Pixeltable column `tbl.prompt`:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
input = {
    'prompt': tbl.prompt,
    'image_size': 'square',
    'num_inference_steps': 25,
}
tbl.add_computed_column(response=run(input, app='fal-ai/fast-sdxl'))
tbl.add_computed_column(
    image=tbl.response['images'][0]['url'].astype(pxt.Image)
)
```
