Access note (as of November 9, 2026): Google says access to Gemini 2.5 models is limited to users who have actively used them in the past. The models are not deprecated and, according to Google, will continue to be served through the Gemini API until further notice. Google’s notice does not specify whether eligibility is tied to a particular project or requires prior use of Flash specifically. A new project alone therefore does not establish that you are ineligible; use the request below to check access. (Google’s Gemini 2.5 Flash model page)
The standard model ID is gemini-2.5-flash. Do not substitute gemini-live-2.5-flash or gemini-2.5-flash-image; those refer to different models. (Google’s Gemini 2.5 Flash model page)
1. Create a Gemini API key
- Open the Google AI Studio API keys page and sign in. Google says a first-time user gets a default Google Cloud project and API key after accepting the terms; copy the key from the API keys page.
- To make another key, choose Create API key in AI Studio and follow the prompts to add a key-project pair. If you want to use an existing Google Cloud project that is not shown, import it from Dashboard → Projects → Import projects, then create a key for it. (Google’s API-key guide; AI Studio getting-started guide)
- Store the key as a secret on the server or in your development environment—not in browser JavaScript, a public repository, or application logs. Google recommends environment variables rather than putting the key directly in code. (Google’s API-key guide)
Key note: Since May 28, 2026, new keys created in AI Studio are authorization keys bound to a Google Cloud service account and restricted to the Gemini API by default. Google says unrestricted standard API keys are rejected; standard keys with explicit restrictions continue to work. If an older key fails, review its restrictions in AI Studio or create a new key. (Google’s API-key guide)
For a local Bash or macOS/Linux terminal, set the key in your environment before making the request:
export GEMINI_API_KEY="your-api-key"
For a deployed application, use your platform’s protected environment-variable settings or a secret manager. Do not commit a file containing the real key.
2. Make a direct Gemini 2.5 Flash API request
This REST example sends a short text prompt to Google’s generateContent method. The model ID is gemini-2.5-flash; Google’s text-generation documentation shows the generateContent URL pattern and x-goog-api-key header. (Google’s Gemini 2.5 Flash model page; Google’s text-generation guide)
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \\
-H "x-goog-api-key: ${GEMINI_API_KEY}" \\
-H "Content-Type: application/json" \\
-X POST \\
-d '{
"contents": [
{
"parts": [
{ "text": "Reply with one short sentence explaining what an API does." }
]
}
]
}'
For this text-only request, look for generated text in candidates[0].content.parts[*].text. Google’s REST example reads the first candidate’s first text part. If the response has no candidate text, do not treat it as a successful text-generation result: inspect the complete response and any HTTP error details. (Google’s text-generation guide)
This example follows Google’s documented REST format; it is not a claim that the request was run or that every account can access this model. If you get a model-access error, check the eligibility note above.
3. Check access and troubleshoot errors
- Invalid-key or authentication error: Confirm that the environment variable is set, contains the complete key, and belongs to the intended Google Cloud project. If you are using an older standard key, check that it is not unrestricted. (Google’s API-key guide)
- Model unavailable or access denied: Check the exact model ID and whether you have actively used a Gemini 2.5 model in the past. Google’s notice describes the condition at the 2.5-model-family level; it does not specify whether Flash-specific prior use is required or how eligibility maps to accounts and projects. A new project alone does not settle eligibility. (Google’s Gemini 2.5 Flash model page)
- Client error (400, 402, or 403): Do not retry without addressing the cause. Google’s troubleshooting guide says these errors can indicate invalid API keys, depleted prepay credits, or bad syntax. Check the returned error details, key, billing or credit status, and request syntax. (Google’s troubleshooting guide)
- 429
RESOURCE_EXHAUSTEDor another error that indicates a retry: Check your project’s quota and billing status. Google recommends exponential backoff for retryable errors; do not repeatedly resend a failing request without a delay. (Google’s troubleshooting guide)
4. Should you use Gemini 2.5 Flash for a new integration?
Google says access to Gemini 2.5 models is limited to users who have actively used them in the past, while recommending newer models for new projects. If you cannot access gemini-2.5-flash, check Google’s current model catalog for an available replacement rather than changing the key format or trying a Live or Image model ID. (Google’s Gemini 2.5 Flash model page)
Google’s free tier covers only certain models and is subject to model rate limits. Check the current pricing, billing, and quota details for the model and project you intend to use before relying on free access or estimating production costs. (Google’s billing guide)
Sources
Text generation - generateContent API | Google AI for Developers
Troubleshooting guide | Gemini API | Google AI for Developers
Gemini 2.5 Flash | Gemini API | Google AI for Developers
Using Gemini API keys | Google AI for Developers
