Download the PHP package php-gemini/generative-ai without Composer
On this page you can find all versions of the php package php-gemini/generative-ai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-gemini/generative-ai
More information about php-gemini/generative-ai
Files in php-gemini/generative-ai
Package generative-ai
Short Description Laravel-friendly PHP Package for Google Gemini Generative AI (including image & text)
License MIT
Informations about the package generative-ai
๐ง Gemini PHP SDK for Google Generative AI
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)
- ๐ Full OAuth2 authentication (refresh token supported)
- ๐ง Easy configuration via
.envor constructor - ๐งช PHPUnit + Testbench testing support
- ๐ฏ Laravel-ready (service provider + facade)
- ๐ฆ Composer installable
- ๐ Full documentation included
๐งช Installation
Install via Composer:
โ๏ธ Configuration
For Laravel users, publish the configuration file:
Then update your .env file with your API Key:
๐ Using OAuth2? See the section below on generating and using refresh tokens instead.
๐ OAuth2 Support
This SDK supports Google OAuth2 access via a refresh_token, client_id, and client_secret.
๐ง Generate Refresh Token
To generate your credentials securely, use our standalone command-line script: Zero-Asif/oauth2_refresh_token_generator
Follow the instructions in its README file. After running the script, add the output to your .env file:
โ The SDK will automatically use OAuth2 if an API key is not provided.
๐ Usage
โ In Laravel
โ In Plain PHP
Initialize with an API Key:
Or initialize with OAuth2:
๐ผ๏ธ Image Input (Vision Model)
โ ๏ธ Note: Only supported for models that accept image input, like
gemini-1.5-flash.
๐งช Testing (PHPUnit)
To run the test suite:
To use Testbench for testing within a Laravel application, first install it:
๐ ๏ธ Roadmap
- [x] Text generation
- [x] Laravel integration
- [x] Image input (vision support)
- [x] OAuth2 integration (refresh token support)
- [x] Unit testing & mocking (PHPUnit + Testbench)
- [ ] Streaming response support
- [ ] Online documentation site (mkdocs)
๐ Documentation
Full documentation is available inside: docs/index.md
๐ค Contributing
Pull requests, issues, and feature suggestions are welcome!
๐ License
This project is open-sourced under the MIT License.
๐ Useful Links
- Packagist: php-gemini/generative-ai
- Gemini API Docs: https://ai.google.dev
- OAuth2 Refresh Token Tool: Zero-Asif/oauth2_refresh_token_generator
- Google Cloud Console (OAuth Credentials): https://console.cloud.google.com/apis/credentials
- Project Homepage: https://github.com/php-gemini/generative-ai
๐ Author
Zero-Asif (Asifuzzaman Asif)
- ๐ง Email: [email protected]
- ๐ GitHub: github.com/Zero-Asif
โจ If this project helped you, please โญ the repo!
All versions of generative-ai with dependencies
google/auth Version ^1.47
php Version >=8.0
guzzlehttp/guzzle Version ^7.0
illuminate/support Version *