Skip to main content

module  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 tutorial.

udf  run()

Signature
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 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:
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:
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)
)