image

Fal’s image generation service implementation.

This module provides integration with Fal’s image generation API for creating images from text prompts using various AI models.

class pipecat.services.fal.image.FalImageGenSettings(model: str | None | _NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, seed: int | None | _NotGiven = <factory>, num_inference_steps: int | _NotGiven = <factory>, num_images: int | _NotGiven = <factory>, image_size: str | dict[str, int] | ~pipecat.services.settings._NotGiven=<factory>, expand_prompt: bool | _NotGiven = <factory>, enable_safety_checker: bool | _NotGiven = <factory>, format: str | _NotGiven = <factory>)[source]

Bases: ImageGenSettings

Settings for the Fal image generation service.

Parameters:
  • model – Fal.ai model identifier.

  • seed – Random seed for reproducible generation. None uses a random seed.

  • num_inference_steps – Number of inference steps for generation.

  • num_images – Number of images to generate.

  • image_size – Image dimensions as a string preset or dict with width/height.

  • expand_prompt – Whether to automatically expand/enhance the prompt.

  • enable_safety_checker – Whether to enable content safety filtering.

  • format – Output image format.

seed: int | None | _NotGiven
num_inference_steps: int | _NotGiven
num_images: int | _NotGiven
image_size: str | dict[str, int] | _NotGiven
expand_prompt: bool | _NotGiven
enable_safety_checker: bool | _NotGiven
format: str | _NotGiven
to_api_arguments() dict[str, Any][source]

Build the Fal API arguments dict from settings, excluding None values.

class pipecat.services.fal.image.FalImageGenService(*, params: InputParams | None = None, aiohttp_session: ClientSession, model: str | None = None, key: str | None = None, settings: FalImageGenSettings | None = None, **kwargs)[source]

Bases: ImageGenService

Fal’s image generation service.

Provides text-to-image generation using Fal.ai’s API with configurable parameters for image quality, safety, and format options.

Settings

alias of FalImageGenSettings

class InputParams(*, seed: int | None = None, num_inference_steps: int = 8, num_images: int = 1, image_size: str | dict[str, int] = 'square_hd', expand_prompt: bool = False, enable_safety_checker: bool = True, format: str = 'png')[source]

Bases: BaseModel

Input parameters for Fal.ai image generation.

Deprecated since version 0.0.105: Use settings=FalImageGenService.Settings(...) instead.

Parameters:
  • seed – Random seed for reproducible generation. If None, uses random seed.

  • num_inference_steps – Number of inference steps for generation. Defaults to 8.

  • num_images – Number of images to generate. Defaults to 1.

  • image_size – Image dimensions as string preset or dict with width/height. Defaults to “square_hd”.

  • expand_prompt – Whether to automatically expand/enhance the prompt. Defaults to False.

  • enable_safety_checker – Whether to enable content safety filtering. Defaults to True.

  • format – Output image format. Defaults to “png”.

seed: int | None
num_inference_steps: int
num_images: int
image_size: str | dict[str, int]
expand_prompt: bool
enable_safety_checker: bool
format: str
__init__(*, params: InputParams | None = None, aiohttp_session: ClientSession, model: str | None = None, key: str | None = None, settings: FalImageGenSettings | None = None, **kwargs)[source]

Initialize the FalImageGenService.

Parameters:
  • params

    Input parameters for image generation configuration.

    Deprecated since version 0.0.105: Use settings=FalImageGenService.Settings(...) instead.

  • aiohttp_session – HTTP client session for downloading generated images.

  • model

    The Fal.ai model to use for generation. Defaults to “fal-ai/fast-sdxl”.

    Deprecated since version 0.0.105: Use settings=FalImageGenService.Settings(model=...) instead.

  • key – Optional API key for Fal.ai. If provided, sets FAL_KEY environment variable.

  • settings – Runtime-updatable settings. When provided alongside deprecated parameters, settings values take precedence.

  • **kwargs – Additional arguments passed to parent ImageGenService.

async run_image_gen(prompt: str) AsyncGenerator[Frame, None][source]

Generate an image from a text prompt.

Parameters:

prompt – The text prompt to generate an image from.

Yields:

URLImageRawFrame – Frame containing the generated image data and metadata. ErrorFrame: If image generation fails.