PHPackages                             amrachraf6699/laravel-gemini-ai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. amrachraf6699/laravel-gemini-ai

ActiveLibrary[API Development](/categories/api)

amrachraf6699/laravel-gemini-ai
===============================

A Laravel package for integrating with Google's Gemini AI API

v1.0.1(3mo ago)288MITPHPPHP ^8.0

Since Mar 15Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/amrachraf6699/laravel-gemini-ai)[ Packagist](https://packagist.org/packages/amrachraf6699/laravel-gemini-ai)[ RSS](/packages/amrachraf6699-laravel-gemini-ai/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Laravel Gemini AI
=================

[](#laravel-gemini-ai)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1b227f7180c47694a77111610210411d5b67f0e680476af2834bb5f1834be2b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d72616368726166363639392f6c61726176656c2d67656d696e692d61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amrachraf6699/laravel-gemini-ai)[![Total Downloads](https://camo.githubusercontent.com/f16e207dc5dc6ecf16d65394ed4c4ca6da8145615dc1f887f9de4c7577ab4540/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616d72616368726166363639392f6c61726176656c2d67656d696e692d61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amrachraf6699/laravel-gemini-ai)

A Laravel package for easy integration with Google's Gemini AI API. This package supports text generation, image generation, and image analysis through a simple and easy-to-use interface.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel 8.0 through 12.x
- Google Gemini AI API key (you can get it from [Google AI Studio](https://ai.google.dev/))

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require amrachraf6699/laravel-gemini-ai
```

Configuration
-------------

[](#configuration)

After installing the package, publish the configuration file:

```
php artisan vendor:publish --tag=gemini-config
```

Then, add your API key to your `.env` file:

```
GEMINI_API_KEY=your-api-key-here
```

You can also customize the models used:

```
GEMINI_TEXT_MODEL=gemini-2.0-flash
GEMINI_IMAGE_MODEL=gemini-2.0-flash-exp
GEMINI_VISION_MODEL=gemini-2.0-flash
```

Usage
-----

[](#usage)

### Text Generation

[](#text-generation)

```
use Amrachraf6699\LaravelGeminiAi\Facades\GeminiAi;

// Generate simple text
$response = GeminiAi::generateText("Tell me about black holes.");

// Using additional options
$response = GeminiAi::generateText("Write a short story about space exploration.", [
    'model' => 'gemini-2.0-pro', // Use a custom model
    'raw' => true, // Return the full response instead of just the text
    'generationConfig' => [
        'temperature' => 0.7,
        'maxOutputTokens' => 1000
    ]
]);
```

### Image Generation

[](#image-generation)

```
// Generate an image
$response = GeminiAi::generateImage("A futuristic city skyline at sunset.");

// Using the response
if (!empty($response['image_url'])) {
    // Use $response['image_url'] to display the image
    echo '';

    // Any text associated with the image
    echo $response['text'];
}
```

### Image Analysis

[](#image-analysis)

```
// Analyze an image using an uploaded file
$imageFile = $request->file('image');
$response = GeminiAi::processImageText("Describe this image in detail.", $imageFile);

// Analyze an image using a file path
$response = GeminiAi::processImageText("What's in this picture?", public_path('images/example.jpg'));

// Analyze an image using binary content or base64 string
$imageContent = file_get_contents('path/to/image.jpg');
$response = GeminiAi::processImageText("Analyze this image.", $imageContent);
```

Error Handling
--------------

[](#error-handling)

The package throws exceptions when errors occur, so it's recommended to use try/catch:

```
try {
    $response = GeminiAi::generateText("Tell me a joke.");
} catch (\Exception $e) {
    // Handle the error
    Log::error('Gemini API Error: ' . $e->getMessage());
}
```

Available Options
-----------------

[](#available-options)

All methods support an `options` array that can be used to customize API requests:

OptionDescription`model`Custom model to use`raw`When set to `true`, returns the full API response instead of extracting content`generationConfig`Array of configuration options for the model (like temperature, tokens)Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit pull requests or open issues on GitHub.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance80

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~316 days

Total

2

Last Release

108d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/edccf2dc747c01b536a671aa552e587b5f6a595747ecbe77d44b95dd9ad1195a?d=identicon)[amrachraf6699](/maintainers/amrachraf6699)

---

Top Contributors

[![amrachraf6699](https://avatars.githubusercontent.com/u/168471094?v=4)](https://github.com/amrachraf6699 "amrachraf6699 (2 commits)")

### Embed Badge

![Health badge](/badges/amrachraf6699-laravel-gemini-ai/health.svg)

```
[![Health](https://phpackages.com/badges/amrachraf6699-laravel-gemini-ai/health.svg)](https://phpackages.com/packages/amrachraf6699-laravel-gemini-ai)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
