Google Gemini api
★★★★★ 4.5 CE

Google Gemini API: Access, Rate Limits & SDKs 2026

The Gemini API uses a single free API key in an x-goog-api-key header, with Python, JavaScript and REST. The Interactions API is the GA surface to build on.

Google Gemini API verdict

Verified today·4 sources checked

The Google Gemini API authenticates with a single free API key, passed in an x-goog-api-key header, and is reachable from Python, JavaScript and REST.

The primary surface is the now-GA Interactions API, with the older generateContent surface still available. It covers text generation and native multimodal input across image, audio, video and documents.

How to build on it

Gemini's API is the easiest of the big three to start: one free API key, an x-goog-api-key header, and SDKs for Python and JavaScript plus REST. The Interactions API is the surface to build on, with stateful multi-turn through previous_interaction_id, built-in Google Search grounding, managed agents and background execution. Server-side state and tool orchestration come for free. Budget around RPM, TPM and RPD per project. Limits rise automatically with cumulative Google Cloud spend, from Free to Tier 3, but preview models are throttled harder, and priority and batch traffic have separate limits. Use the Batch API and the 90% cache discount for volume, and shrink context or outputs to absorb 429s.

Honest limits
  • Rate limits are hit across whichever of RPM, TPM and RPD comes first. 21 requests in a minute trip a 20-RPM limit even with tokens to spare.
  • Preview and experimental models, including Gemini 3.1 Pro Preview, carry stricter rate limits than stable releases.
  • Spend-based limits return a 429 RESOURCE_EXHAUSTED independent of RPM and TPM, gated by billing history and tier.
  • Priority inference runs at 0.3x the standard rate limit per model and tier, and the Batch API has its own separate limits.
Auth
x-goog-api-key (free key)
Primary surface
Interactions API (GA)
SDKs
Python, JS, REST
Usage tiers
Free to Tier 3
Cache discount
90% ($0.20/1M)
View sources

Build with the Google Gemini API

Your first Google Gemini API request

POST :generateContentbash
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-pro:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{ "parts": [{ "text": "Hello, Gemini" }] }]
  }'

How to authenticate with the Google Gemini API

AspectDetailNotes
Get a keyFree API key from Google AI Studioexport GEMINI_API_KEY=...
Authx-goog-api-key header with the API keySet as an environment variable
Primary surfaceInteractions API (generally available)Recommended for newest features and models
Legacy surfacegenerateContent API still availableToggle between API versions in docs
Access methodsPython SDK, JavaScript SDK, RESTSame Interactions API across all three
ScopeRate limits and quotas per projectNot per API key
Response shapeInteraction resource: id, status, usage, steps[]object: interaction

Google Gemini core endpoints

CapabilityHowPurpose
Generate:generateContent / interactionsText generation from text or multimodal input
StreamingServer-sent events (SSE)step.delta events stream text as generated
Multi-turnprevious_interaction_id (stateful) or client historyServer-managed or client-managed conversation
Multimodal inimage / audio / video / documentsNative understanding of media alongside text
Structured outputPydantic (Python) / Zod (JavaScript)JSON conforming to a schema you define
Built-in toolsGoogle Search, code execution, URL context, Maps, computer useGrounding and actions with automatic citations
Managed agentsenvironment="remote"Agents in a remote sandbox with code execution + file management
Backgroundbackground=True, poll interactions.get()Long tasks run asynchronously

Google Gemini rate limits and tiers

LimitDetailNotes
DimensionsRPM, TPM (input), RPDHit on whichever comes first
Scope / resetPer project; RPD resets midnight PacificNot per API key
Usage tiersFree, Tier 1-3; auto-upgraded by spendTier 1 link billing, Tier 3 $1,000 paid
Spend-based limits429 RESOURCE_EXHAUSTED on spend capCaps by billing history / tier
Preview modelsStricter limits for preview/experimentalGemini 3.1 Pro Preview is one
Priority inference0.3x the standard limit per model and tierCounts toward overall interactive limits
Batch API100 concurrent, 2GB input file, 20GB storageSeparate from non-batch limits
Tier promotionFree to Tier 1 instant; later within 10 minSet up billing first in AI Studio

Google Gemini SDKs, error handling and developer fit

AspectDetailNotes
Official SDKsPython, JavaScript, RESTSame Interactions API surface
Convenience accessorsinteraction.output_text, interaction.output_imageSkip parsing the steps array
Function callingstatus requires_action + function_call stepRun locally, submit result for turn 2
Generation outputsText + image (Nano Banana), speech (TTS), music (Lyria 3)Multimodal generation
Rate-limit errors429 RESOURCE_EXHAUSTED; wait, retry, shrink requestsSmaller context windows or shorter outputs
Cost leversBatch API (separate limits); 90% cache discount; concise outputsBatch off the synchronous limits
API pricing (Gemini 3.1 Pro)$2/1M in, $12/1M out, cache hit $0.20/1MIndependent cross-reference

Google Gemini API FAQ

How do I authenticate with the Gemini API?

Create a free API key in Google AI Studio, set it as the GEMINI_API_KEY environment variable, and send it in an x-goog-api-key header. The SDKs read the env var automatically. Rate limits and quotas apply per project, not per API key, so multiple keys in one project share the same limits.

What can the Gemini API do beyond text generation?

The Interactions API, now GA, covers native multimodal understanding across image, audio, video and documents. It generates images through Nano Banana, speech through TTS and music through Lyria 3. Structured output uses Pydantic or Zod, and built-in tools include Google Search grounding, code execution, URL context, Google Maps and computer use. It also supports function calling, managed agents in a remote sandbox, and background execution for long tasks.

What are the Gemini API rate limits?

Limits apply per project across requests per minute, input tokens per minute and requests per day, enforced on whichever is reached first, and RPD resets at midnight Pacific. Usage tiers raise the ceiling automatically by cumulative Google Cloud spend, from Free through Tier 3. Preview models carry stricter limits, priority inference runs at 0.3x the standard limit, and the Batch API has its own limits, at 100 concurrent and a 2GB input file.

Which SDKs does the Gemini API offer?

Official Python and JavaScript SDKs, plus a REST interface, all on the same Interactions API. The SDKs expose the full Interaction response and convenience accessors like interaction.output_text and interaction.output_image, so you do not have to parse the steps array. Multi-turn conversations can be stateful, server-managed through previous_interaction_id, or stateless, with client-managed history.

How do I handle Gemini API rate-limit errors and control cost?

A 429 RESOURCE_EXHAUSTED means a request or spend limit was hit. Wait and retry, or reduce expensive requests by using smaller context windows or shorter outputs. For volume, use the Batch API, which is separate from synchronous limits, and rely on the 90% cache-hit discount, where cached input runs at $0.20 per 1M on Gemini 3.1 Pro. Tier upgrades that raise limits happen automatically as cumulative spend grows.

Sources & verification

Verified by ComparEdgeMethod: Vendor docs, official pages, and selected independent sources
SourceWhat was checkedLast checked
Google OfficialOfficial product pageJuly 10, 2026
Artificial AnalysisIndependent referenceJuly 10, 2026
Google AIGemini API Get StartedJuly 10, 2026
Google AIGemini API Rate LimitsJuly 10, 2026

Every fact on this Google Gemini page is tied to a named source and a verification date. Freshness-sensitive figures trace to the sources above; verify against the vendor before relying on them.