scott / laravel-gemini
A php package for Gemini ai
Requires
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- laravel/pint: ^1.13
- orchestra/testbench: *
- pestphp/pest: ^2.28
- phpstan/phpstan: ^1.10
This package is auto-updated.
Last update: 2025-03-04 23:37:51 UTC
README
This package provides a simple way to use the Gemini API in your Laravel
applications.
The Laravel Gemini package provides a convenient interface for interacting with the Gemini API to generate text based on
a given prompt.
This documentation outlines how to use the GeminiAi
class, its methods, and configuration.
Get Started
Requires PHP 8.1+
First, install GeminiAI via the Composer package manager:
Installation
You can install the package via composer:
composer require scott/laravel-gemini
Configuration
The Laravel Gemini package can be configured using environment variables. The following environment variables are available:
This will create a config/gemini.php
configuration file in your project, which you can modify to your needs
using environment variables.
Blank environment variables for the Google gemini API key and organization id are already appended to your .env
file.
GOOGLE_GEMINI_API_KEY=
You can publish the config file with:
php artisan vendor:publish --provider="Scott\LaravelGemini\LaravelGeminiServiceProvider" --tag="laravel-gemini-config"
Usage
To use the Laravel Gemini package for text generation, follow these steps:
- Create a new instance of Gemini AI:
use Scott\LaravelGemini\GeminiAi; $prompt = GeminiAi::models('gemini-pro') ->generateText('I am a web developer');
- Call the
generateText
method:
echo $prompt;
Testing
composer test
Security
If you discover any security related issues, please email tresorkasendat@gmail.com instead of using the issue tracker.