Quick Start
Get your API key
Get an API key from Google AI Studio.
Configuration
Basic Configuration
Available Models
Environment Variables
| Variable | Scoped Version | Purpose |
|---|---|---|
GEMINI_API_KEY | AVANTE_GEMINI_API_KEY | API authentication |
API Endpoint Structure
Gemini uses a unique endpoint structure:Generation Configuration
Gemini usesgenerationConfig for model parameters:
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
temperature | number | 0.75 | Controls randomness (0.0-1.0) |
topP | number | 0.95 | Nucleus sampling threshold |
topK | number | 40 | Top-k sampling parameter |
maxOutputTokens | number | 8192 | Maximum response length |
candidateCount | number | 1 | Number of response candidates |
Tool Calling
Gemini uses a different format for function declarations:Function Responses
Safety Settings
Gemini includes safety filters. If your prompt is blocked:Finish Reasons
Gemini responses include finish reasons:| Reason | Meaning |
|---|---|
STOP | Natural completion |
MAX_TOKENS | Reached token limit |
SAFETY | Blocked by safety filters |
RECITATION | Blocked due to recitation |
TOOL_CODE | Tool use requested |
Vertex AI
For Google Cloud Vertex AI, use thevertex provider:
Authentication
Vertex AI uses Google Cloud authentication:Advanced Features
ReAct Prompting
Enable ReAct-style prompting for better tool use:Stop Sequences
Custom stop sequences for ReAct mode:Multimodal Input
Gemini supports image inputs:Troubleshooting
API Key Not Found
API Key Not Found
Prompt Blocked by Safety Filters
Prompt Blocked by Safety Filters
If your prompt is blocked:
- Review the
blockReasonin the error - Adjust your prompt to be less sensitive
- Configure safety settings (use with caution)
Vertex AI Authentication Failed
Vertex AI Authentication Failed
For Vertex AI:
- Ensure gcloud is authenticated:
gcloud auth list - Check project ID in endpoint URL
- Verify service account permissions
Rate Limit Errors
Rate Limit Errors
Gemini has generous quotas, but if you hit limits:
- Check quota at Google Cloud Console
- Request quota increase
- Implement request throttling
Best Practices
Model Selection
- Gemini 2.0 Flash: Latest, best performance
- Gemini 1.5 Pro: Maximum capability
- Gemini 1.5 Flash: Fastest responses
Context Window
- 1M+ token context is unique to Gemini
- Great for large codebases
- Entire files can fit in context
Temperature Settings
0.0-0.3: Focused, consistent0.4-0.7: Balanced (recommended)0.8-1.0: Creative, varied
Safety
- Default filters are moderate
- Adjust only when necessary
- Review blocked content carefully