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 useFalImageGenService
, install the required dependencies:
FAL_KEY
You can obtain a fal API key by signing up at fal.
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:
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