Skip to content

fix api key inconsistency and cleanup in live api quickstart#1189

Closed
knQzx wants to merge 5 commits into
google-gemini:mainfrom
knQzx:fix-live-api-notebook
Closed

fix api key inconsistency and cleanup in live api quickstart#1189
knQzx wants to merge 5 commits into
google-gemini:mainfrom
knQzx:fix-live-api-notebook

Conversation

@knQzx
Copy link
Copy Markdown

@knQzx knQzx commented Apr 4, 2026

Summary

  • fixed undefined GOOGLE_API_KEY variable — now reads from os.environ like the rest of the notebook
  • added a warning when native-audio model is selected since it doesn't support TEXT response modality
  • removed redundant client/model redefinition in the resumable sessions section

Test plan

  • verified notebook cells reference the correct api key variable
  • verified model guard prints warning for native-audio models
  • verified resumable sessions section works without redundant client init

fixes #948

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 4, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions Bot added status:awaiting review PR awaiting review from a maintainer component:quickstarts Issues/PR referencing quickstarts folder labels Apr 4, 2026
@knQzx
Copy link
Copy Markdown
Author

knQzx commented Apr 4, 2026

I have signed the CLA

@Venkaiahbabuneelam
Copy link
Copy Markdown

Hi @knQzx, Thanks for reaching out us!

Regarding you PR few checks were failing, Could you please have a look once.

Thanks

@Venkaiahbabuneelam Venkaiahbabuneelam added status:awaiting response Awaiting a response from the author and removed status:awaiting review PR awaiting review from a maintainer labels Apr 15, 2026
@knQzx
Copy link
Copy Markdown
Author

knQzx commented Apr 15, 2026

pushed nbfmt formatting only - content is identical just whitespace so notebook format should pass

notebook lint will still fail on google::inclusive_language - it flags the word native in the model id gemini-2.5-flash-native-audio-preview-09-2025 which is a product name and can't be renamed

same thing happens on main for this file - lint just doesn't surface there because it only runs on notebooks touched by a pr - 5 other notebooks in main also reference native-audio (Browser_as_a_tool, LiveAPI_plotting_and_mapping, Get_started_LiveAPI_tools, Models, Search_Grounding)

the native-audio guard is literally the fix for #948 so removing it to please the linter doesn't make sense

on your side you could add --exclude_lint=google::inclusive_language to the workflow or whitelist product ids in the wordlist

also the run is stuck in action_required - could you approve it

@github-actions
Copy link
Copy Markdown

Marking this pull request as stale since it has been open for 14 days with no activity. This PR will be closed if no further activity occurs.

@github-actions github-actions Bot added the status:stale Issue/PR is marked for closure due to inactivity label Apr 29, 2026
"client = genai.Client(api_key=GOOGLE_API_KEY)"
]
"source": "from google import genai\nfrom google.genai import types\nclient = genai.Client(api_key=os.environ.get('GOOGLE_API_KEY'))"
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run this cell in Colab, it throws a NameError: name 'GOOGLE_API_KEY' is not defined. We need to fetch the key from the environment.

@github-actions github-actions Bot removed the status:stale Issue/PR is marked for closure due to inactivity label May 6, 2026
@thorwebdev
Copy link
Copy Markdown
Collaborator

@knQzx this is great, thanks so much. Could you also update the send_client_content to use await session.send_realtime_input(text="Hello, how are you?") instead and use gemini-3.1-flash-live-preview as the default? https://ai.google.dev/gemini-api/docs/live-api/capabilities#send-text

@knQzx
Copy link
Copy Markdown
Author

knQzx commented May 7, 2026

@thorwebdev done in 161c951

  • replaced send_client_content with send_realtime_input(text=...) in all 4 call sites (Text to Text, Simple text to audio, AudioLoop.send, resumable sessions send)
  • default MODEL bumped to gemini-3.1-flash-live-preview, kept the other ids in the dropdown so users can still pick them

native-audio guard left in place - now only fires if someone manually picks the native-audio model from the dropdown

@thorwebdev
Copy link
Copy Markdown
Collaborator

Hey @knQzx I'm sorry, I should have mentioned that gemini-3.1-flash-live-preview is also a native audio model and also does not support "response_modalities": ["TEXT"], only AUDIO, so this would need a bit of a larger refactor.

Would you be up for changing every cell to AUDIO by any chance and removing the initial Text to Text cell, seeing that the only model that used to support this has since been deprecated? https://ai.google.dev/gemini-api/docs/deprecations#live-api-models

Sorry about that!

@kkorpal kkorpal requested a review from thorwebdev May 8, 2026 04:02
@thorwebdev
Copy link
Copy Markdown
Collaborator

@knQzx I've made the update here now: #1222

I really appreciate you getting started on these changes and contributing your time!

@thorwebdev thorwebdev closed this May 8, 2026
@knQzx
Copy link
Copy Markdown
Author

knQzx commented May 8, 2026

@knQzx I've made the update here now: #1222

I really appreciate you getting started on these changes and contributing your time!

thanks @thorwebdev, all good. closin this in favor of #1222 which has the broader cleanup anyway. happy to help on the next one!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:quickstarts Issues/PR referencing quickstarts folder status:awaiting response Awaiting a response from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Gemini Live API Cookbook

4 participants