Skip to main content

Overview

Google Gemini is Google’s most capable AI model family, offering multimodal capabilities including text, vision, audio, and code. Access Gemini through Portkey for advanced reasoning, long context understanding, and function calling. Base URL: https://generativelanguage.googleapis.com

Supported Features

  • ✅ Chat Completions (including streaming)
  • ✅ Embeddings
  • ✅ Function Calling
  • ✅ Vision (Image and Video inputs)
  • ✅ Audio Understanding
  • ✅ Long Context (up to 2M tokens)
  • ✅ JSON Mode
  • ✅ System Instructions
  • ❌ Image Generation (use Vertex AI)
  • ❌ Fine-tuning (use Vertex AI)

Quick Start

Chat Completions

Streaming

Available Models

Gemini 2.0 (Latest)

Gemini 1.5

Embeddings

Gemini models excel at:
  • Long context understanding (up to 2M tokens)
  • Multimodal reasoning (text, images, video, audio)
  • Code generation and analysis
  • Multilingual capabilities

Configuration Options

Getting Your API Key

  1. Go to Google AI Studio
  2. Click Get API Key
  3. Create or select a project
  4. Copy your API key

Advanced Features

Vision (Image Understanding)

Base64 images:

Function Calling

System Instructions

Long Context Processing

Gemini excels at processing very long documents:

JSON Mode

Embeddings

Batch embeddings:

Fallback Configuration

Fallback to GPT-4 if Gemini fails:

Load Balancing

Balance between different Gemini models:

Error Handling

Key Features

Context Windows

Safety Settings

Gemini includes built-in safety filters. Responses may be blocked if content violates safety thresholds.

Rate Limits

  • Free tier: 15 requests per minute
  • Pay-as-you-go: Higher limits based on usage

Best Practices

  1. Use Flash for speed - Gemini Flash is significantly faster
  2. Leverage long context - Process entire documents in one request
  3. Multimodal inputs - Combine text, images, and more
  4. System instructions - Guide behavior with clear instructions
  5. Handle safety blocks - Implement fallbacks for blocked responses
  6. Use embeddings - text-embedding-004 for semantic search
  7. Stream responses - Better UX for long generations

Gemini vs Vertex AI

For enterprise deployments, consider using Google Vertex AI which offers additional features like fine-tuning, private endpoints, and SLA.

Pricing

Gemini offers competitive pricing with a free tier:

Gemini Pricing

View detailed pricing for all Gemini models

Google Vertex AI

Enterprise Gemini through GCP

Function Calling

Advanced function calling

Vision Guide

Working with images

Fallbacks

Fallback configurations