Gemini Provider
The Gemini provider gives you access to Google’s Gemini models, featuring the efficient Flash series and powerful Pro models with extensive context windows.Configuration
API Key Setup
Set your Google API key in your.env file:
config/llm-magic.php:
Available Models
LLM Magic supports the following Gemini models:Gemini 1.5 Series
- gemini-1.5-flash - Fast and efficient model
- gemini-1.5-flash-8b - Compact 8B parameter model
- gemini-1.5-pro - High-performance model with 2M token context
Gemini 2.0 Series
- gemini-2.0-flash - Latest Flash model optimized for agents
- gemini-2.0-flash-lite - Lightweight Flash variant
Gemini 2.5 Series
- gemini-2.5-flash-lite - Compact Flash model
- gemini-2.5-flash - Latest Flash model
- gemini-2.5-pro - Latest Pro model
Experimental Models
- gemini-2.5-flash-preview-04-17 - Flash preview build
- gemini-2.5-pro-preview-03-25 - Pro preview build
- gemini-2.5-pro-exp-03-25 - Pro experimental build
Model Constants
Use these constants for type safety:Usage
Using the Constructor
Create a Gemini model instance:Using Static Factory Methods
LLM Magic provides convenient static methods:Getting Available Models
Retrieve a list of all available Gemini models:Model Costs
Gemini models include built-in cost tracking. The following pricing is configured (per 1M tokens):| Model | Input Cost | Output Cost |
|---|---|---|
| Gemini 1.5 Flash | $0.15 | $0.60 |
| Gemini 1.5 Flash 8B | $0.075 | $0.30 |
| Gemini 1.5 Pro | $2.50 | $10.00 |
| Gemini 2.0 Flash | $0.10 | $0.40 |
| Gemini 2.0 Flash Lite | $0.075 | $0.30 |
| Gemini 2.5 Flash Preview | $0.15 | $0.60 |
| Gemini 2.5 Pro Preview | $1.25 | $5.00 |
| Gemini 2.5 Pro Experimental | $1.25 | $5.00 |
API Configuration
Gemini uses the OpenAI-compatible API with a custom base URI:Organization Info
The Gemini provider includes organization metadata:- ID:
google - Name: Google
- Website: https://google.com
- Privacy: Data may be used for model training and abuse prevention
Features
Multimodal Support
Gemini models support text, image, video, and audio inputs:- Text: All models
- Images: All models
- Video: Flash and Pro models
- Audio: 2.0 Flash and newer
Large Context Windows
- Gemini 1.5 Pro: Up to 2 million tokens
- Gemini 2.0 Flash: 1 million tokens
- Gemini 2.5 Flash: 1 million tokens
Context Caching
Gemini 2.0 Flash and later support context caching for reduced costs on repeated queries.Advanced Options
You can pass additional options usingChatGptOptions: