Download the PHP package liteopensource/gemini-lite-laravel without Composer
On this page you can find all versions of the php package liteopensource/gemini-lite-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download liteopensource/gemini-lite-laravel
More information about liteopensource/gemini-lite-laravel
Files in liteopensource/gemini-lite-laravel
Package gemini-lite-laravel
Short Description Redisingned and easy to use Gemini Lite SDK for Laravel
License MIT
Informations about the package gemini-lite-laravel
Gemini Lite for Laravel - Documentation
🦸🏽♀️🛠️🪚⚙️🦸🏽 YOU CAN CONTRIBUTE TO THIS PROJECT, CONTACT ME TO: [email protected] 🦸🏽♀️🛠️🪚⚙️🦸🏽
Why use Gemini lite instead other open source Gemini Sdk?
Thanks to its minimalist syntax based on Facades, you can integrate AI functionalities effortlessly. Soon, it will include a ✨token and request limit management system inspired by Laravel Permission✨, perfect for streamlining monetizable projects. Moreover, its support is guaranteed until 2026, as it will be used in two projects set to be launched into production this year.Support the project and help extend its lifespan. If you'd like to contribute, feel free to contact me.
Features
Feature status:
- 🟢 Feature added
- 🟡 Feature in progress
- 🔴 Feature doesn't started
- 🟣 Feature doesn't planet (If you want contribute with this, contact me)
In progress | Progress Status |
---|---|
Text prompt support | 🟢 |
Text prompt with file(Image, pdf, etc) support | 🟢 |
Chat history support | 🟢 |
Change model config in runtime | 🟢 |
Change between Gemini models | 🟢 |
JSON mode support | 🟢 |
Easy upload file to get uri and mime type | 🟢 |
Easy get current gemini config function | 🟢 |
Easy get chat history of current chat instance | 🟢 |
✨ Limit tokens and request support ✨ | 🟢 |
Tokens counter before to do prompt | 🟢 |
Gemini flash 2.0 beta | 🟢 |
Automatic unit testing | 🟡 |
Embedding support | 🟢 |
Image generator support | 🟣 |
Table of Contents
- Gemini Lite for Laravel - Documentation
- Why use Gemini lite instead other open source Gemini Sdk?
- Features
- Table of Contents
- Get Started
- Requeriments
- Installation
- Configuration
- GeminiService
- Creating a New Chat
- Sending Prompts
- Changing Model Configuration
- Using JSON Mode
- Changing Gemini Model
- Getting Current Model Configuration
- Getting Chat History
- UploadFileToGeminiService
- Processing Files from a Path
- Processing Uploaded Files
- GeminiTokenCountService
- Token Limit
- AssignRole
- Can make request?
- Is active
- Update usage
- Store Gemini Request
- EmbeddingService
- Basic Usage
- Examples
- Text-Based Chat
- Image-Based Chat
- Changing Configuration at Runtime
- JSON Mode Chat
- Changing Gemini Model Example
- Getting Current Model Configuration Example
- Count the number of tokens in a given text.
- Check if the user can make a request to Gemini.
- Check if the user is active in Gemini.
- Update the usage tracking for the user.
- Assign roles to test users.
- Log the requests made by the user.
- License
Get Started
Requeriments
You have to verify have added in your project:
- php: Minimum version ^8.0
- PostgreSQL
- guzzlehttp/guzzle: Minimum version ^7.0
- illuminate/console: Minimum version ^9.0
- illuminate/database: Minimum version ^9.0
- illuminate/http: Minimum version ^9.0
- illuminate/support: Minimum version ^9.0
Installation
To install the Gemini Lite for Laravel package, use or add the following line to your composer.json
Then run:
Configuration
Publish your config file using:
Add your Gemini API key to your file:
GeminiService
GeminiService provides methods to interact with the Gemini AI model.
Creating a New Chat
Example of starting a new chat session:
Sending Prompts
To send a prompt to the Gemini model:
Changing Model Configuration
You can modify the model configuration at runtime:
Using JSON Mode
Changing Gemini Model
You can switch between different Gemini models. The currently available models are:
Stable Models
- gemini-1.5-flash: Fast and efficient model for everyday use.
- gemini-1.5-pro: Advanced professional model with enhanced capabilities.
- gemini-1.5-flash-8b: Lightweight 8B parameter version for faster processing.
- gemini-2.0-flash: Improved speed and performance in the 2.0 series.
- gemini-2.0-flash-lite: A lightweight version of Gemini 2.0 Flash.
- gemini-2.0-flash-lite-preview-02-05: Preview of the lightweight 2.0 version.
Experimental Models
- gemini-2.0-flash-exp: Cutting-edge features in the experimental Flash model.
- gemini-2.0-pro-exp-02-05: Professional experimental model in the 2.0 series.
- gemini-2.0-flash-thinking-exp-01-21: Enhanced reasoning capabilities.
- gemini-2.0-flash-exp-image-generation: Specialized model for image generation tasks.
- learnlm-1.5-pro-experimental: Learning-focused experimental model.
Gemini 2.5 Models
- gemini-2.5-pro-preview-03-25: Preview version of Gemini 2.5 Pro (note: no free quota tier).
- gemini-2.5-pro-exp-03-25: Experimental version of Gemini 2.5 Pro with free quota tier access.
Note: The
gemini-2.5-pro-preview-03-25
model doesn't have a free quota tier. Google recommends using the experimental version (gemini-2.5-pro-exp-03-25
) for free tier access.
Getting Current Model Configuration
You can retrieve the current configuration of the Gemini model:
Getting Chat History
You can retrieve the complete chat history of your conversation with Gemini:
UploadFileToGeminiService
This service allows you to upload files for processing by Gemini.
Processing Files from a Path
To process a file from a local path:
Processing Uploaded Files
This is really useful when you work with Livewire and using
To process an uploaded file:
GeminiTokenCountService
This service is responsible for counting the tokens consumed by a text prompt. It returns an integer indicating the number of tokens consumed by the text prompt.
Token Limit
Token limit is independent of GeminiChat so the use of this feature is not integrated into the use of Gemini
This feature is intended for controlling user token consumption. It uses tables in the database to control usage. Therefore, it is important to publish the respective seeders for its operation.
Command to publish seeder and tables:
To use this feature you need to add the HasGeminiRoles trait to the model user
AssignRole
Can make request?
This function is for check if the user can make request to Gemini according to the established limits. The function returs a boolean value
Is active
This function is for check if the user is active. The function returs a boolean value
The difference between isActive and canMakeRequest is that canMakeRequest works based on the limit of tokens and daily and monthly requests and isActive is a more manual and controlled way of controlling the use.
Update usage
This method updates gemini usage, increments the request counter, and increments the token counter. As a parameter it receives the number of tokens used by a prompt as an integer.
Store Gemini Request
This function is intended to store data from the request to gemini, this function does not affect the tracking of user usage, it only stores data.
EmbeddingService
This service provides text embedding capabilities using Gemini's text-embedding-004 model.
Basic Usage
Examples
Text-Based Chat
You can keep chat history easily:
Image-Based Chat
You can combine image prompt and text prompt in the only one prompt
Changing Configuration at Runtime
JSON Mode Chat
Here's an example of using JSON mode to generate cookie recipes:
Changing Gemini Model Example
You can compare responses from different Gemini models:
Getting Current Model Configuration Example
You can compare responses from different Gemini models:
Count the number of tokens in a given text.
Check if the user can make a request to Gemini.
Check if the user is active in Gemini.
Update the usage tracking for the user.
Assign roles to test users.
Log the requests made by the user.
License
MIT License
Copyright (c) 2025 José López Lara
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “liteopensource/gemini-lite-laravel”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All versions of gemini-lite-laravel with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/console Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/database Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/http Version ^9.0 || ^10.0 || ^11.0 || ^12.0