Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
3342024
fix: update client.interactions.create config parameter to generation…
Giom-V Jun 22, 2026
7567494
fix: modernize legacy response references to interaction parts in Get…
Giom-V Jun 22, 2026
c214353
fix: move response_modalities to top level across quickstarts and ens…
Giom-V Jun 22, 2026
0b0ad25
fix: correct response_modalities, audio sample rates, and generation_…
Giom-V Jun 23, 2026
cb59e72
fix: apply round 2 runtime corrections across Error_handling, Nano_Ba…
Giom-V Jun 23, 2026
bfc29a0
fix: apply round 3 syntax corrections across TTS, thinking, managed a…
Giom-V Jun 23, 2026
083530e
fix: apply round 4 Pydantic corrections across Nano Banana, Search Gr…
Giom-V Jun 23, 2026
a4e7230
fix: apply round 6 comprehensive Pydantic and syntax corrections acro…
Giom-V Jun 23, 2026
b6b59ca
fix: apply round 8 comprehensive Pydantic PartParam and LiveClient to…
Giom-V Jun 23, 2026
a786f60
fix: apply round 10 Pydantic LiveClient config and tool corrections a…
Giom-V Jun 23, 2026
38b8648
fix: apply round 11 Pydantic Content wrapper and TTS generation_confi…
Giom-V Jun 23, 2026
10dddc2
fix: apply round 12 Pydantic Part dict serialization and TTS Generate…
Giom-V Jun 23, 2026
0047643
fix: apply round 14 Pydantic LiveClient tool declarations and Generat…
Giom-V Jun 23, 2026
0645bc1
fix: apply round 16 GenerateContentConfig syntax resolutions and add …
Giom-V Jun 23, 2026
62b93f2
fix: resolve final syntax errors and apply nbfmt formatting across qu…
Giom-V Jun 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion quickstarts/Error_handling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"from google.colab import userdata\n",
"\n",
"GEMINI_API_KEY = userdata.get(\"GEMINI_API_KEY\")\n",
"client = genai.Client(api_key=GEMINI_API_KEY)"
"client = genai.Client(api_key=GEMINI_API_KEY)",
"\nMODEL_ID = \"gemini-3.5-flash\"\n"
]
},
{
Expand Down Expand Up @@ -156,6 +157,7 @@
}
],
"source": [
"from google.genai import types\n",
"retry_options = types.HttpRetryOptions(\n",
" attempts=5,\n",
" initial_delay=2.0,\n",
Expand Down
209 changes: 108 additions & 101 deletions quickstarts/Get_Started_Nano_Banana.ipynb

Large diffs are not rendered by default.

47 changes: 23 additions & 24 deletions quickstarts/Get_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
}
],
"source": [
"interaction.output_text"
"interaction.steps[-1].content[0].text"
]
},
{
Expand Down Expand Up @@ -353,7 +353,7 @@
],
"source": [
"# Access the text response with output_text:\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -405,7 +405,7 @@
" system_instruction=system_instruction,\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -486,7 +486,7 @@
" },\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -660,7 +660,7 @@
" ],\n",
")\n",
"\n",
"display(Markdown(interaction.output_text))"
"display(Markdown(interaction.steps[-1].content[0].text))"
]
},
{
Expand Down Expand Up @@ -740,7 +740,7 @@
" ],\n",
")\n",
"\n",
"display(Markdown(interaction.output_text))"
"display(Markdown(interaction.steps[-1].content[0].text))"
]
},
{
Expand Down Expand Up @@ -799,7 +799,6 @@
" {\n",
" \"type\": \"image\",\n",
" \"mime_type\": \"image/jpeg\",\n",
" \"aspect_ratio\": \"16:9\",\n",
" \"image_size\": \"2K\"\n",
" },\n",
" ],\n",
Expand All @@ -815,7 +814,7 @@
" display(Markdown(content.text))\n",
"\n",
"# Or more simply:\n",
"# display(Image(data=base64.b64decode(interaction.output_image.data)))"
"# display(Image(data=base64.b64decode(interaction.steps[-1].content[0].data)))"
]
},
{
Expand Down Expand Up @@ -870,7 +869,7 @@
" input=\"Why do we always see the same side of the Moon? Keep it short.\",\n",
")\n",
"\n",
"Markdown(turn_1.output_text)\n"
"Markdown(turn_1.steps[-1].content[0].text)\n"
]
},
{
Expand Down Expand Up @@ -909,7 +908,7 @@
" previous_interaction_id=turn_1.id,\n",
")\n",
"\n",
"Markdown(turn_2.output_text)\n"
"Markdown(turn_2.steps[-1].content[0].text)\n"
]
},
{
Expand Down Expand Up @@ -951,7 +950,7 @@
" previous_interaction_id=turn_2.id,\n",
")\n",
"\n",
"display(Image(data=base64.b64decode(turn_3.output_image.data)))"
"display(Image(data=base64.b64decode(turn_3.steps[-1].content[0].data)))"
]
},
{
Expand Down Expand Up @@ -1030,7 +1029,7 @@
" }]\n",
")\n",
"\n",
"Markdown(resumed.output_text)"
"Markdown(resumed.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -1060,7 +1059,7 @@
" previous_interaction_id=resumed.id,\n",
")\n",
"\n",
"Markdown(resumed_2.output_text)\n"
"Markdown(resumed_2.steps[-1].content[0].text)\n"
]
},
{
Expand Down Expand Up @@ -1122,7 +1121,7 @@
" },\n",
")\n",
"\n",
"json.loads(interaction.output_text)"
"json.loads(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -1302,7 +1301,7 @@
" input=\"Compose a sonnet about a cat riding a bicycle through a field of sunflowers.\",\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -1384,7 +1383,7 @@
" ],\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -1441,7 +1440,7 @@
" ],\n",
")\n",
"\n",
"display(Markdown(interaction.output_text))"
"display(Markdown(interaction.steps[-1].content[0].text))"
]
},
{
Expand Down Expand Up @@ -1495,7 +1494,7 @@
" ],\n",
")\n",
"\n",
"display(Markdown(interaction.output_text))"
"display(Markdown(interaction.steps[-1].content[0].text))"
]
},
{
Expand Down Expand Up @@ -1563,7 +1562,7 @@
" ],\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -1721,7 +1720,7 @@
" ],\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -1845,7 +1844,7 @@
" tools=[{\"type\": \"google_search\"}],\n",
")\n",
"\n",
"display(Markdown(interaction.output_text))\n"
"display(Markdown(interaction.steps[-1].content[0].text))\n"
]
},
{
Expand Down Expand Up @@ -2055,7 +2054,7 @@
" tools=[{\"type\": \"google_maps\"}],\n",
")\n",
"\n",
"Markdown(interaction.output_text)\n"
"Markdown(interaction.steps[-1].content[0].text)\n"
]
},
{
Expand Down Expand Up @@ -2119,7 +2118,7 @@
" ],\n",
")\n",
"\n",
"Markdown(interaction.output_text)"
"Markdown(interaction.steps[-1].content[0].text)"
]
},
{
Expand Down Expand Up @@ -2172,7 +2171,7 @@
" input=prompt,\n",
" tools=[{\"type\": \"url_context\"}],\n",
" )\n",
" display(Markdown(interaction.output_text))\n",
" display(Markdown(interaction.steps[-1].content[0].text))\n",
"except Exception as e:\n",
" print(f\"url_context tool error: {e}\")\n",
" print(\"Note: url_context may not be available with all models.\")"
Expand Down
22 changes: 9 additions & 13 deletions quickstarts/Get_started_Lyria.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@
" model=MODEL_ID,\n",
" input=prompt,\n",
" response_modalities=['audio', 'text'] # To get both lyrics and the song, this is the default setting\n",
" )\n",
")"
")\n"
]
},
{
Expand Down Expand Up @@ -242,8 +241,8 @@
}
],
"source": [
"for part in response.parts:\n",
" print(part)"
"for step in interaction.steps:\n",
" print(step)"
]
},
{
Expand Down Expand Up @@ -277,7 +276,7 @@
],
"source": [
"# Lyrics\n",
"print(response.parts[0].text)"
"print([c.text for s in interaction.steps for c in s.content if getattr(c, 'text', None)][0])"
]
},
{
Expand Down Expand Up @@ -316,9 +315,9 @@
],
"source": [
"from IPython.display import display, Audio\n",
"audio_bytes = response.parts[-1].inline_data.data\n",
"audio_bytes = [c.data for s in interaction.steps for c in s.content if getattr(c, 'data', None)][0]\n",
"\n",
"display(Audio(audio_bytes))"
"display(Audio(audio_bytes, rate=24000))"
]
},
{
Expand Down Expand Up @@ -439,7 +438,7 @@
}
],
"source": [
"display_lyria_response(response)"
"display_lyria_response(interaction)"
]
},
{
Expand Down Expand Up @@ -949,15 +948,12 @@
}
],
"source": [
"prompt = \"A serious moment in a Shakespeare play\" # @param {type:\"string\"}\n",
"\n",
"prompt = \"A serious moment in a Shakespeare play\" # @param {type:\"string\"}\n\n",
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=prompt,\n",
" response_modalities=['audio', 'text']\n",
" )\n",
")\n",
"\n",
")\n\n",
"display_lyria_response(interaction)"
]
},
Expand Down
29 changes: 11 additions & 18 deletions quickstarts/Get_started_TTS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=\"Say 'hello, my name is Gemini!'\",\n",
" config={\n",
" \"response_modalities\": [\"AUDIO\"],\n",
" \"speech_config\": types.SpeechConfig(\n",
" response_modalities=[\"audio\"],\n",
" generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" voice_config=types.VoiceConfig(\n",
" prebuilt_voice_config=types.PrebuiltVoiceConfig(\n",
" voice_name=\"Kore\"\n",
" )\n",
" )\n",
" ),\n",
" },\n",
" ),\n",
")"
]
},
Expand Down Expand Up @@ -368,8 +368,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=\"Say cheerfully: Have a wonderful day!\",\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" voice_config=types.VoiceConfig(\n",
" prebuilt_voice_config=types.PrebuiltVoiceConfig(\n",
Expand Down Expand Up @@ -481,8 +480,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=prompt,\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" voice_config=types.VoiceConfig(\n",
" prebuilt_voice_config=types.PrebuiltVoiceConfig(\n",
Expand Down Expand Up @@ -563,8 +561,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input='[whispers] By the pricking of my thumbs... [gasp] Something wicked this way comes. [shouting] Run!',\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" voice_config=types.VoiceConfig(\n",
" prebuilt_voice_config=types.PrebuiltVoiceConfig(\n",
Expand Down Expand Up @@ -622,8 +619,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input='Say in a spooky whisper: \"By the pricking of my thumbs... Something wicked this way comes\"',\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" voice_config=types.VoiceConfig(\n",
" prebuilt_voice_config=types.PrebuiltVoiceConfig(\n",
Expand Down Expand Up @@ -687,8 +683,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=prompt,\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" multi_speaker_voice_config=types.MultiSpeakerVoiceConfig(\n",
" speaker_voice_configs=[\n",
Expand Down Expand Up @@ -763,8 +758,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=prompt,\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" multi_speaker_voice_config=types.MultiSpeakerVoiceConfig(\n",
" speaker_voice_configs=[\n",
Expand Down Expand Up @@ -873,8 +867,7 @@
"interaction = client.interactions.create(\n",
" model=MODEL_ID,\n",
" input=transcript,\n",
" config=types.GenerateContentConfig(\n",
" response_modalities=[\"AUDIO\"],\n",
" response_modalities=[\"audio\"],\n generation_config=types.GenerateContentConfig(\n",
" speech_config=types.SpeechConfig(\n",
" multi_speaker_voice_config=types.MultiSpeakerVoiceConfig(\n",
" speaker_voice_configs=[\n",
Expand Down
Loading
Loading