Skip to content

Conversation

@markmcd
Copy link
Member

@markmcd markmcd commented Oct 31, 2025

Colab now uses GEMINI_API_KEY for keys imported from AI Studio, along with the default across the docs on ai.google.dev.

This brings the cookbook in line with the same defaults so users don't need to figure out they have to rename the key.

Colab now uses `GEMINI_API_KEY` for keys imported from AI Studio, along
with the default across the docs on ai.google.dev.

This brings the cookbook in line with the same defaults.
@markmcd markmcd requested a review from Giom-V October 31, 2025 09:28
@review-notebook-app
Copy link

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:examples Issues/PR referencing examples folder component:quickstarts Issues/PR referencing quickstarts folder labels Oct 31, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @markmcd, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request standardizes the API key variable name used in a wide array of Colab notebooks from GOOGLE_API_KEY to GEMINI_API_KEY. This update ensures that the examples are consistent with current best practices and official documentation, making it easier for users to get started without encountering naming discrepancies.

Highlights

  • API Key Renaming: The primary change involves updating all instances of GOOGLE_API_KEY to GEMINI_API_KEY across numerous Colab notebooks.
  • Documentation Alignment: This change aligns the API key naming convention with the latest standards used in AI Studio and ai.google.dev documentation, ensuring consistency.
  • Improved User Experience: Users will no longer need to manually rename their API keys when importing from AI Studio, simplifying the setup process for these notebooks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great step towards standardizing the API key name to GEMINI_API_KEY across all notebooks, which significantly improves consistency. The changes are mostly correct. I've identified a couple of critical issues in one notebook that would cause a NameError, and several minor style inconsistencies related to spacing that should be addressed to align with the repository's style guide.

"from google import genai\n",
"from google.genai import types\n",
"client = genai.Client(api_key=GOOGLE_API_KEY)"
"client = genai.Client(api_key=GEMINI_API_KEY)"
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The variable GEMINI_API_KEY is not defined in this cell's scope, which will cause a NameError. A previous cell sets the GEMINI_API_KEY environment variable. You can initialize the client without arguments, and it will automatically use the key from the environment variable.

Suggested change
"client = genai.Client(api_key=GEMINI_API_KEY)"
"client = genai.Client()"

"MODEL = \"gemini-live-2.5-flash-preview\"\n",
"\n",
"client = genai.Client(api_key=GOOGLE_API_KEY)\n",
"client = genai.Client(api_key=GEMINI_API_KEY)\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The variable GEMINI_API_KEY is not defined in this cell's scope, which will cause a NameError. A previous cell sets the GEMINI_API_KEY environment variable. You can initialize the client without arguments, and it will automatically use the key from the environment variable.

Suggested change
"client = genai.Client(api_key=GEMINI_API_KEY)\n",
"client = genai.Client()\n",

"\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"client = genai.Client(api_key=GOOGLE_API_KEY)"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n",

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"source": [
"from google.colab import userdata\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n",

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"from google.colab import userdata\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"genai.configure(api_key=GOOGLE_API_KEY)"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n",

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"from google.colab import userdata\n",
"\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')"

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"client = genai.Client(api_key=GOOGLE_API_KEY)"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n",
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n",

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"import os\n",
"\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')"

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"from google.colab import userdata\n",
"\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')"

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

"source": [
"from google.colab import userdata\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')"
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1

Suggested change
"GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')"
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')"

Style Guide References

Footnotes

  1. The repository's style guide refers to the Google Python Style Guide, which recommends using spaces around operators for better readability. This is a standard convention in Python.

@gemini-code-assist
Copy link
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@Giom-V
Copy link
Collaborator

Giom-V commented Oct 31, 2025

I'm all for it, but what about those who manually copied their API key under the name "GOOGLE_API_KEY"?

@Giom-V
Copy link
Collaborator

Giom-V commented Oct 31, 2025

I think we should add a "breaking change" on the main readme (and maybe remove the migration guide now that it's been nearly a year). Also I think CONTRIBUTING.md and .gemini/styleguide.md should also be updated accordingly. And maybe the authentication notebook should also be updated with explanations about the auto-import feature.

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

Labels

component:examples Issues/PR referencing examples folder component:quickstarts Issues/PR referencing quickstarts folder status:awaiting review PR awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants