-
Notifications
You must be signed in to change notification settings - Fork 2.2k
GOOGLE_API_KEY -> GEMINI_API_KEY
#1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| "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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| "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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n", | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n", |
Style Guide References
Footnotes
-
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n", | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n", |
Style Guide References
Footnotes
-
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n", | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n", |
Style Guide References
Footnotes
-
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')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')" | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')" |
Style Guide References
Footnotes
-
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')\n", | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n", |
Style Guide References
Footnotes
-
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')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')" | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')" |
Style Guide References
Footnotes
-
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')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')" | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')" |
Style Guide References
Footnotes
-
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')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and adherence to the Google Python Style Guide (and PEP 8), please add a space around the assignment operator.1
| "GEMINI_API_KEY=userdata.get('GEMINI_API_KEY')" | |
| "GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')" |
Style Guide References
Footnotes
-
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. ↩
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
I'm all for it, but what about those who manually copied their API key under the name "GOOGLE_API_KEY"? |
|
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. |
Colab now uses
GEMINI_API_KEYfor 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.