Back to Blog
EnglishTutorial

Gemini 2.5 Pro and Gemini 3 Pro API Integration Guide

Complete guide to integrating Google's Gemini 2.5 Pro, Gemini 2.5 Flash, and Gemini 3 Pro models via API. Includes native format and OpenAI-compatible examples.

C
Crazyrouter Team
January 22, 2026 / 1109 views
Share:
Gemini 2.5 Pro and Gemini 3 Pro API Integration Guide

Google's Gemini models offer exceptional multimodal capabilities, advanced reasoning, and competitive pricing. This guide covers how to integrate Gemini 2.5 Pro, Gemini 2.5 Flash, and the latest Gemini 3 Pro through Crazyrouter's API.

Supported Gemini Models#

ModelInput ($/1M)Output ($/1M)Best For
gemini-3-pro-preview$1.25$7.50Latest generation
gemini-3-pro-preview-thinking$1.25$7.50Extended reasoning
gemini-3-pro-image-preview$1.25$7.50Image generation
gemini-3-flash-preview$0.15$0.60Fast responses
gemini-2.5-pro$1.25$10.00Long documents
gemini-2.5-pro-thinking$1.25$10.00Complex reasoning
gemini-2.5-flash$0.30$2.50Production workloads
gemini-2.5-flash-lite$0.10$0.40Cost-effective
gemini-2.5-flash-image$0.30$2.50Image generation

Quick Start with OpenAI-Compatible API#

The easiest way to use Gemini models is through the OpenAI-compatible endpoint:

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://ai.crazyrouter.us/v1",
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

response = client.chat.completions.create(
    model="gemini-2.5-pro",
    messages=[
        {"role": "user", "content": "Explain the theory of relativity in simple terms."}
    ]
)

print(response.choices[0].message.content)

Native Gemini API Format#

For advanced features, use the native Gemini API format:

Text Generation#

bash
curl -X POST "https://ai.crazyrouter.us/v1beta/models/gemini-2.5-pro:generateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "contents": [{
      "parts": [{"text": "Write a poem about artificial intelligence."}]
    }]
  }'

Streaming Text Generation#

bash
curl -X POST "https://ai.crazyrouter.us/v1beta/models/gemini-3-pro-preview:streamGenerateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "contents": [{
      "parts": [{"text": "Explain quantum computing step by step."}]
    }]
  }'

Extended Thinking with Gemini#

Gemini models support extended thinking for complex reasoning:

python
# Gemini 2.5 Pro with thinking
response = client.chat.completions.create(
    model="gemini-2.5-pro-thinking",
    messages=[
        {"role": "user", "content": "Solve this complex math problem step by step: Find all prime numbers p such that p^2 + 2 is also prime."}
    ]
)

# Gemini 3 Pro with thinking
response = client.chat.completions.create(
    model="gemini-3-pro-preview-thinking",
    messages=[
        {"role": "user", "content": "Analyze this algorithm's time complexity."}
    ]
)

Image Generation with Gemini#

Gemini 2.5 Flash Image#

bash
curl -X POST "https://ai.crazyrouter.us/v1beta/models/gemini-2.5-flash-image:generateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "contents": [{
      "parts": [{"text": "Generate an image of a futuristic city at sunset"}]
    }],
    "generationConfig": {
      "responseModalities": ["image", "text"]
    }
  }'

Gemini 3 Pro Image (with aspect ratio control)#

bash
curl -X POST "https://ai.crazyrouter.us/v1beta/models/gemini-3-pro-image-preview:generateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "contents": [{
      "parts": [{"text": "A serene Japanese garden with cherry blossoms"}]
    }],
    "generationConfig": {
      "responseModalities": ["image"],
      "aspectRatio": "16:9"
    }
  }'

Google Search Integration#

Gemini models can access real-time information via Google Search:

bash
curl -X POST "https://ai.crazyrouter.us/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "contents": [{
      "parts": [{"text": "What are the latest developments in AI as of today?"}]
    }],
    "tools": [{
      "googleSearch": {}
    }]
  }'

Flash Lite Models (Cost-Effective)#

For high-volume, cost-sensitive applications:

python
# Standard Flash Lite
response = client.chat.completions.create(
    model="gemini-2.5-flash-lite",
    messages=[{"role": "user", "content": "Summarize this text briefly."}]
)

# Flash Lite with thinking
response = client.chat.completions.create(
    model="gemini-2.5-flash-lite-thinking",
    messages=[{"role": "user", "content": "Solve this logic puzzle."}]
)

Python SDK Example#

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://ai.crazyrouter.us/v1",
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

# Gemini 3 Pro for complex reasoning
response = client.chat.completions.create(
    model="gemini-3-pro-preview",
    messages=[
        {"role": "system", "content": "You are a helpful AI assistant with expertise in science."},
        {"role": "user", "content": "Explain CRISPR gene editing and its potential applications."}
    ],
    temperature=0.7,
    max_tokens=2000
)

print(response.choices[0].message.content)

Pricing Comparison#

ModelInput ($/1M)Output ($/1M)
gemini-3-pro-preview$1.25$7.50
gemini-2.5-pro$1.25$10.00
gemini-2.5-flash$0.30$2.50
gemini-2.5-flash-lite$0.10$0.40
gemini-flash-latest$0.30$2.50

Pricing Disclaimer: The prices shown in this article are for demonstration purposes only and may change at any time. Actual billing will be based on the real-time prices displayed when you make your request.

Best Practices#

  1. Use Flash for production: Gemini 2.5 Flash offers excellent performance at lower cost
  2. Enable thinking for complex tasks: Use thinking-enabled models for math and reasoning
  3. Leverage multimodal capabilities: Gemini excels at image and video understanding
  4. Use streaming for long responses: Better user experience with real-time output

Model Selection Guide#

Use CaseRecommended Model
General chatgemini-2.5-flash
Complex reasoninggemini-2.5-pro-thinking or gemini-3-pro-preview-thinking
Image generationgemini-2.5-flash-image or gemini-3-pro-image-preview
Cost-sensitivegemini-2.5-flash-lite
Latest featuresgemini-3-pro-preview

Getting Started#

  1. Sign up at Crazyrouter
  2. Create an API key in the console
  3. Choose between OpenAI-compatible or native Gemini format
  4. Start building with Gemini models

For questions, contact [email protected]

Implementation Guides

Topics

Related Articles

Sora API: The Complete Guide to Building with OpenAI Video GenerationTutorial

Sora API: The Complete Guide to Building with OpenAI Video Generation

OpenAI's current Sora API is asynchronous and tier-based, not a fire-and-forget video button. The official guide recommends polling every 10 to 20 seconds, and Sora access is not available on the F...

Mar 26
GPT Agent Mode Complete Guide: Autonomous AI Tasks in 2026Tutorial

GPT Agent Mode Complete Guide: Autonomous AI Tasks in 2026

"Learn how GPT Agent Mode works, how to use it via API, and how it compares to standard chat completions for autonomous task execution."

Feb 27
Cheaper AI API in 2026: How to Lower LLM Costs Without Losing QualityTutorial

Cheaper AI API in 2026: How to Lower LLM Costs Without Losing Quality

At 1M GPT-4 tokens per month, official API pricing is $30, while Crazyrouter lists $21 for the same volume (pricing data updated 2026-03-06). That 30% gap looks clear on paper, yet real production...

Mar 18
DeepSeek R2 API Guide: How to Use the Next-Gen Reasoning ModelTutorial

DeepSeek R2 API Guide: How to Use the Next-Gen Reasoning Model

Complete guide to DeepSeek R2, the advanced reasoning model. Learn about its capabilities, API integration, pricing, and how it compares to OpenAI o3 and Claude.

Feb 22
DeepSeek V3.2 API Guide: How to Use China's Top Open-Source ModelTutorial

DeepSeek V3.2 API Guide: How to Use China's Top Open-Source Model

"Complete guide to DeepSeek V3.2 API — setup, code examples, pricing, and how it compares to GPT-4 and Claude for developers building AI applications."

Feb 21
Claude Code Builds a Multi-Model Odds Alert Router: claude-fable-5 vs GPT-5.5 vs QwenTutorial

Claude Code Builds a Multi-Model Odds Alert Router: claude-fable-5 vs GPT-5.5 vs Qwen

The third Claude Code World Cup analytics project: route the same odds alert JSON task across claude-fable-5, GPT-5.5, Qwen Plus, and Gemini to measure valid JSON rate, latency, and fallback behavior through Crazyrouter.

Jun 13