The short answer
gemini-2.5-pro is a legacy API choice for existing users, not the model to select for a new project. Google’s model guidance limits Gemini 2.5 access to users who actively used it previously. Google AI Studio’s model notice says Gemini 2.5 Pro API access is limited to existing users until December 1, 2026; from that date, requests sent to gemini-2.5-pro will automatically route to gemini-3.8-flash and be billed at that model’s rates. New projects should choose a currently supported model directly rather than depend on automatic routing. (Google AI Studio model notice; Gemini API model guide)
Google Cloud lists a separate Gemini 2.5 Pro retirement date of October 20, 2026. That date has passed; check Google Cloud’s current model catalog before building a Vertex AI integration. (Google Cloud model page)
Make a Gemini API request with Python
Use this example only if your project already has access to gemini-2.5-pro. Google recommends its maintained Google GenAI SDK. The older google-generativeai package found in some tutorials is not actively maintained. (Google GenAI SDK documentation)
Requirements: Python 3.11 or later, a Gemini API key, and existing access to the model. Google’s current SDK package metadata specifies Python >=3.11. You can create or manage a Gemini API key in Google AI Studio. (SDK package metadata; API key documentation)
-
Install the SDK:
python -m pip install -U google-genai -
Set the key as an environment variable. The SDK’s client can read
GEMINI_API_KEYwhen you creategenai.Client()without passing a key. Keep credentials server-side; don’t put them in browser code or commit them to a repository. (API key documentation; SDK migration guide)macOS or Linux:
export GEMINI_API_KEY="YOUR_API_KEY"Windows PowerShell:
$env:GEMINI_API_KEY="YOUR_API_KEY" -
Save this as
gemini_test.pyand runpython gemini_test.py:from google import genai client = genai.Client() response = client.models.generate_content( model="gemini-2.5-pro", contents="Explain API rate limits in one short paragraph.", ) print(response.text)
This follows Google’s documented client.models.generate_content(...) and response.text pattern. A valid key alone may not provide access: Google restricts Gemini 2.5 API access to existing users who actively used the models. If this is a new project, use a model currently available to it—Google’s current model guidance points new projects to gemini-3.8-flash or gemini-3.5-flash-lite. (Text-generation guide; Gemini API model guide)
Cost and production checks
- Pricing: Check Google’s Gemini API pricing page for the applicable input and output rates, prompt-length tier, and effective date before budgeting. This article does not provide a numeric Gemini 2.5 Pro rate or worked cost estimate. Don’t use third-party gateway prices as Google rates.
- Thinking tokens: Google says billed usage includes thinking tokens. Include them in cost planning and confirm their classification in the pricing details. (Google pricing page)
- Billing setup: To move a project from the Free Tier to a Paid Tier, Google says to link a billing account and prepay at least $5 (or the equivalent in another currency). The free tier covers only certain models and their stated limits, so confirm the selected model and project’s access before relying on it for production. (Gemini API billing guide)
- After December 1, 2026: Google says requests using
gemini-2.5-prowill route to Gemini 3.8 Flash and be billed at Gemini 3.8 Flash rates. Check the live pricing table for the replacement’s rates and applicable conditions before budgeting for post-routing traffic. (Google AI Studio model notice; Google pricing table) - Quotas: Gemini API rate limits are project-scoped, not key-scoped, and may be measured by requests per minute, input tokens per minute, and requests per day. Check the limits shown for your project in AI Studio. (Gemini API rate limits)
- Keys and migration: Google documents a move toward authorization keys: new AI Studio keys are authorization keys by default, and unrestricted standard keys are rejected. Before changing models or credentials, review Google’s current migration notes and test the replacement in your own project. Google’s model notice lists changes for the Gemini 3.8 Flash migration, including function calling, thought-signature validation, thinking settings, sampling parameters, and prefilled model turns. (API key documentation; Google AI Studio model notice)
Quick checklist
- New project: Choose a model currently available to the project; don’t build around
gemini-2.5-proor its future automatic routing. - Existing Gemini API project: Confirm that the project retains access, use the current SDK and key type, and plan for the announced December 1, 2026 routing change.
- Budget: Use Google’s current pricing table for the model, prompt-length tier, and effective date. Include thinking tokens in billed-usage planning.
- Vertex AI: Select a currently available Google Cloud model; the listed Gemini 2.5 Pro retirement date has passed.
Official documentation
- Gemini 2.5 Pro API model guide
- Google AI Studio model notice and migration details
- Google GenAI SDK libraries
- Text generation
- API key setup and security
- Gemini API pricing
- Billing and tiers
- Rate limits
- Gemini 2.5 Pro on Google Cloud
Sources
Gemini 2.5 Pro — Google AI Studio model notice
Migrate to the Google GenAI SDK
