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.
Requires PHP 8.1+
First, install GeminiAI via the Composer package manager:
You can install the package via composer:
composer require scott/laravel-gemini
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"
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;
composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.