- How do I install and set up this package in Laravel?
- Run `composer require hosseinhezami/laravel-gemini`, publish the config with `php artisan vendor:publish --tag=gemini-config`, and add your `GEMINI_API_KEY` to your `.env` file. The package auto-configures for Laravel 10+ and requires no additional setup beyond these steps.
- Does this package support real-time streaming responses from Gemini?
- Yes, the package includes streaming capabilities with configurable chunk sizes and timeouts. Use `Gemini::stream()` to handle responses incrementally, ideal for chatbots or live AI interactions.
- Can I use function-calling with custom tools in this package?
- The package supports Gemini’s function-calling feature, allowing you to define custom tools. However, you’ll need to manually structure the function schemas in your prompts, as the package doesn’t auto-generate tool configurations.
- What Laravel versions are officially supported?
- This package is fully compatible with Laravel 10 and 11. It leverages Laravel’s service container and facades, so no additional adjustments are needed for these versions.
- How does caching work, and can I customize it?
- The package integrates with Laravel’s cache drivers (e.g., Redis, file, database) to cache responses. Configure the default TTL and cache tags in `config/gemini.php` to optimize performance and reduce API costs.
- Are there built-in retries for failed API requests?
- Yes, the package includes a retry policy with configurable max retries (default: 3) and delay (default: 1 second). Adjust these in `config/gemini.php` under `retry_policy` for your reliability needs.
- Can I process large files (e.g., videos or audio) with this package?
- The package supports file uploads for video, audio, and document processing, but large files may require chunked uploads or custom logic. Ensure your server has PHP extensions like `fileinfo`, `gd`, and `curl` enabled for optimal performance.
- Does this package work with Laravel Queues for async processing?
- Yes, you can dispatch Gemini tasks to Laravel Queues for async processing, especially useful for long-running tasks like video analysis. Use the `Gemini::generate()` method with queue jobs to offload heavy workloads.
- How do I handle API rate limits or throttling?
- The package includes rate-limiting logic, but test under load to ensure it meets your needs. For stricter control, implement middleware to enforce additional limits or use Laravel’s `throttle` middleware in combination.
- Are there alternatives if I need offline AI capabilities?
- This package relies solely on Google Gemini’s API and lacks built-in offline fallbacks. For hybrid solutions, consider integrating a local LLM (e.g., Ollama) alongside this package, using caching as a fallback mechanism.