yunusasuroglu/laravel-gemini-ai

A package to interact with Gemini API without routes

v1.0 2024-12-21 17:30 UTC

This package is auto-updated.

Last update: 2025-05-21 21:44:39 UTC


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

  1. Fork this project.
  2. Create a new feature branch (feature/feature-adi).
  3. Commit your changes (git commit -m 'New feature added').
  4. Push the branch to master (git push origin feature/feature-adi).
  5. Open a Pull Request.

Licence

This project is licensed under the MIT License.