fal
Image generation service implementation using fal’s fast SDXL models
Overview
FalImageGenService
provides high-speed image generation capabilities using fal’s optimized Stable Diffusion XL models. It supports various image sizes, formats, and generation parameters with a focus on fast inference.
Installation
To use FalImageGenService
, install the required dependencies:
You’ll also need to set up your Fal API key as an environment variable: FAL_KEY
Configuration
Constructor Parameters
Generation parameters configuration
HTTP session for image downloading
Model identifier
Fal API key (alternative to environment variable)
Input Parameters
Supported Image Sizes
Possible enum values: square_hd
, square
, portrait_4_3
, portrait_16_9
, landscape_4_3
, landscape_16_9
Note: For custom image sizes, you can pass the width and height as an object:
See the fal docs for more information.
Output Frames
URLImageRawFrame
Generated image URL
Raw image data
Image dimensions (width, height)
Image format (e.g., ‘PNG’)
ErrorFrame
Error information if generation fails
Methods
See the Image Generation base class methods for additional functionality.
Usage Example
Frame Flow
Metrics Support
The service collects processing metrics:
- Generation time
- Download time
- API response time
- Total processing duration
Notes
- Fast inference times with optimized models
- Supports various image sizes and formats
- Automatic prompt enhancement option
- Built-in safety filtering
- Asynchronous operation
- Efficient HTTP session management
- Comprehensive error handling