yunusasuroglu / laravel-gemini-ai
A package to interact with Gemini API without routes
v1.0
2024-12-21 17:30 UTC
Requires
- php: ^8.0
README
This is a Laravel package to interact with Google's Gemini AI API. It allows you to send text to the API and receive the generated content in return.
Installation
To install the package, run the following Composer command in your Laravel project:
composer require yunusasuroglu/laravel-gemini-ai
Controller
$geminiService = new GeminiService(); $text = "The text to be sent to the API will come here"; $apiKey = env('GEMINI_API_KEY'); try { $result = $geminiService->create($text, $apiKey); echo $result['text']; // Prints the response returned by the API to the screen } catch (\Exception $e) { echo 'Error: ' . $e->getMessage(); }
Requirements
- PHP 8.0 or above
- Composer
Contribute
- Fork this project.
- Create a new feature branch (
feature/feature-adi
). - Commit your changes (
git commit -m 'New feature added'
). - Push the branch to master (
git push origin feature/feature-adi
). - Open a Pull Request.
Licence
This project is licensed under the MIT License.