@google/gemini-cli-core 0.21.0-nightly.20251219.70696e364 → 0.21.0-nightly.20251221.8feeffb29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/CONTRIBUTING.md +546 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +592 -0
- package/dist/docs/changelogs/latest.md +225 -0
- package/dist/docs/changelogs/preview.md +129 -0
- package/dist/docs/changelogs/releases.md +896 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +354 -0
- package/dist/docs/cli/configuration.md +780 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +108 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +63 -0
- package/dist/docs/cli/keyboard-shortcuts.md +143 -0
- package/dist/docs/cli/model-routing.md +37 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +112 -0
- package/dist/docs/cli/system-prompt.md +93 -0
- package/dist/docs/cli/telemetry.md +791 -0
- package/dist/docs/cli/themes.md +237 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials.md +83 -0
- package/dist/docs/cli/uninstall.md +47 -0
- package/dist/docs/core/index.md +101 -0
- package/dist/docs/core/memport.md +244 -0
- package/dist/docs/core/policy-engine.md +267 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +245 -0
- package/dist/docs/extensions/index.md +293 -0
- package/dist/docs/faq.md +154 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +888 -0
- package/dist/docs/get-started/configuration.md +1444 -0
- package/dist/docs/get-started/deployment.md +143 -0
- package/dist/docs/get-started/examples.md +219 -0
- package/dist/docs/get-started/gemini-3.md +116 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +806 -0
- package/dist/docs/hooks/index.md +665 -0
- package/dist/docs/hooks/reference.md +168 -0
- package/dist/docs/hooks/writing-hooks.md +1026 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +202 -0
- package/dist/docs/index.md +147 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +297 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +95 -0
- package/dist/docs/tools/mcp-server.md +1044 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +57 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +158 -0
- package/dist/google-gemini-cli-core-0.21.0-nightly.20251219.70696e364.tgz +0 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js +1 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -1
- package/dist/src/agents/introspection-agent.d.ts +23 -0
- package/dist/src/agents/introspection-agent.js +72 -0
- package/dist/src/agents/introspection-agent.js.map +1 -0
- package/dist/src/agents/introspection-agent.test.d.ts +6 -0
- package/dist/src/agents/introspection-agent.test.js +47 -0
- package/dist/src/agents/introspection-agent.test.js.map +1 -0
- package/dist/src/agents/local-executor.js +14 -12
- package/dist/src/agents/local-executor.js.map +1 -1
- package/dist/src/agents/local-executor.test.js +3 -0
- package/dist/src/agents/local-executor.test.js.map +1 -1
- package/dist/src/agents/registry.js +6 -0
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +16 -0
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/config/config.d.ts +6 -0
- package/dist/src/config/config.js +22 -0
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +59 -1
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/core/client.js +8 -4
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +20 -0
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.js +2 -2
- package/dist/src/core/clientHookTriggers.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.js +3 -3
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.js +3 -3
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
- package/dist/src/core/sessionHookTriggers.js +3 -3
- package/dist/src/core/sessionHookTriggers.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/hooks/hookEventHandler.js +10 -4
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +40 -0
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.js +12 -8
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +58 -33
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +6 -2
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +4 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +8 -1
- package/dist/src/mcp/oauth-utils.js +30 -1
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +42 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +5 -11
- package/dist/src/services/contextManager.js +20 -17
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +40 -41
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
- package/dist/src/tools/confirmation-policy.test.js +152 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -0
- package/dist/src/tools/edit.js +5 -1
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +129 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
- package/dist/src/tools/get-internal-docs.test.js +56 -0
- package/dist/src/tools/get-internal-docs.test.js.map +1 -0
- package/dist/src/tools/smart-edit.js +5 -1
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +1 -0
- package/dist/src/tools/tool-names.js +1 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/web-fetch.js +5 -1
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/write-file.js +5 -1
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/utils/environmentContext.js +3 -0
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +2 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +3 -2
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.js +1 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +3 -1
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/shell-utils.js +25 -4
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/google-gemini-cli-core-0.21.0-nightly.20251218.739c02bd6.tgz +0 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Gemini CLI authentication setup
|
|
2
|
+
|
|
3
|
+
To use Gemini CLI, you'll need to authenticate with Google. This guide helps you
|
|
4
|
+
quickly find the best way to sign in based on your account type and how you're
|
|
5
|
+
using the CLI.
|
|
6
|
+
|
|
7
|
+
For most users, we recommend starting Gemini CLI and logging in with your
|
|
8
|
+
personal Google account.
|
|
9
|
+
|
|
10
|
+
## Choose your authentication method <a id="auth-methods"></a>
|
|
11
|
+
|
|
12
|
+
Select the authentication method that matches your situation in the table below:
|
|
13
|
+
|
|
14
|
+
| User Type / Scenario | Recommended Authentication Method | Google Cloud Project Required |
|
|
15
|
+
| :--------------------------------------------------------------------- | :--------------------------------------------------------------- | :---------------------------------------------------------- |
|
|
16
|
+
| Individual Google accounts | [Login with Google](#login-google) | No, with exceptions |
|
|
17
|
+
| Organization users with a company, school, or Google Workspace account | [Login with Google](#login-google) | [Yes](#set-gcp) |
|
|
18
|
+
| AI Studio user with a Gemini API key | [Use Gemini API Key](#gemini-api) | No |
|
|
19
|
+
| Google Cloud Vertex AI user | [Vertex AI](#vertex-ai) | [Yes](#set-gcp) |
|
|
20
|
+
| [Headless mode](#headless) | [Use Gemini API Key](#gemini-api) or<br> [Vertex AI](#vertex-ai) | No (for Gemini API Key)<br> [Yes](#set-gcp) (for Vertex AI) |
|
|
21
|
+
|
|
22
|
+
### What is my Google account type?
|
|
23
|
+
|
|
24
|
+
- **Individual Google accounts:** Includes all
|
|
25
|
+
[free tier accounts](../quota-and-pricing/#free-usage) such as Gemini Code
|
|
26
|
+
Assist for individuals, as well as paid subscriptions for
|
|
27
|
+
[Google AI Pro and Ultra](https://gemini.google/subscriptions/).
|
|
28
|
+
|
|
29
|
+
- **Organization accounts:** Accounts using paid licenses through an
|
|
30
|
+
organization such as a company, school, or
|
|
31
|
+
[Google Workspace](https://workspace.google.com/). Includes
|
|
32
|
+
[Google AI Ultra for Business](https://support.google.com/a/answer/16345165)
|
|
33
|
+
subscriptions.
|
|
34
|
+
|
|
35
|
+
## (Recommended) Login with Google <a id="login-google"></a>
|
|
36
|
+
|
|
37
|
+
If you run Gemini CLI on your local machine, the simplest authentication method
|
|
38
|
+
is logging in with your Google account. This method requires a web browser on a
|
|
39
|
+
machine that can communicate with the terminal running Gemini CLI (e.g., your
|
|
40
|
+
local machine).
|
|
41
|
+
|
|
42
|
+
> **Important:** If you are a **Google AI Pro** or **Google AI Ultra**
|
|
43
|
+
> subscriber, use the Google account associated with your subscription.
|
|
44
|
+
|
|
45
|
+
To authenticate and use Gemini CLI:
|
|
46
|
+
|
|
47
|
+
1. Start the CLI:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
gemini
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2. Select **Login with Google**. Gemini CLI opens a login prompt using your web
|
|
54
|
+
browser. Follow the on-screen instructions. Your credentials will be cached
|
|
55
|
+
locally for future sessions.
|
|
56
|
+
|
|
57
|
+
### Do I need to set my Google Cloud project?
|
|
58
|
+
|
|
59
|
+
Most individual Google accounts (free and paid) don't require a Google Cloud
|
|
60
|
+
project for authentication. However, you'll need to set a Google Cloud project
|
|
61
|
+
when you meet at least one of the following conditions:
|
|
62
|
+
|
|
63
|
+
- You are using a company, school, or Google Workspace account.
|
|
64
|
+
- You are using a Gemini Code Assist license from the Google Developer Program.
|
|
65
|
+
- You are using a license from a Gemini Code Assist subscription.
|
|
66
|
+
|
|
67
|
+
For instructions, see [Set your Google Cloud Project](#set-gcp).
|
|
68
|
+
|
|
69
|
+
## Use Gemini API key <a id="gemini-api"></a>
|
|
70
|
+
|
|
71
|
+
If you don't want to authenticate using your Google account, you can use an API
|
|
72
|
+
key from Google AI Studio.
|
|
73
|
+
|
|
74
|
+
To authenticate and use Gemini CLI with a Gemini API key:
|
|
75
|
+
|
|
76
|
+
1. Obtain your API key from
|
|
77
|
+
[Google AI Studio](https://aistudio.google.com/app/apikey).
|
|
78
|
+
|
|
79
|
+
2. Set the `GEMINI_API_KEY` environment variable to your key. For example:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Replace YOUR_GEMINI_API_KEY with the key from AI Studio
|
|
83
|
+
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To make this setting persistent, see
|
|
87
|
+
[Persisting Environment Variables](#persisting-vars).
|
|
88
|
+
|
|
89
|
+
3. Start the CLI:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
gemini
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
4. Select **Use Gemini API key**.
|
|
96
|
+
|
|
97
|
+
> **Warning:** Treat API keys, especially for services like Gemini, as sensitive
|
|
98
|
+
> credentials. Protect them to prevent unauthorized access and potential misuse
|
|
99
|
+
> of the service under your account.
|
|
100
|
+
|
|
101
|
+
## Use Vertex AI <a id="vertex-ai"></a>
|
|
102
|
+
|
|
103
|
+
To use Gemini CLI with Google Cloud's Vertex AI platform, choose from the
|
|
104
|
+
following authentication options:
|
|
105
|
+
|
|
106
|
+
- A. Application Default Credentials (ADC) using `gcloud`.
|
|
107
|
+
- B. Service account JSON key.
|
|
108
|
+
- C. Google Cloud API key.
|
|
109
|
+
|
|
110
|
+
Regardless of your authentication method for Vertex AI, you'll need to set
|
|
111
|
+
`GOOGLE_CLOUD_PROJECT` to your Google Cloud project ID with the Vertex AI API
|
|
112
|
+
enabled, and `GOOGLE_CLOUD_LOCATION` to the location of your Vertex AI resources
|
|
113
|
+
or the location where you want to run your jobs.
|
|
114
|
+
|
|
115
|
+
For example:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Replace with your project ID and desired location (e.g., us-central1)
|
|
119
|
+
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
|
|
120
|
+
export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
To make any Vertex AI environment variable settings persistent, see
|
|
124
|
+
[Persisting Environment Variables](#persisting-vars).
|
|
125
|
+
|
|
126
|
+
#### A. Vertex AI - application default credentials (ADC) using `gcloud`
|
|
127
|
+
|
|
128
|
+
Consider this authentication method if you have Google Cloud CLI installed.
|
|
129
|
+
|
|
130
|
+
> **Note:** If you have previously set `GOOGLE_API_KEY` or `GEMINI_API_KEY`, you
|
|
131
|
+
> must unset them to use ADC:
|
|
132
|
+
>
|
|
133
|
+
> ```bash
|
|
134
|
+
> unset GOOGLE_API_KEY GEMINI_API_KEY
|
|
135
|
+
> ```
|
|
136
|
+
|
|
137
|
+
1. Verify you have a Google Cloud project and Vertex AI API is enabled.
|
|
138
|
+
|
|
139
|
+
2. Log in to Google Cloud:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
gcloud auth application-default login
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
3. [Configure your Google Cloud Project](#set-gcp).
|
|
146
|
+
|
|
147
|
+
4. Start the CLI:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
gemini
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
5. Select **Vertex AI**.
|
|
154
|
+
|
|
155
|
+
#### B. Vertex AI - service account JSON key
|
|
156
|
+
|
|
157
|
+
Consider this method of authentication in non-interactive environments, CI/CD
|
|
158
|
+
pipelines, or if your organization restricts user-based ADC or API key creation.
|
|
159
|
+
|
|
160
|
+
> **Note:** If you have previously set `GOOGLE_API_KEY` or `GEMINI_API_KEY`, you
|
|
161
|
+
> must unset them:
|
|
162
|
+
>
|
|
163
|
+
> ```bash
|
|
164
|
+
> unset GOOGLE_API_KEY GEMINI_API_KEY
|
|
165
|
+
> ```
|
|
166
|
+
|
|
167
|
+
1. [Create a service account and key](https://cloud.google.com/iam/docs/keys-create-delete)
|
|
168
|
+
and download the provided JSON file. Assign the "Vertex AI User" role to the
|
|
169
|
+
service account.
|
|
170
|
+
|
|
171
|
+
2. Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the JSON
|
|
172
|
+
file's absolute path. For example:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Replace /path/to/your/keyfile.json with the actual path
|
|
176
|
+
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/keyfile.json"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
3. [Configure your Google Cloud Project](#set-gcp).
|
|
180
|
+
|
|
181
|
+
4. Start the CLI:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
gemini
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
5. Select **Vertex AI**.
|
|
188
|
+
> **Warning:** Protect your service account key file as it gives access to
|
|
189
|
+
> your resources.
|
|
190
|
+
|
|
191
|
+
#### C. Vertex AI - Google Cloud API key
|
|
192
|
+
|
|
193
|
+
1. Obtain a Google Cloud API key:
|
|
194
|
+
[Get an API Key](https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=newuser).
|
|
195
|
+
|
|
196
|
+
2. Set the `GOOGLE_API_KEY` environment variable:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Replace YOUR_GOOGLE_API_KEY with your Vertex AI API key
|
|
200
|
+
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
> **Note:** If you see errors like
|
|
204
|
+
> `"API keys are not supported by this API..."`, your organization might
|
|
205
|
+
> restrict API key usage for this service. Try the other Vertex AI
|
|
206
|
+
> authentication methods instead.
|
|
207
|
+
|
|
208
|
+
3. [Configure your Google Cloud Project](#set-gcp).
|
|
209
|
+
|
|
210
|
+
4. Start the CLI:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
gemini
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
5. Select **Vertex AI**.
|
|
217
|
+
|
|
218
|
+
## Set your Google Cloud project <a id="set-gcp"></a>
|
|
219
|
+
|
|
220
|
+
> **Important:** Most individual Google accounts (free and paid) don't require a
|
|
221
|
+
> Google Cloud project for authentication.
|
|
222
|
+
|
|
223
|
+
When you sign in using your Google account, you may need to configure a Google
|
|
224
|
+
Cloud project for Gemini CLI to use. This applies when you meet at least one of
|
|
225
|
+
the following conditions:
|
|
226
|
+
|
|
227
|
+
- You are using a Company, School, or Google Workspace account.
|
|
228
|
+
- You are using a Gemini Code Assist license from the Google Developer Program.
|
|
229
|
+
- You are using a license from a Gemini Code Assist subscription.
|
|
230
|
+
|
|
231
|
+
To configure Gemini CLI to use a Google Cloud project, do the following:
|
|
232
|
+
|
|
233
|
+
1. [Find your Google Cloud Project ID](https://support.google.com/googleapi/answer/7014113).
|
|
234
|
+
|
|
235
|
+
2. [Enable the Gemini for Cloud API](https://cloud.google.com/gemini/docs/discover/set-up-gemini#enable-api).
|
|
236
|
+
|
|
237
|
+
3. [Configure necessary IAM access permissions](https://cloud.google.com/gemini/docs/discover/set-up-gemini#grant-iam).
|
|
238
|
+
|
|
239
|
+
4. Configure your environment variables. Set either the `GOOGLE_CLOUD_PROJECT`
|
|
240
|
+
or `GOOGLE_CLOUD_PROJECT_ID` variable to the project ID to use with Gemini
|
|
241
|
+
CLI. Gemini CLI checks for `GOOGLE_CLOUD_PROJECT` first, then falls back to
|
|
242
|
+
`GOOGLE_CLOUD_PROJECT_ID`.
|
|
243
|
+
|
|
244
|
+
For example, to set the `GOOGLE_CLOUD_PROJECT_ID` variable:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Replace YOUR_PROJECT_ID with your actual Google Cloud project ID
|
|
248
|
+
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
To make this setting persistent, see
|
|
252
|
+
[Persisting Environment Variables](#persisting-vars).
|
|
253
|
+
|
|
254
|
+
## Persisting environment variables <a id="persisting-vars"></a>
|
|
255
|
+
|
|
256
|
+
To avoid setting environment variables for every terminal session, you can
|
|
257
|
+
persist them with the following methods:
|
|
258
|
+
|
|
259
|
+
1. **Add your environment variables to your shell configuration file:** Append
|
|
260
|
+
the `export ...` commands to your shell's startup file (e.g., `~/.bashrc`,
|
|
261
|
+
`~/.zshrc`, or `~/.profile`) and reload your shell (e.g.,
|
|
262
|
+
`source ~/.bashrc`).
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Example for .bashrc
|
|
266
|
+
echo 'export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"' >> ~/.bashrc
|
|
267
|
+
source ~/.bashrc
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
> **Warning:** Be aware that when you export API keys or service account
|
|
271
|
+
> paths in your shell configuration file, any process launched from that
|
|
272
|
+
> shell can read them.
|
|
273
|
+
|
|
274
|
+
2. **Use a `.env` file:** Create a `.gemini/.env` file in your project
|
|
275
|
+
directory or home directory. Gemini CLI automatically loads variables from
|
|
276
|
+
the first `.env` file it finds, searching up from the current directory,
|
|
277
|
+
then in `~/.gemini/.env` or `~/.env`. `.gemini/.env` is recommended.
|
|
278
|
+
|
|
279
|
+
Example for user-wide settings:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
mkdir -p ~/.gemini
|
|
283
|
+
cat >> ~/.gemini/.env <<'EOF'
|
|
284
|
+
GOOGLE_CLOUD_PROJECT="your-project-id"
|
|
285
|
+
# Add other variables like GEMINI_API_KEY as needed
|
|
286
|
+
EOF
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Variables are loaded from the first file found, not merged.
|
|
290
|
+
|
|
291
|
+
## Running in Google Cloud environments <a id="cloud-env"></a>
|
|
292
|
+
|
|
293
|
+
When running Gemini CLI within certain Google Cloud environments, authentication
|
|
294
|
+
is automatic.
|
|
295
|
+
|
|
296
|
+
In a Google Cloud Shell environment, Gemini CLI typically authenticates
|
|
297
|
+
automatically using your Cloud Shell credentials. In Compute Engine
|
|
298
|
+
environments, Gemini CLI automatically uses Application Default Credentials
|
|
299
|
+
(ADC) from the environment's metadata server.
|
|
300
|
+
|
|
301
|
+
If automatic authentication fails, use one of the interactive methods described
|
|
302
|
+
on this page.
|
|
303
|
+
|
|
304
|
+
## Running in headless mode <a id="headless"></a>
|
|
305
|
+
|
|
306
|
+
[Headless mode](../cli/headless) will use your existing authentication method,
|
|
307
|
+
if an existing authentication credential is cached.
|
|
308
|
+
|
|
309
|
+
If you have not already logged in with an authentication credential, you must
|
|
310
|
+
configure authentication using environment variables:
|
|
311
|
+
|
|
312
|
+
- [Use Gemini API Key](#gemini-api)
|
|
313
|
+
- [Vertex AI](#vertex-ai)
|
|
314
|
+
|
|
315
|
+
## What's next?
|
|
316
|
+
|
|
317
|
+
Your authentication method affects your quotas, pricing, Terms of Service, and
|
|
318
|
+
privacy notices. Review the following pages to learn more:
|
|
319
|
+
|
|
320
|
+
- [Gemini CLI: Quotas and Pricing](../quota-and-pricing.md).
|
|
321
|
+
- [Gemini CLI: Terms of Service and Privacy Notice](../tos-privacy.md).
|