php-gemini / generative-ai
Laravel-friendly PHP Package for Google Gemini Generative AI (including image & text)
Requires
- php: >=8.0
- google/auth: ^1.47
- guzzlehttp/guzzle: ^7.0
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- illuminate/config: ^12.19
- illuminate/contracts: ^12.19
- illuminate/support: ^12.19
This package is auto-updated.
Last update: 2025-06-29 17:22:21 UTC
README
A Laravel-friendly, lightweight PHP SDK to interact with Google Gemini Generative AI. Supports text generation, image input (vision), and is fully customizable for any PHP project.
β¨ Features
- β Gemini text generation (prompt β response)
- πΌοΈ Image input support (base64 vision models)
- βοΈ Configurable model & API key via
.env
- π― Laravel-ready (service provider + facade)
- π OAuth2 support planned
- π¦ Composer installable
- π Full documentation included
π§ͺ Installation
Install via Composer:
composer require php-gemini/generative-ai
βοΈ Configuration
For Laravel users, publish the configuration file:
php artisan vendor:publish --provider="PhpGemini\GenerativeAI\Providers\GeminiServiceProvider"
Then update your .env
file:
GEMINI_API_KEY=your_actual_api_key GEMINI_MODEL=gemini-1.5-flash
You can also update config/gemini.php
as needed.
π Usage
β In Laravel
use Gemini; echo Gemini::generate("What's the future of AI?");
β In Plain PHP
use PhpGemini\GenerativeAI\GeminiClient; require 'vendor/autoload.php'; $gemini = new GeminiClient('your_api_key', 'gemini-1.5-flash'); echo $gemini->generateContent("Tell me something interesting.");
πΌοΈ Image Input (Vision Model)
$response = $gemini->generateContentWithImage('path/to/image.jpg', 'Whatβs in this image?');
β οΈ Note: Only works with models that support image input, like
gemini-1.5-flash
orgemini-pro-vision
.
π οΈ Roadmap
- Text generation
- Laravel integration
- Image input (vision support)
- Streaming response support
- OAuth2 integration
- Unit testing & mocking
- Online documentation site (mkdocs)
π Documentation
Full documentation is available inside: docs/index.md
π€ Contributing
Pull requests, issues, and feature suggestions are welcome!
git clone [https://github.com/php-gemini/generative-ai.git](https://github.com/php-gemini/generative-ai.git)
cd generative-ai
composer install
π License
This project is open-sourced under the MIT license.
π Useful Links
- Packagist: php-gemini/generative-ai
- Gemini API Docs: https://ai.google.dev
- Documentation:
docs/index.md
π Author
Zero-Asif (Asifuzzaman Asif)
- π§ Email: asifuzzamanasif0001@gmail.com
- π GitHub: github.com/Zero-Asif
β¨ If this project helped you, please β the repo!