Try Bifrost Enterprise free for 14 days.
Request access

How to Get a Google Gemini API Key

Create a free Google account, generate your Gemini API key at Google AI Studio, set up billing for production, then integrate with Bifrost for advanced multi-model routing and cost governance. Complete in minutes.

Free API keyGoogle AI StudioBearer authMultimodal modelsBifrost gateway

Google Gemini provider summary

Bifrost supports Gemini models through HTTP APIs with comprehensive multimodal support for text, images, audio, and video inputs. Access the latest Google AI models with free API keys.

PropertyDetails
DescriptionGoogle Gemini provides multimodal AI capabilities including text, vision, audio, and video processing with advanced reasoning and coding support.
Provider route on Bifrostgemini/<model>
Provider docGoogle AI Documentation
API endpoint for providerhttps://generativelanguage.googleapis.com/v1beta
Supported endpoints/v1/models, /v1/chat/completions, /v1/responses, /v1/images/generations, /v1/images/edits, /v1/embeddings, /v1/audio/speech, /v1/audio/transcriptions, /v1/files, /v1/batches, /v1/count-tokens, /v1/videos

Official Google Gemini Resources

Use these Google-hosted links for console access, API documentation, and authentication details.

Prerequisites

Before you begin, you will need:

Google accountEmail addressPayment method for production (optional for free tier)
i
Free tier available: Google Gemini offers a free tier with daily rate limits for testing and development. Enable billing in Google Cloud Console for production use.

[ QUICK START ]

How Do You Get a Google Gemini API Key in 5 Steps?

1

Create or sign in to a Google account

Visit Google AI Studio to get started.

Go to aistudio.google.com and sign in with your Google account. You should land on the Google AI Studio dashboard.

Google AI Studio dashboard with Explore Google models and Get API key in the sidebar
2

Click 'Get API Key'

In Google AI Studio, click the "Get API Key" button to access the API key creation interface.

3

Generate and copy your API key

Your key is displayed once. Copy it immediately and store it securely.

Click "Create API key", name your key, choose a Google Cloud project (or use the default), then click "Create key". Copy the key immediately, it is shown only once.

Google AI Studio Create a new key dialog with name, project selection, and Create key button
Terminal (macOS/Linux)
export GEMINI_API_KEY="AIza..."
!
Treat keys like passwords: Never expose API keys in client-side code or commit them to version control. Store in .env files and add to .gitignore.
4

Enable billing for production

Add a payment method when ready for higher limits.

Google Gemini offers a free tier with daily rate limits. For production use or higher volume, enable billing in Google Cloud Console.

5

Make your first generateContent call

Authenticate with Bearer tokens per Gemini's HTTP API.

Use Gemini's REST API with x-goog-api-key header authentication:

Terminal
$ curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -d '{
    "contents": [{"role":"user","parts":[{"text":"Hello!"}]}]
  }'

[ MODELS ]

Available Google Gemini Models

ModelAPI IDBest for
Gemini 3.1 Pro Previewgemini-3.1-pro-previewAdvanced reasoning, agents, and complex coding.
Gemini 3 Flash Previewgemini-3-flash-previewFrontier performance at lower cost.
Gemini 3.1 Flash-Litegemini-3.1-flash-liteStable, budget-friendly multimodal workloads.
Gemini 2.5 Progemini-2.5-proDeep reasoning and advanced coding.
Gemini 2.5 Flashgemini-2.5-flashBest price-performance for high-volume tasks.
Gemini 2.5 Flash-Litegemini-2.5-flash-liteFastest, most budget-friendly 2.5 model.
Gemini 2.5 Flash Image (Nano Banana)gemini-2.5-flash-imageNative image generation and editing.
Gemini 3 Pro Image Preview (Nano Banana Pro)gemini-3-pro-image-previewStudio-quality image generation.
Gemini 3.1 Flash Image Previewgemini-3.1-flash-image-previewHigh-efficiency visual creation.
Veo 3.1 Previewveo-3.1-generate-previewCinematic video with synchronized audio.
Veo 3.1 Lite Previewveo-3.1-lite-generate-previewCost-efficient video generation.
Imagen 4imagen-4.0-generate-001Text-to-image up to 2K resolution.
Gemini Embedding 2gemini-embedding-2Multimodal embeddings for RAG and search.
Gemini Embeddinggemini-embedding-001Text embeddings for semantic search.
Gemini 2.5 Flash Live Previewgemini-2.5-flash-native-audio-preview-12-2025Real-time voice and video agents.
Gemini 2.5 Flash TTS Previewgemini-2.5-flash-preview-ttsControllable text-to-speech.
Lyria 3 Pro Previewlyria-3-pro-previewFull-length music generation.
Computer Use Previewgemini-2.5-computer-use-preview-10-2025UI automation and browser agents.
Deep Research Previewdeep-research-preview-04-2026Multi-step research with citations.

Models and availability change over time. See the Google's Gemini models documentation for the latest list and pricing.

[ TROUBLESHOOTING ]

Troubleshooting Common Gemini API Errors

ErrorLikely CauseWhat to Do
401 UnauthorizedInvalid or missing API key.Verify your API key is correct and properly formatted. Generate a new key if needed.
400 Invalid RequestInvalid request format or unsupported model.Check request format against Gemini API reference. Verify model ID is current.
429 Rate LimitedRate limit exceeded for your plan or tier.Enable billing for higher limits. Implement exponential backoff. Use Bifrost for load distribution.
500 Server ErrorTemporary Google service unavailability.Retry after a delay. Check Google Cloud status page. Configure failover with Bifrost.

[ PRODUCTION-READY ]

Use Your Gemini Key with Bifrost

Bifrost is a drop-in replacement for Gemini SDKs. Update your base URL and keep your client code. Bifrost handles cost tracking, virtual keys, budgets, and intelligent failover.

Step 1: Start Bifrost and register Gemini

Run the Bifrost gateway and configure your Gemini credentials in the Web UI.

Terminal
$ npx -y @maximhq/bifrost
OUTPUT
 Bifrost started
├─ HTTP server listening on http://localhost:8080
├─ Web UI available at   http://localhost:8080
└─ Configure providers and virtual keys in the dashboard
Add the Gemini integration in the Web UI. For details, read Gemini on Bifrost.

Step 2: Point your Gemini SDK at Bifrost

Update your SDK to route through Bifrost's unified gateway.

example.py
import anthropic

# BEFORE
# client = anthropic.Anthropic(api_key="your-gemini-key")

# AFTER: route via Bifrost + virtual key
client = anthropic.Anthropic(
    api_key="sk-bf-your-virtual-key",
    base_url="http://localhost:8080/anthropic"
)

response = client.messages.create(
    model="gemini-2.0-flash",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello from Bifrost!"}]
)

print(response.content[0].text)
Virtual keys can be sent as x-bf-vk or Authorization: Bearer sk-bf-* per the Bifrost documentation.

Ready to Route Gemini Through Bifrost?

Bifrost is open source and production-ready. Get started in minutes with cost tracking, virtual keys, and failover built in.

[ BIFROST FEATURES ]

Open Source & Enterprise

Everything you need to run AI in production, from free open source to enterprise-grade features.

01 Governance

SAML support for SSO and Role-based access control and policy enforcement for team collaboration.

02 Adaptive Load Balancing

Automatically optimizes traffic distribution across provider keys and models based on real-time performance metrics.

03 Cluster Mode

High availability deployment with automatic failover and load balancing. Peer-to-peer clustering where every instance is equal.

04 Alerts

Real-time notifications for budget limits, failures, and performance issues on Email, Slack, PagerDuty, Teams, Webhook and more.

05 Log Exports

Export and analyze request logs, traces, and telemetry data from Bifrost with enterprise-grade data export capabilities for compliance, monitoring, and analytics.

06 Audit Logs

Comprehensive logging and audit trails for compliance and debugging.

07 Vault Support

Secure API key management with HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, and Azure Key Vault integration.

08 VPC Deployment

Deploy Bifrost within your private cloud infrastructure with VPC isolation, custom networking, and enhanced security controls.

09 Guardrails

Automatically detect and block unsafe model outputs with real-time policy enforcement and content moderation across all agents.

[ SHIP RELIABLE AI ]

Try Bifrost Enterprise with a 14-day Free Trial

[quick setup]

Drop-in replacement for any AI SDK

Change just one line of code. Works with OpenAI, Anthropic, Vercel AI SDK, LangChain, and more.

1import os
2from anthropic import Anthropic
3
4anthropic = Anthropic(
5 api_key=os.environ.get("ANTHROPIC_API_KEY"),
6 base_url="https://<bifrost_url>/anthropic",
7)
8
9message = anthropic.messages.create(
10 model="claude-3-5-sonnet-20241022",
11 max_tokens=1024,
12 messages=[
13 {"role": "user", "content": "Hello, Claude"}
14 ]
15)
Drop in once, run everywhere.

[ FAQ ]

Frequently Asked Questions

No. The Gemini API can be accessed via simple API key authentication without a Google Cloud project. However, for production workloads, enterprise features, and advanced monitoring, consider using Google Cloud Console with billing.

Google offers gemini-2.0-flash, gemini-1.5-pro, gemini-1.5-flash, and other models. Visit the Gemini API documentation to see the latest available models and their capabilities.

Yes, Gemini API has a free tier with daily rate limits. For production use or higher volume, enable billing in Google Cloud Console or sign up for a paid plan.

Implement exponential backoff in your client. Upgrade to a paid plan for higher limits. Use Bifrost to distribute requests across multiple providers for resilience.

Gemini has its own API format. However, Bifrost provides OpenAI-compatible routing for Gemini, allowing you to use OpenAI SDKs seamlessly.

Bifrost provides cost tracking, virtual keys, budget governance, and automatic failover across multiple providers including Gemini, reducing infrastructure complexity.