From 36a22f292b1833100cc05471f80df56f239a5a2a Mon Sep 17 00:00:00 2001 From: Holt Skinner Date: Thu, 18 Jun 2026 14:07:45 -0400 Subject: [PATCH 1/2] chore(genai): Update Gemini Model IDs - `gemini-2.5-flash` -> `gemini-3.5-flash` - `gemini-2.5-pro` -> `gemini-3.1-pro-preview` - `gemini-2.0-flash-live-preview-04-09` -> `gemini-live-2.5-flash-native-audio` --- genai/batch_prediction/batchpredict_with_bq.py | 4 ++-- genai/batch_prediction/batchpredict_with_gcs.py | 4 ++-- genai/bounding_box/boundingbox_with_txt_img.py | 2 +- .../contentcache_create_with_txt_gcs_pdf.py | 2 +- genai/content_cache/contentcache_use_with_txt.py | 2 +- .../ctrlgen_with_class_schema.py | 3 +-- .../ctrlgen_with_enum_class_schema.py | 2 +- .../ctrlgen_with_enum_schema.py | 2 +- .../ctrlgen_with_nested_class_schema.py | 3 +-- .../ctrlgen_with_nullable_schema.py | 2 +- .../ctrlgen_with_resp_schema.py | 2 +- genai/count_tokens/counttoken_compute_with_txt.py | 2 +- .../counttoken_localtokenizer_compute_with_txt.py | 2 +- .../counttoken_localtokenizer_with_txt.py | 2 +- genai/count_tokens/counttoken_resp_with_txt.py | 2 +- genai/count_tokens/counttoken_with_txt.py | 2 +- genai/count_tokens/counttoken_with_txt_vid.py | 2 +- genai/express_mode/api_key_example.py | 2 +- genai/express_mode/test_express_mode_examples.py | 5 ++--- genai/live/live_code_exec_with_txt.py | 12 +++++++++--- genai/live/live_func_call_with_txt.py | 14 ++++++++++---- genai/live/live_ground_googsearch_with_txt.py | 12 +++++++++--- genai/live/live_ground_ragengine_with_txt.py | 15 +++++++++++---- genai/live/live_structured_output_with_txt.py | 8 +++++--- genai/live/live_txt_with_audio.py | 2 +- genai/live/live_txtgen_with_audio.py | 2 +- genai/live/live_websocket_textgen_with_audio.py | 2 +- genai/live/live_websocket_textgen_with_txt.py | 2 +- genai/live/live_with_txt.py | 11 ++++++++--- .../provisionedthroughput_with_txt.py | 2 +- genai/safety/safety_with_txt.py | 4 ++-- genai/text_generation/textgen_async_with_txt.py | 2 +- .../textgen_chat_stream_with_txt.py | 2 +- genai/text_generation/textgen_chat_with_txt.py | 2 +- genai/text_generation/textgen_code_with_pdf.py | 2 +- genai/text_generation/textgen_config_with_txt.py | 2 +- .../text_generation/textgen_sys_instr_with_txt.py | 2 +- .../textgen_transcript_with_gcs_audio.py | 2 +- genai/text_generation/textgen_with_gcs_audio.py | 2 +- genai/text_generation/textgen_with_local_video.py | 2 +- genai/text_generation/textgen_with_multi_img.py | 2 +- .../textgen_with_multi_local_img.py | 2 +- genai/text_generation/textgen_with_mute_video.py | 2 +- genai/text_generation/textgen_with_pdf.py | 2 +- genai/text_generation/textgen_with_txt.py | 2 +- genai/text_generation/textgen_with_txt_img.py | 2 +- genai/text_generation/textgen_with_txt_stream.py | 2 +- genai/text_generation/textgen_with_video.py | 2 +- .../text_generation/textgen_with_youtube_video.py | 2 +- .../text_generation/thinking_textgen_with_txt.py | 2 +- genai/thinking/thinking_budget_with_txt.py | 2 +- .../thinking/thinking_includethoughts_with_txt.py | 2 +- genai/thinking/thinking_with_txt.py | 2 +- genai/tools/tools_code_exec_with_txt.py | 4 ++-- genai/tools/tools_code_exec_with_txt_local_img.py | 4 ++-- .../tools/tools_enterprise_web_search_with_txt.py | 2 +- genai/tools/tools_func_def_with_txt.py | 2 +- genai/tools/tools_func_desc_with_txt.py | 2 +- .../tools_google_maps_coordinates_with_txt.py | 6 +++--- genai/tools/tools_google_maps_with_txt.py | 2 +- ...tools_google_search_and_urlcontext_with_txt.py | 10 ++++++++-- genai/tools/tools_google_search_with_txt.py | 2 +- genai/tools/tools_urlcontext_with_txt.py | 8 ++++---- genai/tools/tools_vais_with_txt.py | 2 +- genai/tuning/preference_tuning_job_create.py | 4 ++-- genai/tuning/tuning_job_create.py | 12 ++++++++++-- genai/tuning/tuning_with_checkpoints_create.py | 12 ++++++++++-- 67 files changed, 150 insertions(+), 99 deletions(-) diff --git a/genai/batch_prediction/batchpredict_with_bq.py b/genai/batch_prediction/batchpredict_with_bq.py index bf051f2a223..2fc6dab4a7c 100644 --- a/genai/batch_prediction/batchpredict_with_bq.py +++ b/genai/batch_prediction/batchpredict_with_bq.py @@ -18,7 +18,7 @@ def generate_content(output_uri: str) -> str: import time from google import genai - from google.genai.types import CreateBatchJobConfig, JobState, HttpOptions + from google.genai.types import CreateBatchJobConfig, HttpOptions, JobState client = genai.Client(http_options=HttpOptions(api_version="v1")) @@ -28,7 +28,7 @@ def generate_content(output_uri: str) -> str: job = client.batches.create( # To use a tuned model, set the model param to your tuned model using the following format: # model="projects/{PROJECT_ID}/locations/{LOCATION}/models/{MODEL_ID} - model="gemini-2.5-flash", + model="gemini-3.5-flash", src="bq://storage-samples.generative_ai.batch_requests_for_multimodal_input", config=CreateBatchJobConfig(dest=output_uri), ) diff --git a/genai/batch_prediction/batchpredict_with_gcs.py b/genai/batch_prediction/batchpredict_with_gcs.py index fcedf217bdc..2617b123231 100644 --- a/genai/batch_prediction/batchpredict_with_gcs.py +++ b/genai/batch_prediction/batchpredict_with_gcs.py @@ -18,7 +18,7 @@ def generate_content(output_uri: str) -> str: import time from google import genai - from google.genai.types import CreateBatchJobConfig, JobState, HttpOptions + from google.genai.types import CreateBatchJobConfig, HttpOptions, JobState client = genai.Client(http_options=HttpOptions(api_version="v1")) # TODO(developer): Update and un-comment below line @@ -28,7 +28,7 @@ def generate_content(output_uri: str) -> str: job = client.batches.create( # To use a tuned model, set the model param to your tuned model using the following format: # model="projects/{PROJECT_ID}/locations/{LOCATION}/models/{MODEL_ID} - model="gemini-2.5-flash", + model="gemini-3.5-flash", # Source link: https://storage.cloud.google.com/cloud-samples-data/batch/prompt_for_batch_gemini_predict.jsonl src="gs://cloud-samples-data/batch/prompt_for_batch_gemini_predict.jsonl", config=CreateBatchJobConfig(dest=output_uri), diff --git a/genai/bounding_box/boundingbox_with_txt_img.py b/genai/bounding_box/boundingbox_with_txt_img.py index a22f15dc664..679c9be0fae 100644 --- a/genai/bounding_box/boundingbox_with_txt_img.py +++ b/genai/bounding_box/boundingbox_with_txt_img.py @@ -102,7 +102,7 @@ def plot_bounding_boxes(image_uri: str, bounding_boxes: list[BoundingBox]) -> No image_uri = "https://storage.googleapis.com/generativeai-downloads/images/socks.jpg" response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ Part.from_uri( file_uri=image_uri, diff --git a/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py b/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py index 2ed5ee6b713..56f04011e56 100644 --- a/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py +++ b/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py @@ -42,7 +42,7 @@ def create_content_cache() -> str: ] content_cache = client.caches.create( - model="gemini-2.5-flash", + model="gemini-3.5-flash", config=CreateCachedContentConfig( contents=contents, system_instruction=system_instruction, diff --git a/genai/content_cache/contentcache_use_with_txt.py b/genai/content_cache/contentcache_use_with_txt.py index 7e85e52cd72..97c0d662d03 100644 --- a/genai/content_cache/contentcache_use_with_txt.py +++ b/genai/content_cache/contentcache_use_with_txt.py @@ -22,7 +22,7 @@ def generate_content(cache_name: str) -> str: # Use content cache to generate text response # E.g cache_name = 'projects/.../locations/.../cachedContents/1111111111111111111' response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Summarize the pdfs", config=GenerateContentConfig( cached_content=cache_name, diff --git a/genai/controlled_generation/ctrlgen_with_class_schema.py b/genai/controlled_generation/ctrlgen_with_class_schema.py index 8613c206a59..51effae1c57 100644 --- a/genai/controlled_generation/ctrlgen_with_class_schema.py +++ b/genai/controlled_generation/ctrlgen_with_class_schema.py @@ -17,7 +17,6 @@ def generate_content() -> str: # [START googlegenaisdk_ctrlgen_with_class_schema] from google import genai from google.genai.types import GenerateContentConfig, HttpOptions - from pydantic import BaseModel class Recipe(BaseModel): @@ -26,7 +25,7 @@ class Recipe(BaseModel): client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="List a few popular cookie recipes.", config=GenerateContentConfig( response_mime_type="application/json", diff --git a/genai/controlled_generation/ctrlgen_with_enum_class_schema.py b/genai/controlled_generation/ctrlgen_with_enum_class_schema.py index 0eeb869c200..9eb8a839bf3 100644 --- a/genai/controlled_generation/ctrlgen_with_enum_class_schema.py +++ b/genai/controlled_generation/ctrlgen_with_enum_class_schema.py @@ -29,7 +29,7 @@ class InstrumentClass(enum.Enum): client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="What type of instrument is a guitar?", config={ "response_mime_type": "text/x.enum", diff --git a/genai/controlled_generation/ctrlgen_with_enum_schema.py b/genai/controlled_generation/ctrlgen_with_enum_schema.py index 3cfd358ac25..9a2493a5b46 100644 --- a/genai/controlled_generation/ctrlgen_with_enum_schema.py +++ b/genai/controlled_generation/ctrlgen_with_enum_schema.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="What type of instrument is an oboe?", config=GenerateContentConfig( response_mime_type="text/x.enum", diff --git a/genai/controlled_generation/ctrlgen_with_nested_class_schema.py b/genai/controlled_generation/ctrlgen_with_nested_class_schema.py index 633c79bb128..970f11a2231 100644 --- a/genai/controlled_generation/ctrlgen_with_nested_class_schema.py +++ b/genai/controlled_generation/ctrlgen_with_nested_class_schema.py @@ -19,7 +19,6 @@ def generate_content() -> str: from google import genai from google.genai.types import GenerateContentConfig, HttpOptions - from pydantic import BaseModel class Grade(enum.Enum): @@ -36,7 +35,7 @@ class Recipe(BaseModel): client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="List about 10 home-baked cookies and give them grades based on tastiness.", config=GenerateContentConfig( response_mime_type="application/json", diff --git a/genai/controlled_generation/ctrlgen_with_nullable_schema.py b/genai/controlled_generation/ctrlgen_with_nullable_schema.py index 8aba542425e..9f93ea465bb 100644 --- a/genai/controlled_generation/ctrlgen_with_nullable_schema.py +++ b/genai/controlled_generation/ctrlgen_with_nullable_schema.py @@ -51,7 +51,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=prompt, config=GenerateContentConfig( response_mime_type="application/json", diff --git a/genai/controlled_generation/ctrlgen_with_resp_schema.py b/genai/controlled_generation/ctrlgen_with_resp_schema.py index 2e17c516d0f..33e78d1ae00 100644 --- a/genai/controlled_generation/ctrlgen_with_resp_schema.py +++ b/genai/controlled_generation/ctrlgen_with_resp_schema.py @@ -36,7 +36,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=prompt, config={ "response_mime_type": "application/json", diff --git a/genai/count_tokens/counttoken_compute_with_txt.py b/genai/count_tokens/counttoken_compute_with_txt.py index 0b3af0a6bb2..088f437c659 100644 --- a/genai/count_tokens/counttoken_compute_with_txt.py +++ b/genai/count_tokens/counttoken_compute_with_txt.py @@ -20,7 +20,7 @@ def compute_tokens_example() -> int: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.compute_tokens( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="What's the longest word in the English language?", ) diff --git a/genai/count_tokens/counttoken_localtokenizer_compute_with_txt.py b/genai/count_tokens/counttoken_localtokenizer_compute_with_txt.py index 889044e63af..f89f323a6b2 100644 --- a/genai/count_tokens/counttoken_localtokenizer_compute_with_txt.py +++ b/genai/count_tokens/counttoken_localtokenizer_compute_with_txt.py @@ -17,7 +17,7 @@ def counttoken_localtokenizer_compute_with_txt() -> int: # [START googlegenaisdk_counttoken_localtokenizer_compute_with_txt] from google.genai.local_tokenizer import LocalTokenizer - tokenizer = LocalTokenizer(model_name="gemini-2.5-flash") + tokenizer = LocalTokenizer(model_name="gemini-3.5-flash") response = tokenizer.compute_tokens("What's the longest word in the English language?") print(response) # Example output: diff --git a/genai/count_tokens/counttoken_localtokenizer_with_txt.py b/genai/count_tokens/counttoken_localtokenizer_with_txt.py index e784d393c9b..f726303cb71 100644 --- a/genai/count_tokens/counttoken_localtokenizer_with_txt.py +++ b/genai/count_tokens/counttoken_localtokenizer_with_txt.py @@ -17,7 +17,7 @@ def counttoken_localtokenizer_with_txt() -> int: # [START googlegenaisdk_counttoken_localtokenizer_with_txt] from google.genai.local_tokenizer import LocalTokenizer - tokenizer = LocalTokenizer(model_name="gemini-2.5-flash") + tokenizer = LocalTokenizer(model_name="gemini-3.5-flash") response = tokenizer.count_tokens("What's the highest mountain in Africa?") print(response) # Example output: diff --git a/genai/count_tokens/counttoken_resp_with_txt.py b/genai/count_tokens/counttoken_resp_with_txt.py index f2db5309e01..f5cb315effe 100644 --- a/genai/count_tokens/counttoken_resp_with_txt.py +++ b/genai/count_tokens/counttoken_resp_with_txt.py @@ -24,7 +24,7 @@ def count_tokens_example() -> int: # Send text to Gemini response = client.models.generate_content( - model="gemini-2.5-flash", contents=prompt + model="gemini-3.5-flash", contents=prompt ) # Prompt and response tokens count diff --git a/genai/count_tokens/counttoken_with_txt.py b/genai/count_tokens/counttoken_with_txt.py index fcbf9484087..7eb37a8d2ab 100644 --- a/genai/count_tokens/counttoken_with_txt.py +++ b/genai/count_tokens/counttoken_with_txt.py @@ -20,7 +20,7 @@ def count_tokens() -> int: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.count_tokens( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="What's the highest mountain in Africa?", ) print(response) diff --git a/genai/count_tokens/counttoken_with_txt_vid.py b/genai/count_tokens/counttoken_with_txt_vid.py index e32f14f0845..e8d1ec72f67 100644 --- a/genai/count_tokens/counttoken_with_txt_vid.py +++ b/genai/count_tokens/counttoken_with_txt_vid.py @@ -29,7 +29,7 @@ def count_tokens() -> int: ] response = client.models.count_tokens( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=contents, ) print(response) diff --git a/genai/express_mode/api_key_example.py b/genai/express_mode/api_key_example.py index 21f8ab0e81d..47f390b6914 100644 --- a/genai/express_mode/api_key_example.py +++ b/genai/express_mode/api_key_example.py @@ -23,7 +23,7 @@ def generate_content() -> str: client = genai.Client(vertexai=True, api_key=API_KEY) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Explain bubble sort to me.", ) diff --git a/genai/express_mode/test_express_mode_examples.py b/genai/express_mode/test_express_mode_examples.py index 7b2ff26511a..acfdc964240 100644 --- a/genai/express_mode/test_express_mode_examples.py +++ b/genai/express_mode/test_express_mode_examples.py @@ -14,9 +14,8 @@ from unittest.mock import MagicMock, patch -from google.genai import types - import api_key_example +from google.genai import types @patch("google.genai.Client") @@ -40,7 +39,7 @@ def test_api_key_example(mock_genai_client: MagicMock) -> None: mock_genai_client.assert_called_once_with(vertexai=True, api_key="YOUR_API_KEY") mock_genai_client.return_value.models.generate_content.assert_called_once_with( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Explain bubble sort to me.", ) assert response == "This is a mocked bubble sort explanation." diff --git a/genai/live/live_code_exec_with_txt.py b/genai/live/live_code_exec_with_txt.py index ce36fc9f7b1..aab142bceae 100644 --- a/genai/live/live_code_exec_with_txt.py +++ b/genai/live/live_code_exec_with_txt.py @@ -18,11 +18,17 @@ async def generate_content() -> list[str]: # [START googlegenaisdk_live_code_exec_with_txt] from google import genai - from google.genai.types import (Content, LiveConnectConfig, Modality, Part, - Tool, ToolCodeExecution) + from google.genai.types import ( + Content, + LiveConnectConfig, + Modality, + Part, + Tool, + ToolCodeExecution, + ) client = genai.Client() - model_id = "gemini-2.0-flash-live-preview-04-09" + model_id = "gemini-live-2.5-flash-native-audio" config = LiveConnectConfig( response_modalities=[Modality.TEXT], tools=[Tool(code_execution=ToolCodeExecution())], diff --git a/genai/live/live_func_call_with_txt.py b/genai/live/live_func_call_with_txt.py index 615ad1a8c9a..b48d9155a70 100644 --- a/genai/live/live_func_call_with_txt.py +++ b/genai/live/live_func_call_with_txt.py @@ -20,12 +20,18 @@ async def generate_content() -> list[FunctionResponse]: # [START googlegenaisdk_live_func_call_with_txt] from google import genai - from google.genai.types import (Content, FunctionDeclaration, - FunctionResponse, LiveConnectConfig, - Modality, Part, Tool) + from google.genai.types import ( + Content, + FunctionDeclaration, + FunctionResponse, + LiveConnectConfig, + Modality, + Part, + Tool, + ) client = genai.Client() - model_id = "gemini-2.0-flash-live-preview-04-09" + model_id = "gemini-live-2.5-flash-native-audio" # Simple function definitions turn_on_the_lights = FunctionDeclaration(name="turn_on_the_lights") diff --git a/genai/live/live_ground_googsearch_with_txt.py b/genai/live/live_ground_googsearch_with_txt.py index d160b286649..573dfe61414 100644 --- a/genai/live/live_ground_googsearch_with_txt.py +++ b/genai/live/live_ground_googsearch_with_txt.py @@ -19,11 +19,17 @@ async def generate_content() -> list[str]: # [START googlegenaisdk_live_ground_googsearch_with_txt] from google import genai - from google.genai.types import (Content, GoogleSearch, LiveConnectConfig, - Modality, Part, Tool) + from google.genai.types import ( + Content, + GoogleSearch, + LiveConnectConfig, + Modality, + Part, + Tool, + ) client = genai.Client() - model_id = "gemini-2.0-flash-live-preview-04-09" + model_id = "gemini-live-2.5-flash-native-audio" config = LiveConnectConfig( response_modalities=[Modality.TEXT], tools=[Tool(google_search=GoogleSearch())], diff --git a/genai/live/live_ground_ragengine_with_txt.py b/genai/live/live_ground_ragengine_with_txt.py index 09b133ad7cf..6d6761f7926 100644 --- a/genai/live/live_ground_ragengine_with_txt.py +++ b/genai/live/live_ground_ragengine_with_txt.py @@ -17,12 +17,19 @@ async def generate_content(memory_corpus: str) -> list[str]: # [START googlegenaisdk_live_ground_ragengine_with_txt] from google import genai - from google.genai.types import (Content, LiveConnectConfig, Modality, Part, - Retrieval, Tool, VertexRagStore, - VertexRagStoreRagResource) + from google.genai.types import ( + Content, + LiveConnectConfig, + Modality, + Part, + Retrieval, + Tool, + VertexRagStore, + VertexRagStoreRagResource, + ) client = genai.Client() - model_id = "gemini-2.0-flash-live-preview-04-09" + model_id = "gemini-live-2.5-flash-native-audio" rag_store = VertexRagStore( rag_resources=[ VertexRagStoreRagResource( diff --git a/genai/live/live_structured_output_with_txt.py b/genai/live/live_structured_output_with_txt.py index 2727fbcb08e..21fee517773 100644 --- a/genai/live/live_structured_output_with_txt.py +++ b/genai/live/live_structured_output_with_txt.py @@ -30,8 +30,10 @@ def generate_content() -> CalendarEvent: import google.auth.transport.requests import openai from google.auth import default - from openai.types.chat import (ChatCompletionSystemMessageParam, - ChatCompletionUserMessageParam) + from openai.types.chat import ( + ChatCompletionSystemMessageParam, + ChatCompletionUserMessageParam, + ) project_id = os.environ["GOOGLE_CLOUD_PROJECT"] location = "us-central1" @@ -59,7 +61,7 @@ def generate_content() -> CalendarEvent: ) completion = client.beta.chat.completions.parse( - model="google/gemini-2.5-flash", + model="google/gemini-3.5-flash", messages=[ ChatCompletionSystemMessageParam( role="system", content="Extract the event information." diff --git a/genai/live/live_txt_with_audio.py b/genai/live/live_txt_with_audio.py index 30e9004d76f..e90ee98e19a 100644 --- a/genai/live/live_txt_with_audio.py +++ b/genai/live/live_txt_with_audio.py @@ -30,7 +30,7 @@ async def generate_content() -> list[str]: from google.genai.types import Blob, LiveConnectConfig, Modality client = genai.Client() - model = "gemini-2.0-flash-live-preview-04-09" + model = "gemini-live-2.5-flash-native-audio" config = LiveConnectConfig(response_modalities=[Modality.TEXT]) async with client.aio.live.connect(model=model, config=config) as session: diff --git a/genai/live/live_txtgen_with_audio.py b/genai/live/live_txtgen_with_audio.py index 7daf4073a48..7a3af9dcdfb 100644 --- a/genai/live/live_txtgen_with_audio.py +++ b/genai/live/live_txtgen_with_audio.py @@ -28,7 +28,7 @@ async def generate_content() -> list[str]: from google.genai.types import Blob, LiveConnectConfig, Modality client = genai.Client() - model = "gemini-2.0-flash-live-preview-04-09" + model = "gemini-live-2.5-flash-native-audio" config = LiveConnectConfig(response_modalities=[Modality.TEXT]) def get_audio(url: str) -> bytes: diff --git a/genai/live/live_websocket_textgen_with_audio.py b/genai/live/live_websocket_textgen_with_audio.py index 781ffc96d78..29a5c913a2f 100644 --- a/genai/live/live_websocket_textgen_with_audio.py +++ b/genai/live/live_websocket_textgen_with_audio.py @@ -57,7 +57,7 @@ def read_wavefile(filepath: str) -> tuple[str, str]: # Configuration Constants PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") LOCATION = "us-central1" - GEMINI_MODEL_NAME = "gemini-2.0-flash-live-preview-04-09" + GEMINI_MODEL_NAME = "gemini-live-2.5-flash-native-audio" # To generate a bearer token in CLI, use: # $ gcloud auth application-default print-access-token # It's recommended to fetch this token dynamically rather than hardcoding. diff --git a/genai/live/live_websocket_textgen_with_txt.py b/genai/live/live_websocket_textgen_with_txt.py index 13515b30062..41b731d3cf3 100644 --- a/genai/live/live_websocket_textgen_with_txt.py +++ b/genai/live/live_websocket_textgen_with_txt.py @@ -44,7 +44,7 @@ async def generate_content() -> str: # Configuration Constants PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") LOCATION = "us-central1" - GEMINI_MODEL_NAME = "gemini-2.0-flash-live-preview-04-09" + GEMINI_MODEL_NAME = "gemini-live-2.5-flash-native-audio" # To generate a bearer token in CLI, use: # $ gcloud auth application-default print-access-token # It's recommended to fetch this token dynamically rather than hardcoding. diff --git a/genai/live/live_with_txt.py b/genai/live/live_with_txt.py index 78df0ccd700..65d8903aabf 100644 --- a/genai/live/live_with_txt.py +++ b/genai/live/live_with_txt.py @@ -18,11 +18,16 @@ async def generate_content() -> list[str]: # [START googlegenaisdk_live_with_txt] from google import genai - from google.genai.types import (Content, HttpOptions, LiveConnectConfig, - Modality, Part) + from google.genai.types import ( + Content, + HttpOptions, + LiveConnectConfig, + Modality, + Part, + ) client = genai.Client(http_options=HttpOptions(api_version="v1beta1")) - model_id = "gemini-2.0-flash-live-preview-04-09" + model_id = "gemini-live-2.5-flash-native-audio" async with client.aio.live.connect( model=model_id, diff --git a/genai/provisioned_throughput/provisionedthroughput_with_txt.py b/genai/provisioned_throughput/provisionedthroughput_with_txt.py index a85362ee6d8..d915da62b98 100644 --- a/genai/provisioned_throughput/provisionedthroughput_with_txt.py +++ b/genai/provisioned_throughput/provisionedthroughput_with_txt.py @@ -31,7 +31,7 @@ def generate_content() -> str: ) ) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="How does AI work?", ) print(response.text) diff --git a/genai/safety/safety_with_txt.py b/genai/safety/safety_with_txt.py index 308a45cb154..ef95a46571b 100644 --- a/genai/safety/safety_with_txt.py +++ b/genai/safety/safety_with_txt.py @@ -20,8 +20,8 @@ def generate_content() -> GenerateContentResponse: from google import genai from google.genai.types import ( GenerateContentConfig, - HarmCategory, HarmBlockThreshold, + HarmCategory, HttpOptions, SafetySetting, ) @@ -54,7 +54,7 @@ def generate_content() -> GenerateContentResponse: ] response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=prompt, config=GenerateContentConfig( system_instruction=system_instruction, diff --git a/genai/text_generation/textgen_async_with_txt.py b/genai/text_generation/textgen_async_with_txt.py index ccbb5cdc443..9c3d0b00b2b 100644 --- a/genai/text_generation/textgen_async_with_txt.py +++ b/genai/text_generation/textgen_async_with_txt.py @@ -21,7 +21,7 @@ async def generate_content() -> str: from google.genai.types import GenerateContentConfig, HttpOptions client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" response = await client.aio.models.generate_content( model=model_id, diff --git a/genai/text_generation/textgen_chat_stream_with_txt.py b/genai/text_generation/textgen_chat_stream_with_txt.py index d5a5cf9b6c6..2d8f946e8fa 100644 --- a/genai/text_generation/textgen_chat_stream_with_txt.py +++ b/genai/text_generation/textgen_chat_stream_with_txt.py @@ -19,7 +19,7 @@ def generate_content() -> bool: from google.genai.types import HttpOptions client = genai.Client(http_options=HttpOptions(api_version="v1")) - chat_session = client.chats.create(model="gemini-2.5-flash") + chat_session = client.chats.create(model="gemini-3.5-flash") for chunk in chat_session.send_message_stream("Why is the sky blue?"): print(chunk.text, end="") diff --git a/genai/text_generation/textgen_chat_with_txt.py b/genai/text_generation/textgen_chat_with_txt.py index 0b1bc928e0c..36e13e81e56 100644 --- a/genai/text_generation/textgen_chat_with_txt.py +++ b/genai/text_generation/textgen_chat_with_txt.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) chat_session = client.chats.create( - model="gemini-2.5-flash", + model="gemini-3.5-flash", history=[ UserContent(parts=[Part(text="Hello")]), ModelContent( diff --git a/genai/text_generation/textgen_code_with_pdf.py b/genai/text_generation/textgen_code_with_pdf.py index da4ca76b73a..39bbce2d4c7 100644 --- a/genai/text_generation/textgen_code_with_pdf.py +++ b/genai/text_generation/textgen_code_with_pdf.py @@ -21,7 +21,7 @@ def generate_content() -> str: from google.genai.types import HttpOptions, Part client = genai.Client(http_options=HttpOptions(api_version="v1beta1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" prompt = "Convert this python code to use Google Python Style Guide." print("> ", prompt, "\n") pdf_uri = "https://storage.googleapis.com/cloud-samples-data/generative-ai/text/inefficient_fibonacci_series_python_code.pdf" diff --git a/genai/text_generation/textgen_config_with_txt.py b/genai/text_generation/textgen_config_with_txt.py index 0a54b2cb5ab..ae8c7fdd7eb 100644 --- a/genai/text_generation/textgen_config_with_txt.py +++ b/genai/text_generation/textgen_config_with_txt.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Why is the sky blue?", # See the SDK documentation at # https://googleapis.github.io/python-genai/genai.html#genai.types.GenerateContentConfig diff --git a/genai/text_generation/textgen_sys_instr_with_txt.py b/genai/text_generation/textgen_sys_instr_with_txt.py index 1bdd3d74128..3d532f3f757 100644 --- a/genai/text_generation/textgen_sys_instr_with_txt.py +++ b/genai/text_generation/textgen_sys_instr_with_txt.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Why is the sky blue?", config=GenerateContentConfig( system_instruction=[ diff --git a/genai/text_generation/textgen_transcript_with_gcs_audio.py b/genai/text_generation/textgen_transcript_with_gcs_audio.py index 1cac5ee4bef..c75cb44308b 100644 --- a/genai/text_generation/textgen_transcript_with_gcs_audio.py +++ b/genai/text_generation/textgen_transcript_with_gcs_audio.py @@ -24,7 +24,7 @@ def generate_content() -> str: Use speaker A, speaker B, etc. to identify speakers. """ response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ prompt, Part.from_uri( diff --git a/genai/text_generation/textgen_with_gcs_audio.py b/genai/text_generation/textgen_with_gcs_audio.py index f65818dc652..81ea31b2759 100644 --- a/genai/text_generation/textgen_with_gcs_audio.py +++ b/genai/text_generation/textgen_with_gcs_audio.py @@ -23,7 +23,7 @@ def generate_content() -> str: Provide a concise summary of the main points in the audio file. """ response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ prompt, Part.from_uri( diff --git a/genai/text_generation/textgen_with_local_video.py b/genai/text_generation/textgen_with_local_video.py index be1b1a7ad9c..112a940da8e 100644 --- a/genai/text_generation/textgen_with_local_video.py +++ b/genai/text_generation/textgen_with_local_video.py @@ -19,7 +19,7 @@ def generate_content() -> str: from google.genai.types import HttpOptions, Part client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" # Read local video file content with open("test_data/describe_video_content.mp4", "rb") as fp: diff --git a/genai/text_generation/textgen_with_multi_img.py b/genai/text_generation/textgen_with_multi_img.py index 71b617baf71..19d5388d823 100644 --- a/genai/text_generation/textgen_with_multi_img.py +++ b/genai/text_generation/textgen_with_multi_img.py @@ -28,7 +28,7 @@ def generate_content() -> str: local_file_img_bytes = f.read() response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ "Generate a list of all the objects contained in both images.", Part.from_uri(file_uri=gcs_file_img_path, mime_type="image/jpeg"), diff --git a/genai/text_generation/textgen_with_multi_local_img.py b/genai/text_generation/textgen_with_multi_local_img.py index 9419c186bdd..a7aeb3a7ab5 100644 --- a/genai/text_generation/textgen_with_multi_local_img.py +++ b/genai/text_generation/textgen_with_multi_local_img.py @@ -28,7 +28,7 @@ def generate_content(image_path_1: str, image_path_2: str) -> str: image_2_bytes = f.read() response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ "Generate a list of all the objects contained in both images.", Part.from_bytes(data=image_1_bytes, mime_type="image/jpeg"), diff --git a/genai/text_generation/textgen_with_mute_video.py b/genai/text_generation/textgen_with_mute_video.py index 1c644c94ead..0a014aed928 100644 --- a/genai/text_generation/textgen_with_mute_video.py +++ b/genai/text_generation/textgen_with_mute_video.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ Part.from_uri( file_uri="gs://cloud-samples-data/generative-ai/video/ad_copy_from_video.mp4", diff --git a/genai/text_generation/textgen_with_pdf.py b/genai/text_generation/textgen_with_pdf.py index 31de8b5e46c..28f2dd18f77 100644 --- a/genai/text_generation/textgen_with_pdf.py +++ b/genai/text_generation/textgen_with_pdf.py @@ -21,7 +21,7 @@ def generate_content() -> str: from google.genai.types import HttpOptions, Part client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" prompt = """ You are a highly skilled document summarization specialist. diff --git a/genai/text_generation/textgen_with_txt.py b/genai/text_generation/textgen_with_txt.py index c2e4a879f02..4825aac9212 100644 --- a/genai/text_generation/textgen_with_txt.py +++ b/genai/text_generation/textgen_with_txt.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="How does AI work?", ) print(response.text) diff --git a/genai/text_generation/textgen_with_txt_img.py b/genai/text_generation/textgen_with_txt_img.py index 99d2bc87e96..a295eea2d18 100644 --- a/genai/text_generation/textgen_with_txt_img.py +++ b/genai/text_generation/textgen_with_txt_img.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ "What is shown in this image?", Part.from_uri( diff --git a/genai/text_generation/textgen_with_txt_stream.py b/genai/text_generation/textgen_with_txt_stream.py index 30ce428c4f8..6d43d0d2c20 100644 --- a/genai/text_generation/textgen_with_txt_stream.py +++ b/genai/text_generation/textgen_with_txt_stream.py @@ -21,7 +21,7 @@ def generate_content() -> bool: client = genai.Client(http_options=HttpOptions(api_version="v1")) for chunk in client.models.generate_content_stream( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Why is the sky blue?", ): print(chunk.text, end="") diff --git a/genai/text_generation/textgen_with_video.py b/genai/text_generation/textgen_with_video.py index 7cd4cc97d15..db567d67960 100644 --- a/genai/text_generation/textgen_with_video.py +++ b/genai/text_generation/textgen_with_video.py @@ -25,7 +25,7 @@ def generate_content() -> str: Create a chapter breakdown with timestamps for key sections or topics discussed. """ response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[ Part.from_uri( file_uri="gs://cloud-samples-data/generative-ai/video/pixel8.mp4", diff --git a/genai/text_generation/textgen_with_youtube_video.py b/genai/text_generation/textgen_with_youtube_video.py index 26eaddcce62..d24ec894573 100644 --- a/genai/text_generation/textgen_with_youtube_video.py +++ b/genai/text_generation/textgen_with_youtube_video.py @@ -21,7 +21,7 @@ def generate_content() -> str: from google.genai.types import HttpOptions, Part client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" response = client.models.generate_content( model=model_id, diff --git a/genai/text_generation/thinking_textgen_with_txt.py b/genai/text_generation/thinking_textgen_with_txt.py index 00f72e919e3..931b369b26f 100644 --- a/genai/text_generation/thinking_textgen_with_txt.py +++ b/genai/text_generation/thinking_textgen_with_txt.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client() response = client.models.generate_content( - model="gemini-2.5-pro", + model="gemini-3.1-pro-preview", contents="solve x^2 + 4x + 4 = 0", ) print(response.text) diff --git a/genai/thinking/thinking_budget_with_txt.py b/genai/thinking/thinking_budget_with_txt.py index 5e8bc3cba27..3b8d07a8197 100644 --- a/genai/thinking/thinking_budget_with_txt.py +++ b/genai/thinking/thinking_budget_with_txt.py @@ -21,7 +21,7 @@ def generate_content() -> str: client = genai.Client() response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="solve x^2 + 4x + 4 = 0", config=GenerateContentConfig( thinking_config=ThinkingConfig( diff --git a/genai/thinking/thinking_includethoughts_with_txt.py b/genai/thinking/thinking_includethoughts_with_txt.py index 0eafd71b24a..df8f7c9f43d 100644 --- a/genai/thinking/thinking_includethoughts_with_txt.py +++ b/genai/thinking/thinking_includethoughts_with_txt.py @@ -20,7 +20,7 @@ def generate_content() -> str: client = genai.Client() response = client.models.generate_content( - model="gemini-2.5-pro", + model="gemini-3.1-pro-preview", contents="solve x^2 + 4x + 4 = 0", config=GenerateContentConfig( thinking_config=ThinkingConfig(include_thoughts=True) diff --git a/genai/thinking/thinking_with_txt.py b/genai/thinking/thinking_with_txt.py index 0eccf44b93a..ae0ef2a15a2 100644 --- a/genai/thinking/thinking_with_txt.py +++ b/genai/thinking/thinking_with_txt.py @@ -19,7 +19,7 @@ def generate_content() -> str: client = genai.Client() response = client.models.generate_content( - model="gemini-2.5-pro", + model="gemini-3.1-pro-preview", contents="solve x^2 + 4x + 4 = 0", ) print(response.text) diff --git a/genai/tools/tools_code_exec_with_txt.py b/genai/tools/tools_code_exec_with_txt.py index a97cd913446..5c4deecd301 100644 --- a/genai/tools/tools_code_exec_with_txt.py +++ b/genai/tools/tools_code_exec_with_txt.py @@ -17,14 +17,14 @@ def generate_content() -> str: # [START googlegenaisdk_tools_code_exec_with_txt] from google import genai from google.genai.types import ( + GenerateContentConfig, HttpOptions, Tool, ToolCodeExecution, - GenerateContentConfig, ) client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" code_execution_tool = Tool(code_execution=ToolCodeExecution()) response = client.models.generate_content( diff --git a/genai/tools/tools_code_exec_with_txt_local_img.py b/genai/tools/tools_code_exec_with_txt_local_img.py index b58102afb39..10a64799fe0 100644 --- a/genai/tools/tools_code_exec_with_txt_local_img.py +++ b/genai/tools/tools_code_exec_with_txt_local_img.py @@ -17,7 +17,6 @@ def generate_content() -> GenerateContentResponse: # [START googlegenaisdk_tools_code_exec_with_txt_local_img] - from PIL import Image from google import genai from google.genai.types import ( GenerateContentConfig, @@ -25,6 +24,7 @@ def generate_content() -> GenerateContentResponse: Tool, ToolCodeExecution, ) + from PIL import Image client = genai.Client(http_options=HttpOptions(api_version="v1")) code_execution_tool = Tool(code_execution=ToolCodeExecution()) @@ -46,7 +46,7 @@ def generate_content() -> GenerateContentResponse: image_data = Image.open(image_file) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=[image_data, prompt], config=GenerateContentConfig( tools=[code_execution_tool], diff --git a/genai/tools/tools_enterprise_web_search_with_txt.py b/genai/tools/tools_enterprise_web_search_with_txt.py index 429f58600a9..c84ef9e8311 100644 --- a/genai/tools/tools_enterprise_web_search_with_txt.py +++ b/genai/tools/tools_enterprise_web_search_with_txt.py @@ -26,7 +26,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="When is the next total solar eclipse in the United States?", config=GenerateContentConfig( tools=[ diff --git a/genai/tools/tools_func_def_with_txt.py b/genai/tools/tools_func_def_with_txt.py index 89327dcd0cc..98581a43fcc 100644 --- a/genai/tools/tools_func_def_with_txt.py +++ b/genai/tools/tools_func_def_with_txt.py @@ -34,7 +34,7 @@ def get_current_weather(location: str) -> str: return weather_map.get(location, "unknown") client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" response = client.models.generate_content( model=model_id, diff --git a/genai/tools/tools_func_desc_with_txt.py b/genai/tools/tools_func_desc_with_txt.py index 6d89ede0fae..16c35ce291d 100644 --- a/genai/tools/tools_func_desc_with_txt.py +++ b/genai/tools/tools_func_desc_with_txt.py @@ -24,7 +24,7 @@ def generate_content() -> str: ) client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" get_album_sales = FunctionDeclaration( name="get_album_sales", diff --git a/genai/tools/tools_google_maps_coordinates_with_txt.py b/genai/tools/tools_google_maps_coordinates_with_txt.py index dbeafa66578..35253798d6a 100644 --- a/genai/tools/tools_google_maps_coordinates_with_txt.py +++ b/genai/tools/tools_google_maps_coordinates_with_txt.py @@ -20,16 +20,16 @@ def generate_content() -> str: GenerateContentConfig, GoogleMaps, HttpOptions, + LatLng, + RetrievalConfig, Tool, ToolConfig, - RetrievalConfig, - LatLng ) client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Where can I get the best espresso near me?", config=GenerateContentConfig( tools=[ diff --git a/genai/tools/tools_google_maps_with_txt.py b/genai/tools/tools_google_maps_with_txt.py index e2ff93e63b7..c9c3bbf336b 100644 --- a/genai/tools/tools_google_maps_with_txt.py +++ b/genai/tools/tools_google_maps_with_txt.py @@ -31,7 +31,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="Recommend a good restaurant in San Francisco.", config=GenerateContentConfig( tools=[ diff --git a/genai/tools/tools_google_search_and_urlcontext_with_txt.py b/genai/tools/tools_google_search_and_urlcontext_with_txt.py index f55353985c4..bb3c9ba826f 100644 --- a/genai/tools/tools_google_search_and_urlcontext_with_txt.py +++ b/genai/tools/tools_google_search_and_urlcontext_with_txt.py @@ -16,10 +16,16 @@ def generate_content() -> str: # [START googlegenaisdk_tools_google_search_and_urlcontext_with_txt] from google import genai - from google.genai.types import Tool, GenerateContentConfig, HttpOptions, UrlContext, GoogleSearch + from google.genai.types import ( + GenerateContentConfig, + GoogleSearch, + HttpOptions, + Tool, + UrlContext, + ) client = genai.Client(http_options=HttpOptions(api_version="v1beta1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" tools = [ Tool(url_context=UrlContext), diff --git a/genai/tools/tools_google_search_with_txt.py b/genai/tools/tools_google_search_with_txt.py index 4069071d0c3..fe1fe89030c 100644 --- a/genai/tools/tools_google_search_with_txt.py +++ b/genai/tools/tools_google_search_with_txt.py @@ -26,7 +26,7 @@ def generate_content() -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="When is the next total solar eclipse in the United States?", config=GenerateContentConfig( tools=[ diff --git a/genai/tools/tools_urlcontext_with_txt.py b/genai/tools/tools_urlcontext_with_txt.py index 0d7551afe23..d64d3e1051d 100644 --- a/genai/tools/tools_urlcontext_with_txt.py +++ b/genai/tools/tools_urlcontext_with_txt.py @@ -16,10 +16,10 @@ def generate_content() -> str: # [START googlegenaisdk_tools_urlcontext_with_txt] from google import genai - from google.genai.types import Tool, GenerateContentConfig, HttpOptions, UrlContext + from google.genai.types import GenerateContentConfig, HttpOptions, Tool, UrlContext client = genai.Client(http_options=HttpOptions(api_version="v1")) - model_id = "gemini-2.5-flash" + model_id = "gemini-3.5-flash" url_context_tool = Tool( url_context=UrlContext @@ -71,10 +71,10 @@ def generate_content() -> str: # get URLs retrieved for context print(response.candidates[0].url_context_metadata) # url_metadata=[UrlMetadata( - # retrieved_url='https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash', + # retrieved_url='https://ai.google.dev/gemini-api/docs/models#gemini-3.5-flash', # url_retrieval_status= # ), UrlMetadata( - # retrieved_url='https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro', + # retrieved_url='https://ai.google.dev/gemini-api/docs/models#gemini-3.1-pro-preview', # url_retrieval_status= # )] # [END googlegenaisdk_tools_urlcontext_with_txt] diff --git a/genai/tools/tools_vais_with_txt.py b/genai/tools/tools_vais_with_txt.py index 8c6e51d3b0e..e018cbcd20c 100644 --- a/genai/tools/tools_vais_with_txt.py +++ b/genai/tools/tools_vais_with_txt.py @@ -30,7 +30,7 @@ def generate_content(datastore: str) -> str: # datastore = "projects/111111111111/locations/global/collections/default_collection/dataStores/data-store-id" response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="How do I make an appointment to renew my driver's license?", config=GenerateContentConfig( tools=[ diff --git a/genai/tuning/preference_tuning_job_create.py b/genai/tuning/preference_tuning_job_create.py index 13fa05d61d0..04a77958a05 100644 --- a/genai/tuning/preference_tuning_job_create.py +++ b/genai/tuning/preference_tuning_job_create.py @@ -18,7 +18,7 @@ def create_tuning_job() -> str: import time from google import genai - from google.genai.types import HttpOptions, CreateTuningJobConfig, TuningDataset + from google.genai.types import CreateTuningJobConfig, HttpOptions, TuningDataset client = genai.Client(http_options=HttpOptions(api_version="v1")) @@ -32,7 +32,7 @@ def create_tuning_job() -> str: # Refer to https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini-use-continuous-tuning#google-gen-ai-sdk # for example to continuous tune from SFT tuned model. tuning_job = client.tunings.tune( - base_model="gemini-2.5-flash", + base_model="gemini-3.5-flash", training_dataset=training_dataset, config=CreateTuningJobConfig( tuned_model_display_name="Example tuning job", diff --git a/genai/tuning/tuning_job_create.py b/genai/tuning/tuning_job_create.py index 168b8a50c3b..a73c444f73b 100644 --- a/genai/tuning/tuning_job_create.py +++ b/genai/tuning/tuning_job_create.py @@ -18,7 +18,15 @@ def create_tuning_job(output_gcs_uri: str) -> str: import time from google import genai - from google.genai.types import HttpOptions, CreateTuningJobConfig, TuningDataset, EvaluationConfig, OutputConfig, GcsDestination, Metric + from google.genai.types import ( + CreateTuningJobConfig, + EvaluationConfig, + GcsDestination, + HttpOptions, + Metric, + OutputConfig, + TuningDataset, + ) # TODO(developer): Update and un-comment below line # output_gcs_uri = "gs://your-bucket/your-prefix" @@ -47,7 +55,7 @@ def create_tuning_job(output_gcs_uri: str) -> str: ) tuning_job = client.tunings.tune( - base_model="gemini-2.5-flash", + base_model="gemini-3.5-flash", training_dataset=training_dataset, config=CreateTuningJobConfig( tuned_model_display_name="Example tuning job", diff --git a/genai/tuning/tuning_with_checkpoints_create.py b/genai/tuning/tuning_with_checkpoints_create.py index d15db2bc819..0938dd52264 100644 --- a/genai/tuning/tuning_with_checkpoints_create.py +++ b/genai/tuning/tuning_with_checkpoints_create.py @@ -18,7 +18,15 @@ def create_with_checkpoints(output_gcs_uri: str) -> str: import time from google import genai - from google.genai.types import HttpOptions, CreateTuningJobConfig, TuningDataset, EvaluationConfig, OutputConfig, GcsDestination, Metric + from google.genai.types import ( + CreateTuningJobConfig, + EvaluationConfig, + GcsDestination, + HttpOptions, + Metric, + OutputConfig, + TuningDataset, + ) # TODO(developer): Update and un-comment below line # output_gcs_uri = "gs://your-bucket/your-prefix" @@ -47,7 +55,7 @@ def create_with_checkpoints(output_gcs_uri: str) -> str: ) tuning_job = client.tunings.tune( - base_model="gemini-2.5-flash", + base_model="gemini-3.5-flash", training_dataset=training_dataset, config=CreateTuningJobConfig( tuned_model_display_name="Example tuning job", From a0d627ebd41420c65e620f13bcd97d0a59b83def Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Thu, 18 Jun 2026 13:37:09 -0700 Subject: [PATCH 2/2] fix: ordering of libraries Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- genai/express_mode/test_express_mode_examples.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/genai/express_mode/test_express_mode_examples.py b/genai/express_mode/test_express_mode_examples.py index acfdc964240..388965f06cd 100644 --- a/genai/express_mode/test_express_mode_examples.py +++ b/genai/express_mode/test_express_mode_examples.py @@ -14,9 +14,10 @@ from unittest.mock import MagicMock, patch -import api_key_example from google.genai import types +import api_key_example + @patch("google.genai.Client") def test_api_key_example(mock_genai_client: MagicMock) -> None: