Google — quickstart
Best long-context-per-dollar in the market and native multimodal that handles video, audio, and images first-class. Pick Google when you're processing big documents, doing video analysis, or need very cheap per-token rates at long context.
gemini-3.1-pro Get a key
- Create an API key at aistudio.google.com
- Set it as `GEMINI_API_KEY` env var
Make a request
Three equivalent ways to call the recommended model. Pick the one that matches your stack.
curl
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-pro:generateContent?key=$GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts": [{"text": "Summarize the last week of AI model releases."}]
}]
}' python
pip install google-genai from google import genai
client = genai.Client()
res = client.models.generate_content(
model="gemini-3.1-pro",
contents="Summarize the last week of AI model releases.",
)
print(res.text) node
npm install @google/genai import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const res = await client.models.generateContent({
model: "gemini-3.1-pro",
contents: "Summarize the last week of AI model releases.",
});
console.log(res.text); Pricing
Gemini 3.1 Flash-Lite is the cost leader in this catalog for 1M-context workloads. Pro tier costs more but handles complex reasoning + agentic loops better.
Alternatives in this lineup
- Gemini 3.1 Flash-Lite — Cheapest 1M-context model in this catalog. Use for high-volume RAG/summarization.
- Gemini 2.5 Pro — Prior-gen flagship. Still solid; cheaper than 3.1.
- Gemini 2.5 Flash — Speed-tier alternative if Flash-Lite is too lean.
Gotchas
- Two SDK lineages. The newer `google-genai` SDK is the supported one; the older `google-generativeai` is deprecated. Check the import path — `from google import genai` (new) vs `import google.generativeai` (old).
- Safety filters can block surprising things. Gemini's content filters are stricter than Anthropic/OpenAI defaults. Persona-driven content (roleplay, character voices) can trigger filters even when benign. Inspect `prompt_feedback` if responses are unexpectedly empty.
- Region matters for rate limits. Free-tier rate limits and feature availability vary by region. Same API key can behave differently from EU vs US.
Official docs: https://ai.google.dev/gemini-api/docs