fal-rs
A Rust client for the fal.ai API, providing easy access to state-of-the-art AI models for image generation, audio processing, and more.
Features
- Type-safe API: Strongly typed interfaces for all fal.ai endpoints, generated and kept up-to-date straight from the API itself
- Async/Await Support: Built on top of
reqwestfor efficient async operations - Queue System: Built-in support for fal.ai's queue system for long-running operations
- Image Processing: Optional image processing capabilities with the
imagefeature
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Usage
Using public model endpoints
By default, the endpoints feature is enabled, and you can use pre-built, fully-typed endpoint functions to call the API:
use *;
async
Using the Queue System
For long-running operations, you can use the FAL Queue API:
use *;
use StreamExt;
async
The #[endpoint] macro
You can easily create a custom endpoint function using the provided endpoint proc macro. This should only be necessary if you disable the endpoints feature, or you are using a private model endpoint.
use *;
use Deserialize;
// This endpoint function can now be used to call the fal endpoint:
async
Features
The crate comes with several optional features:
image(enabled by default): Provides image processing capabilities using theimagecrateendpoints(enabled by default): Includes pre-generated endpoint modules for fal.ai services
Generating Endpoint Modules
The generate package in this repository is used to automatically generate endpoint modules based on the fal.ai API specification. This ensures that the client always has up-to-date type definitions and endpoint implementations.
To generate endpoint modules:
- Clone the repository
- Run the generate package:
This will update the endpoint modules in the fal/src/endpoints directory with the latest API definitions, using the model registry from the FAL API.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
We welcome contributions! Please feel free to submit a Pull Request.