Short answer
You can no longer call the Gemini API model gemini-3-pro-preview: Google says it shut down on March 9, 2026. Google lists Gemini 3.1 Pro Preview separately, with the model ID gemini-3.1-pro-preview. It remains a Preview model. This tutorial uses the Gemini Developer API; it does not explain how to access a consumer-facing Gemini app. (Gemini 3 Pro Preview status · Gemini 3.1 Pro Preview model page)
Before you start
You’ll need Python 3.11 or later, Google’s google-genai package, and a Gemini API key associated with a Google Cloud project. The SDK project metadata specifies Python >=3.11. Check your installed version with:
python --version
If your interpreter is older than Python 3.11, install a supported Python version before continuing. (Google GenAI Python SDK project metadata)
Open Google AI Studio to create or manage an API key. Google’s Gemini 3.1 Pro Preview model page lists the model as Preview; the material cited here does not establish whether this specific model requires paid-tier access. Check its availability and billing status for your project in AI Studio before relying on it.
If AI Studio indicates that you need the paid tier, Google’s billing guide says to open Set up billing on the API keys or Projects page, link a Cloud Billing account, and follow the billing prompts. Under the documented prepaid flow, the minimum initial credit purchase is $5 USD or the equivalent in another currency. That is a billing setup instruction, not confirmation that Gemini 3.1 Pro Preview itself requires paid access. (Gemini API billing guide)
Make a first Gemini 3.1 Pro Preview API call
1. Create a key and keep it private
In AI Studio, create a Gemini API key for a project or select an existing project and key. Set the key as an environment variable rather than putting it directly in your script. Google’s Gemini API key guide describes using GEMINI_API_KEY or GOOGLE_API_KEY; if both are set, GOOGLE_API_KEY takes precedence. (API key guide)
macOS or Linux:
export GEMINI_API_KEY="your_api_key_here"
PowerShell:
$env:GEMINI_API_KEY="your_api_key_here"
2. Install the Python SDK
python -m pip install -U google-genai
3. Send a request
Save this as try_gemini.py:
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.1-pro-preview",
contents="Explain what an API is to a beginner in three bullet points.",
)
print(response.text)
Run it with:
python try_gemini.py
This uses Google’s documented Python generate_content request pattern and text response accessor, together with the model ID listed on the Gemini 3.1 Pro Preview page. Google’s Gemini API documentation says Gemini models support content generation. The expected success check is that the script prints the response text; this is a documented example, not a reported test run. (Text-generation example · Supported models and request format · Gemini 3.1 Pro Preview model page)
What Gemini 3.1 Pro Preview supports
Google lists text, image, video, audio, and PDF inputs, with text output. Its model page also marks function calling and structured outputs as supported. For example, you could use it to summarize a PDF or extract fields into a structured format. Check the model documentation for feature-specific limits, and validate model output before passing it to other systems. (Gemini 3.1 Pro Preview model page)
If you meant the original Gemini 3 Pro Preview
The original API model ID, gemini-3-pro-preview, is shut down. Google’s deprecation list names gemini-3.1-pro-preview as its recommended replacement; the shut-down model’s warning also points readers to Gemini 4 Argon. These are separate model IDs, so check the current documentation for the model and API channel you intend to use rather than treating a model-name change as a verified drop-in migration. (Deprecation list · Original Gemini 3 Pro Preview notice)
Production checks
- Confirm the model and channel. The old
gemini-3-pro-previewAPI model is shut down. Check thatgemini-3.1-pro-previewis available to your project before using it. - Protect credentials. Keep API keys out of source control and browser-side code; use a secret store in deployed applications.
- Test realistic requests and failures. Validate representative outputs and decide how your application handles invalid inputs and API errors.
- Review billing and limits. Check your project’s current billing status, pricing, and active rate limits in AI Studio before estimating production usage. (Billing guide · Rate limits)
Bottom line: The original Gemini 3 Pro Preview API model is shut down. For a Gemini 3 Pro-series API call, use gemini-3.1-pro-preview only after confirming it is available to your project and reviewing its current billing and Preview terms.
Sources
Gemini 3 Pro preview | Gemini API | Google AI for Developers
Gemini 3.1 Pro preview | Gemini API | Google AI for Developers
Text generation - generateContent API | Google AI for Developers
Generate content with the Gemini API | Google Cloud Documentation
Using Gemini API keys | Google AI for Developers
Billing | Gemini API | Google AI for Developers
Gemini deprecations | Gemini API | Google AI for Developers
