Overview
Google Gemini integration provides access to Gemini 1.5 Pro, Flash, and 2.5 models through the Generative AI API. Supports multimodal inputs (text, images, video), large context windows, and advanced reasoning.Setup
Get API Key
Visit Google AI Studio and create an API key
Configuration
Basic Parameters
Google Generative AI API key credential
The Gemini model to use:
gemini-2.5-pro- Most capable, latest generationgemini-2.5-flash- Fast and efficientgemini-1.5-pro-latest- Previous generation progemini-1.5-flash-latest- Previous generation flashgemini-1.0-pro- Legacy model
Override with a custom model name (e.g., experimental models like
gemini-1.5-pro-exp-0801)Controls randomness (0.0 to 1.0). Lower = more deterministic
Enable streaming responses
Advanced Parameters
Maximum tokens to generate. Gemini 1.5 supports up to 8192 output tokens
Nucleus sampling threshold (0.0 to 1.0)
Sample from top K most probable tokens. Must be positive
Safety Settings
Configure content filtering for different harm categories:Harm Categories:
HARM_CATEGORY_DANGEROUS_CONTENT- Violence, dangerous actsHARM_CATEGORY_HARASSMENT- Harassment, bullyingHARM_CATEGORY_HATE_SPEECH- Hate speechHARM_CATEGORY_SEXUALLY_EXPLICIT- Sexual contentHARM_CATEGORY_CIVIC_INTEGRITY- Election-related content
BLOCK_NONE- Don’t block any contentBLOCK_ONLY_HIGH- Block only high-probability harmful contentBLOCK_MEDIUM_AND_ABOVE- Block medium and highBLOCK_LOW_AND_ABOVE- Block low, medium, and highHARM_BLOCK_THRESHOLD_UNSPECIFIED- Use default
Thinking Budget (Gemini 2.5)
Thinking budget is available for Gemini 2.5 models to guide internal reasoning.
Guide the number of thinking tokens:
-1- Dynamic budget (recommended)0- Disable thinking- Positive integer - Fixed thinking token budget
Multimodal Support
Enable image input for multimodal analysis
Custom API base URL (for Vertex AI or custom endpoints)
Usage Examples
Basic Text Chat
Multimodal Image Analysis
With Safety Settings
Gemini 2.5 with Thinking
Using Custom Model
Model Comparison
| Model | Context Window | Output Tokens | Best For | Speed |
|---|---|---|---|---|
| Gemini 2.5 Pro | 2M tokens | 8K | Complex reasoning | Medium |
| Gemini 2.5 Flash | 1M tokens | 8K | Fast responses | Fast |
| Gemini 1.5 Pro | 1M tokens | 8K | Multimodal tasks | Medium |
| Gemini 1.5 Flash | 1M tokens | 8K | High volume | Very Fast |
Best Practices
Model Selection
- Use Flash for most production tasks
- Use Pro for complex analysis
- Use 2.5 for latest capabilities
- Test experimental models in dev
Safety Configuration
- Set appropriate safety thresholds
- Test with your content
- Monitor blocked responses
- Adjust per use case
Multimodal
- Enable image uploads only when needed
- Consider image size and format
- Use clear text prompts
- Test with sample images
Performance
- Enable streaming for UX
- Use Flash for speed
- Set appropriate token limits
- Monitor latency
Long Context Windows
Gemini models support extremely large contexts:- Gemini 2.5 Pro: Up to 2 million tokens
- Gemini 1.5 Pro/Flash: Up to 1 million tokens
- Analyze entire codebases
- Process lengthy documents
- Long conversation history
- Multi-turn complex tasks
Common Issues
Safety Filter Triggered
Safety Filter Triggered
If responses are blocked:
- Check safety settings configuration
- Review harm categories and thresholds
- Consider using
BLOCK_NONEfor dev/test - Rephrase prompts to be less ambiguous
Rate Limiting
Rate Limiting
Google AI has rate limits based on your tier:
- Free tier: 15 RPM, 1M TPM
- Paid tier: 360 RPM, 4M TPM
- Implement exponential backoff
- Batch requests when possible
- Consider paid tier for production
Model Not Available
Model Not Available
Some models require allowlist access:
- Use generally available models
- Check model availability by region
- Request access for experimental models
Image Upload Issues
Image Upload Issues
For multimodal inputs:
- Ensure
allowImageUploadsis enabled - Check image format (JPEG, PNG, WebP)
- Verify image size limits
- Use supported MIME types
Pricing
Gemini uses input/output token pricing:| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|
| Gemini 1.5 Flash | $0.075 | $0.30 |
| Gemini 1.5 Pro | $1.25 | $5.00 |
| Gemini 2.5 Pro | $2.50 | $10.00 |