Google AI Studio api
★★★★ 4.3 CE

Google AI Studio API: Access, Rate Limits & SDKs 2026

The Gemini API, reached with a free AI Studio key, exposes the GA Interactions API through the google-genai SDKs and REST, plus a three-line OpenAI-compatible swap.

Google AI Studio API verdict

Verified today·4 sources checked

The Gemini API is reached with a free key from Google AI Studio.

It exposes one rich surface, the now-GA Interactions API, through the google-genai SDKs for Python and JavaScript and REST, plus an OpenAI-compatible endpoint for a three-line migration. The Interactions API covers text generation, SSE streaming, stateful multi-turn through previous_interaction_id, native multimodal understanding, and media generation across Nano Banana images, Veo video, Gemini TTS and Lyria 3 music.

How to build on it

Build on the Gemini API when you want one surface for text, multimodal understanding, media generation and agents behind a free AI Studio key. For the deepest control, use the native google-genai SDK and the GA Interactions API. That gives stateful previous_interaction_id for chat and agents, background=True for long jobs, built-in Google Search and code-execution tools, and managed agents in a remote sandbox. If you already run OpenAI code, migrate in three lines through the compatibility endpoint and reach chat, images, video, embeddings and batch, using extra_body for Gemini-only features like thinking_config and cached_content. Tune cost and priority with service_tier and reasoning effort. The trade-off is real. The OpenAI-compatible path is beta and lossy on unlisted params, and thinking cannot be disabled on newer models. Some features like Search grounding and batch file transfer need the native client, so reach for the SDK when the compat shim falls short.

Honest limits
  • Two API surfaces coexist: the recommended GA Interactions API and the older generateContent API. A page toggle switches the docs, so match your code to the one you call.
  • The OpenAI-compatible layer is in beta and silently ignores parameters it does not recognize, so verify behaviour rather than assume full OpenAI parity.
  • Thinking is mandatory on Gemini 2.5 Pro and 3 models and cannot be turned off, and reasoning_effort and thinking_level or budget cannot be combined.
Get a key
Free in AI Studio
Native
google-genai SDK + REST
Surface
Interactions API (GA)
OpenAI compat
3-line swap (beta)
Base URL (compat)
generativelanguage.../openai/
View sources

This page covers the Gemini API surface reached with an AI Studio key. The model's benchmark quality and total cost live on their own pages.

Build with the Google AI Studio API

Your first Google AI Studio API request

OpenAI-compatible chat completionpython
from openai import OpenAI

client = OpenAI(
    api_key="GEMINI_API_KEY",
    base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
)
response = client.chat.completions.create(
    model="gemini-3.5-flash",
    messages=[{"role": "user", "content": "Explain how AI works"}],
)
print(response.choices[0].message.content)

How to authenticate with the Google AI Studio API

AspectDetailNotes
Get a keyFree Gemini API key in AI Studioexport GEMINI_API_KEY=...
Native SDKsgoogle-genai (Python) + @google/genai (JS/TS)Full Interactions API; SDKs read GEMINI_API_KEY
RESTReturns the full Interaction resourceMetadata, usage, step-by-step history
OpenAI compatbase_url generativelanguage.../v1beta/openai/3-line change; beta
Auth (compat)api_key = your Gemini API keyFrom Google AI Studio
Modelsgemini-3.5-flash, 3.1 Pro/Flash, Nano Banana, Veo, Lyria 3Multimodal model family
Agent skillnpx skills add google-gemini/gemini-skillsKeep coding agents current

Core endpoints and capabilities

CapabilityHowPurpose
Text generationinteractions.create (model + input)Single-call generation; interaction.output_text convenience
StreamingSSE step.delta eventsStream text chunks as they are generated
Multi-turnprevious_interaction_id / statelessServer-side history + caching, or client-managed
Multimodalmedia alongside text in one requestNative image, audio, video, document understanding
GenerationNano Banana / Veo / TTS / Lyria 3Image, video, speech and music generation
Structured outputPydantic (Python) / Zod (JS)JSON conforming exactly to a schema
Tools + functionsgoogle_search, code, function_callBuilt-in tools + your own functions (requires_action)
Agents + backgroundenvironment="remote", background=TrueRemote-sandbox agents and async long tasks

Tiers, thinking and rules

AspectDetailNotes
Service tiersservice_tier: standard / flex / priorityMatches OpenAI tier name and logic
Thinking controlreasoning_effort -> thinking_level/budgetminimal/low/medium/high mapping
Thinking offOnly on 2.5 models (reasoning_effort=none)Cannot disable on 2.5 Pro or 3 models
Batch APIJSONL, completion_window 24hCreate/monitor/view; upload/download via genai client
Compat statusOpenAI libraries support is in betaUnlisted params silently ignored
Search groundingGemini 3+ only (via compat)Enable with extra_body tools
Embeddingsgemini-embedding-001 / -2-previewText or multimodal embeddings

SDKs, features and developer fit

AspectDetailNotes
SDKsgoogle-genai (Python), @google/genai (JS/TS), OpenAI libsPlus REST
Gemini extrasextra_body: cached_content, thinking_config, aspect_ratioEnable Gemini-only features in OpenAI calls
Thought signaturesOpenAI-compatible thought signatures (Gemini 3)Chat completion APIs
Models APIList models / retrieve a modelDiscover available Gemini models
Image paramsn, size, response_format (+ extra_body aspect_ratio)gemini-3-pro-image-preview, Nano Banana
Video endpointSora-compatible /v1/videos (poll for result)veo-3.1; async long-running op
Agent skillgemini-skills coding-agent skillKeep agents current with Interactions API

Google AI Studio API FAQ

How do I authenticate with the Gemini API from AI Studio?

Create a free Gemini API key in Google AI Studio and set it as the GEMINI_API_KEY environment variable. The native google-genai SDKs for Python and JavaScript and REST read it for the GA Interactions API, and for REST you send it in an x-goog-api-key header. If you use the OpenAI libraries, pass it as api_key and point base_url at https://generativelanguage.googleapis.com/v1beta/openai/.

What is the Interactions API?

It is the now-GA Gemini API surface Google recommends for the latest features and models, available through the Python and JavaScript SDKs and REST. One surface covers text generation, SSE streaming, stateful multi-turn through previous_interaction_id, and native multimodal understanding. It also handles image, video, speech and music generation, structured output, built-in tools, function calling, managed agents with environment='remote', and background execution with background=True.

Is the Gemini API OpenAI-compatible?

Yes, in beta. Reach Gemini models from the OpenAI Python and TypeScript libraries by changing three lines: api_key to your Gemini key, base_url to https://generativelanguage.googleapis.com/v1beta/openai/, and model to a Gemini model. It covers chat, image and video generation through a Sora-compatible /v1/videos endpoint, embeddings and the Batch API. It maps reasoning_effort to Gemini thinking levels and matches service_tier. Unlisted parameters are silently ignored, and some features need the native client.

How do I control thinking and cost on the Gemini API?

Through reasoning effort and service tiers. The compatibility layer maps OpenAI's reasoning_effort, from minimal to high, to Gemini thinking levels or budgets. But reasoning_effort and thinking_level or budget cannot be combined, and thinking cannot be turned off on Gemini 2.5 Pro or 3 models. For cost and latency, the service_tier parameter matches OpenAI's standard, Flex and Priority logic, and the Batch API runs jobs within a 24-hour completion window.

What can the API generate besides text?

Plenty, on the same key. It generates images with the Nano Banana models and video with Veo through the Sora-compatible /v1/videos endpoint, which you poll for the result. It also produces expressive multi-speaker speech with Gemini 3.1 Flash TTS, and music with Lyria 3. It also produces text and multimodal embeddings through gemini-embedding-001 and gemini-embedding-2-preview. Image and video generation accept rich parameters like aspect_ratio, resolution and reference_images through extra_body.

Sources & verification

Verified by ComparEdgeMethod: Vendor docs, official pages, and selected independent sources
SourceWhat was checkedLast checked
Google OfficialOfficial product pageJuly 10, 2026
Google AIAistudioJuly 10, 2026
Google AIGemini API Get StartedJuly 10, 2026
Google AIGemini API OpenaiJuly 10, 2026

Every fact on this Google AI Studio 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.