The fal_client
is a robust and user-friendly library designed for seamless integration of fal serverless functions in Dart and Flutter projects. Developed in pure Dart, it provides developers with simple APIs to interact with AI models and works across all supported Flutter platforms.
The fal_client
library serves as a client for fal serverless Python functions. For guidance on creating your functions, refer to the quickstart guide.
This client library is crafted as a lightweight layer atop platform standards like http
and cross_file
. This ensures a hassle-free integration into your existing codebase. Moreover, it addresses platform disparities, guaranteeing flawless operation across various Flutter runtimes.
Note: Ensure you've reviewed the fal-serverless getting started guide to acquire your credentials and register your functions.
- Start by adding
fal_client
as a dependency:
flutter pub add fal_client
- Setup the client instance:
import 'package:fal_client/fal_client.dart';
final fal = FalClient.withCredentials('FAL_KEY_ID:FAL_KEY_SECRET');
- Now use
fal.subcribe
to dispatch requests to the model API:
final result = await fal.subscribe('text-to-image',
input: {
'prompt': 'a cute shih-tzu puppy',
'model_name': 'stabilityai/stable-diffusion-xl-base-1.0',
'image_size': 'square_hd'
},
onQueueUpdate: (update) => {print(update)}
);
Notes:
- Replace
text-to-image
with a valid model id. Check fal.ai/models for all available models. - The result type is a
Map<String, dynamic>
and the entries depend on the API output schema.
See the open feature requests for a list of proposed features and join the discussion.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Make sure you read our Code of Conduct
- Fork the project and clone your fork
- Setup the local environment with
npm install
- Create a feature branch (
git checkout -b feature/add-cool-thing
) or a bugfix branch (git checkout -b fix/smash-that-bug
) - Commit the changes (
git commit -m 'feat(client): added a cool thing'
) - use conventional commits - Push to the branch (
git push --set-upstream origin feature/add-cool-thing
) - Open a Pull Request
Check the good first issue queue, your contribution will be welcome!
Distributed under the MIT License. See LICENSE for more information.