Installation
The Google client is included in the core Koog library. No additional dependencies required.Quick Start
Authentication
API Key Setup
Get your API key from Google AI Studio.Programmatic Configuration
Available Models
Gemini 2.5 Pro (Most Capable)
Best model for complex tasks requiring advanced reasoning.- 1 million token context window
- Native multimodal (audio, image, video, text)
- Function calling
- Structured outputs (JSON schema)
- Extended thinking
Gemini 2.5 Flash (Recommended)
Best balance of speed and capability.- General-purpose applications
- Real-time interactions
- Cost-effective multimodal tasks
- High-throughput scenarios
Gemini 2.5 Flash Lite
Ultra-fast and cost-efficient.Gemini 2.0 Flash
Fast, efficient model for various tasks.Gemini 2.0 Flash Lite
Smallest, most efficient Gemini 2.0 model.Gemini 3 Pro Preview
Advanced reasoning with thinking capability.Embedding Models
Code Examples
Basic Chat Completion
Function Calling
Vision - Image Analysis
Video Processing
Audio Processing
Structured Output
Extended Thinking (Gemini 3)
Streaming Responses
Long Context Processing
Multiple Choices
Embeddings
Advanced Configuration
Custom Parameters
Tool Choice Control
Model Capabilities
| Model | Context | Output | Vision | Audio | Video | Tools | Thinking |
|---|---|---|---|---|---|---|---|
| Gemini 2.5 Pro | 1M | 65K | ✅ | ✅ | ✅ | ✅ | ❌ |
| Gemini 2.5 Flash | 1M | 65K | ✅ | ✅ | ✅ | ✅ | ❌ |
| Gemini 2.0 Flash | 1M | 8K | ✅ | ✅ | ✅ | ✅ | ❌ |
| Gemini 3 Pro | 1M | 65K | ✅ | ✅ | ✅ | ✅ | ✅ |
Pricing
Pricing varies by model. See Google AI Pricing for current rates. Example costs (per 1M tokens):- Gemini 2.5 Flash: 1.00 (input) / 3.50 (output)
- Gemini 2.5 Pro: 2.50 (input) / 15.00 (output)
- Gemini 2.0 Flash: 0.70 (input) / $0.40 (output)
Best Practices
- Use Gemini 2.5 Flash for most tasks - best balance of speed and capability
- Use Gemini 2.5 Pro for complex reasoning and long documents
- Leverage 1M context for document-heavy applications
- Use multimodal inputs - images, audio, video natively supported
- Enable streaming for long responses
- Batch API calls to stay within rate limits
Limitations
- No moderation API: Implement custom content filtering
- Rate limits vary by region and tier
- Video processing can be slow for long videos
Troubleshooting
Rate Limits
Error Handling
Empty Response Handling
Sometimes Gemini models may return emptyparts fields: