From e8fd2d6147a6527d852d85842bf250400ec93b49 Mon Sep 17 00:00:00 2001 From: chrisheecho <10987336+chrisheecho@users.noreply.github.com> Date: Fri, 11 Jul 2025 06:25:11 -0700 Subject: [PATCH] Update authentication.md to show how to use API keys in GCP (#3042) Co-authored-by: Pascal Birchler --- docs/cli/authentication.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/cli/authentication.md b/docs/cli/authentication.md index a62284d0..41deb825 100644 --- a/docs/cli/authentication.md +++ b/docs/cli/authentication.md @@ -40,9 +40,19 @@ The Gemini CLI requires you to authenticate with Google's AI services. On initia ``` 3. **Vertex AI:** - - If not using express mode: + - Obtain your Google Cloud API key: [Get an API Key](https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=newuser) + - Set the `GOOGLE_API_KEY` environment variable. In the following methods, replace `YOUR_GOOGLE_API_KEY` with your Vertex AI API key: + - You can temporarily set these environment variables in your current shell session using the following commands: + ```bash + export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY" + ``` + - For repeated use, you can add the environment variables to your [.env file](#persisting-environment-variables-with-env-files) or your shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`). For example, the following commands add the environment variables to a `~/.bashrc` file: + ```bash + echo 'export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"' >> ~/.bashrc + source ~/.bashrc + ``` + - To use Application Default Credentials (ADC), use the following command: - Ensure you have a Google Cloud project and have enabled the Vertex AI API. - - Set up Application Default Credentials (ADC), using the following command: ```bash gcloud auth application-default login ``` @@ -59,17 +69,6 @@ The Gemini CLI requires you to authenticate with Google's AI services. On initia echo 'export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"' >> ~/.bashrc source ~/.bashrc ``` - - If using express mode: - - Set the `GOOGLE_API_KEY` environment variable. In the following methods, replace `YOUR_GOOGLE_API_KEY` with your Vertex AI API key provided by express mode: - - You can temporarily set these environment variables in your current shell session using the following commands: - ```bash - export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY" - ``` - - For repeated use, you can add the environment variables to your [.env file](#persisting-environment-variables-with-env-files) or your shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`). For example, the following commands add the environment variables to a `~/.bashrc` file: - ```bash - echo 'export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"' >> ~/.bashrc - source ~/.bashrc - ``` 4. **Cloud Shell:** - This option is only available when running in a Google Cloud Shell environment. - It automatically uses the credentials of the logged-in user in the Cloud Shell environment.