Gemini API & Google AI Studio
Getting Started — Google AI Studio (Free)
Google AI Studio is the fastest way to start building with Gemini — no credit card required.
- Go to aistudio.google.com
- Sign in with your Google account
- Start prompting — free tier includes Gemini 3.5 Pro access
# Python SDKpip install google-generativeai
import google.generativeai as genaigenai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-3.5-pro")response = model.generate_content("Explain quantum computing in one paragraph")print(response.text)Gemini API
Text Generation
model = genai.GenerativeModel("gemini-3.5-flash")response = model.generate_content("Write a Python function to check if a number is prime")print(response.text)Multimodal Input
import PIL.Image
# Text + imageimage = PIL.Image.open("photo.jpg")model = genai.GenerativeModel("gemini-3.5-pro")response = model.generate_content(["Describe this image in detail:", image])print(response.text)Audio Input
# Audio file analysisaudio_file = genai.upload_file("meeting.mp3")model = genai.GenerativeModel("gemini-3.5-pro")response = model.generate_content(["Summarize this meeting:", audio_file])print(response.text)Video Input
# Video analysisvideo_file = genai.upload_file("presentation.mp4")model = genai.GenerativeModel("gemini-3.5-pro")response = model.generate_content([ "Analyze this presentation and create a summary:", video_file])print(response.text)Streaming
model = genai.GenerativeModel("gemini-3.5-flash")response = model.generate_content("Write a haiku about programming", stream=True)for chunk in response: print(chunk.text, end="", flush=True)Function Calling
model = genai.GenerativeModel( "gemini-3.5-pro", tools=[{ "function_declarations": [{ "name": "get_weather", "description": "Get current weather for a location", "parameters": { "type": "object", "properties": { "location": {"type": "string", "description": "City and state"} }, "required": ["location"] } }] }])Structured Output
model = genai.GenerativeModel("gemini-3.5-pro")response = model.generate_content( "Extract people from: Alice met Bob at 3 PM", generation_config={"response_mime_type": "application/json"})Gemini Live API — Real-Time Voice
Bidirectional streaming for voice agents and real-time audio:
# Client-side WebSocket connection for live voice# Available via AI Studio or Vertex AI# Supports: voice input → model processing → voice output# Use cases: voice agents, live translation, audio analysisVertex AI — Enterprise
from google.cloud import aiplatformfrom vertexai.generative_models import GenerativeModel
# Deploy within your GCP projectmodel = GenerativeModel("gemini-3.5-pro")# Full GCP integration: IAM, VPC, Cloud Logging, audit trails| Feature | AI Studio | Vertex AI |
|---|---|---|
| Cost | Free tier, then pay-per-use | Pay-per-use, committed use discounts |
| Setup | No setup required | GCP project + APIs |
| Security | Google account | IAM, VPC, Private Link, Cloud KMS |
| Compliance | Standard | SOC 2, HIPAA, FedRAMP |
| Context | 1M tokens | 1M tokens |
| SLAs | None | Enterprise SLAs |
Embeddings
model = "models/text-embedding-004"result = genai.embed_content( model=model, content="The quick brown fox jumps over the lazy dog")vector = result['embedding']
# Dimensions: 768 (text-embedding-004)# Use for: semantic search, clustering, recommendationsPricing
Gemini API pricing is tiered. Check ai.google.dev/pricing for latest:
| Model Tier | Typical Range | Notes |
|---|---|---|
| Flash tier | 0.15 / 1M input | Fastest, most affordable |
| Pro tier | 2.50 / 1M input | Balanced, production workloads |
| Ultra tier | Premium pricing | Maximum quality |
| Audio/Live | Per-minute + per-token | Real-time streaming |
AI Studio free tier: Generous free quota for experimentation. No credit card needed.
Where Next
- Antigravity & Flow — agentic development platform
- Media & Creative — video, image, music generation
- Enterprise & Deployment — Vertex AI, compliance