Intro to Gemini 3 Flash (Preview)

Source notebook

Repo path: gemini/getting-started/intro_gemini_3_flash.ipynb · Open on GitHub · intermediate

Quickstart for Gemini 3 Flash Preview on Vertex AI with Gen AI SDK features and multimodal/tool examples.

Summary

The notebook teaches how to call Gemini 3 Flash Preview through the Google Gen AI SDK on Vertex AI after installing google-genai, authenticating, and creating an enterprise client. It demonstrates generate_content, streaming, chat, thinking levels, thought summaries, safety settings, structured output, multimodal inputs, tools, function calling, token counting, and async requests. It also shows newer Gemini 3 API controls such as media_resolution, thought signature handling, streaming function call arguments, and multimodal function responses.

Key code patterns

Vertex AI client

from google import genai
from google.genai import types
 
PROJECT_ID = os.environ.get("GOOGLE_CLOUD_PROJECT")
LOCATION = "global"
client = genai.Client(enterprise=True, project=PROJECT_ID, location=LOCATION)
MODEL_ID = "gemini-3-flash-preview"

Creates the Gen AI SDK client used for all Gemini 3 Flash Preview requests on Vertex AI.

Thinking level

response = client.models.generate_content(
    model=MODEL_ID,
    contents="How does AI work?",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(
            thinking_level=types.ThinkingLevel.MINIMAL
        )
    ),
)

Shows how to trade reasoning depth for latency and cost by setting thinking_level.

Per-part media resolution

types.Part(
    file_data=types.FileData(
        file_uri="gs://cloud-samples-data/generative-ai/image/a-man-and-a-dog.png",
        mime_type="image/jpeg",
    ),
    media_resolution=types.PartMediaResolution(
        level=types.PartMediaResolutionLevel.MEDIA_RESOLUTION_ULTRA_HIGH
    ),
)

Demonstrates granular image or video processing control for multimodal prompts.

Manual function response history

history = [
    types.Content(role="user", parts=[types.Part(text=prompt)]),
    response.candidates[0].content,
    types.Content(role="tool", parts=[
        types.Part.from_function_response(
            name=function_call.name,
            response=function_response_data,
        )
    ]),
]
response_2 = client.models.generate_content(model=MODEL_ID, contents=history)

Preserves the model turn so the SDK can carry thought signatures into the follow-up request.

Structured output schema

class CountryInfo(BaseModel):
    name: str
    population: int
    capital: str
 
response = client.models.generate_content(
    model=MODEL_ID,
    contents="Give me information for the United States.",
    config=types.GenerateContentConfig(
        response_mime_type="application/json",
        response_schema=CountryInfo,
    ),
)

Uses a Pydantic schema to request JSON and parse the response into a typed object.

Models & APIs used

  • Models: gemini-3-flash-preview
  • APIs / services: Vertex AI, Cloud Storage, Google Search
  • SDKs / libraries: google-genai, pydantic, IPython

When to use this

Use this pattern when starting a Vertex AI Gemini 3 Flash Preview project that needs SDK calls, multimodal input, tools, structured output, or chat.

Gotchas & caveats

  • Gemini 3 Flash Preview access is removed for new and inactive Gemini Enterprise Agent Platform projects on June 15, 2026, and model tuning is also turned off on that date.
  • Gemini 3 Flash API features require Gen AI SDK for Python version 1.56.0 or later.
  • The notebook uses LOCATION = “global” and requires a Google Cloud project with the Vertex AI API enabled.
  • If PROJECT_ID is left as the template value, the notebook falls back to GOOGLE_CLOUD_PROJECT from the environment.
  • If thinking_level is omitted, the model defaults to HIGH dynamic thinking.
  • thinking_level and legacy thinking_budget cannot be used together; the notebook says this returns a 400 error.
  • ULTRA_HIGH media resolution is only supported for individual media parts.
  • For raw JSON function-calling history, missing thought_signature can cause a 400 error: “Function Call in the content block is missing a thought_signature”.

Best practices

  • Use the Google Gen AI SDK chat history or append the full model response so thought signatures are handled automatically.
  • Set thinking_level to MINIMAL or LOW for lower-complexity tasks where lower latency is preferred.
  • Use HIGH thinking_level for non-trivial reasoning tasks such as the double-checked locking C++ example.
  • Lower media_resolution for long videos or extensive documents to fit token limits.
  • Keep Gemini 3 temperature at its default value of 1.0 as recommended in the notebook.
  • Use safety_settings and inspect finish_reason and safety_ratings when testing blocked content.
  • Use response_mime_type with response_schema for structured JSON outputs.
  • Use from_uri for Cloud Storage or public URLs and from_bytes for local files.