Download the PHP package cjmellor/fal-ai-laravel without Composer
On this page you can find all versions of the php package cjmellor/fal-ai-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package fal-ai-laravel
Fal.ai Laravel Package
A Laravel package for integrating with the Fal.ai API, providing a fluent interface for AI model interactions with built-in webhook support.
Features
- ๐ Fluent API - Chainable methods for easy request building
- ๐ Webhook Support - Secure webhook handling with ED25519 signature verification
- โก Queue & Sync Modes - Support for both immediate and queued requests
- ๐ก๏ธ Security - Built-in webhook verification middleware
- ๐งช Well Tested - Comprehensive test suite
- ๐ Laravel Integration - Native Laravel middleware and service provider
- ๐ฃ๏ธ Built-in Routes - Pre-configured webhook endpoints ready to use
Installation
Install the package via Composer:
Publish the configuration file:
Add your Fal.ai API key to your .env
file:
Basic Usage
Simple Request
Queue vs Sync Modes
[!TIP] Queue mode is the default and recommended for most use cases. It's perfect for complex generations that take time to process.
Queue Mode (Default)
Use queue mode when:
- Generating high-quality images with many inference steps
- Processing multiple images in batch
- You don't need immediate results
- Working with complex prompts or large image sizes
Sync Mode
Use sync mode when:
- You need immediate results
- Generating simple images with few inference steps
- Building interactive applications
- Testing and development
[!WARNING] Sync mode may timeout for complex requests. Use queue mode for production applications.
Webhook Support
[!NOTE] For comprehensive webhook documentation, see the Webhook Guide
Making Requests with Webhooks
When you add a webhook URL to your request, it automatically switches to queue mode:
Webhook URL Requirements
- Must be a valid HTTPS URL
- Must be publicly accessible
- Should respond with 2xx status codes
Setting Up Webhook Endpoints
You have two options for handling webhooks: use the built-in route or create your own custom endpoint.
Option 1: Built-in Webhook Route (Easiest)
The package includes a pre-configured webhook route at /webhooks/fal
that handles basic webhook processing:
[!TIP] The built-in route automatically verifies webhooks and returns appropriate responses. Perfect for getting started quickly!
Option 2: Custom Webhook Endpoint (Recommended for Production)
For production applications, create a custom webhook endpoint with your own processing logic:
Option 3: Manual Verification (Advanced)
For complete control over the verification process:
Webhook Payload Examples
Successful Completion
Error
โ๏ธ Configuration
[!NOTE] You can customise the package behaviour by publishing and modifying the configuration file.
The configuration file config/fal-ai.php
contains the following options:
Environment Variables
Available Models
The package supports all Fal.ai models. Some popular ones include:
FLUX Models (Recommended):
fal-ai/flux/schnell
- Fast image generation (1-4 steps)fal-ai/flux/dev
- High-quality image generation (12B parameters)fal-ai/flux/pro
- Professional grade (API only)fal-ai/flux-lora
- FLUX with LoRA support
Other Popular Models:
fal-ai/stable-diffusion-v35-large
- Latest Stable Diffusion 3.5fal-ai/recraft/v3
- Vector art and typographyfal-ai/aura-flow
- High-quality text-to-imagefal-ai/ideogram/v2
- Excellent typography handling
Fluent API Methods
Common Methods
Error Handling
[!IMPORTANT] Always implement proper error handling in production applications to gracefully handle API failures and webhook verification issues.
๐งช Testing
Run the test suite:
๐ Security
[!CAUTION] Webhook security is critical for protecting your application from malicious requests. Always use the provided verification mechanisms.
Webhook Security
This package implements Fal.ai's webhook verification using:
- ED25519 signature verification using Fal.ai's public keys
- Timestamp validation to prevent replay attacks
- JWKS caching for performance
- Automatic header extraction and validation
Best Practices
[!TIP] Follow these security practices to ensure your webhook endpoints are secure:
- Always use HTTPS for webhook URLs
- Use the provided middleware for automatic verification
- Validate webhook payloads in your application logic
- Implement proper error handling and logging
- Monitor webhook endpoints for suspicious activity
- Use rate limiting on webhook routes
- Keep your API keys secure and rotate them regularly
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This package is open-sourced software licensed under the MIT license.
๐ฌ Support
For support, please open an issue on GitHub or contact the maintainers.