You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add version compatibility table showing v6, v5, and v4 support
- Update installation commands with correct version specifiers
- Clarify authentication options (6 auth types, optional with oauth-personal default)
- Move verbose/logger to model settings section
- Add Gemini 3 model documentation
description: Learn how to use the Gemini CLI community provider to access Google's Gemini models through the official CLI/SDK.
3
+
description: Learn how to use the Gemini CLI provider to access Google's Gemini models.
4
4
---
5
5
6
6
# Gemini CLI Provider
7
7
8
-
The [ai-sdk-provider-gemini-cli](https://github.com/ben-vargas/ai-sdk-provider-gemini-cli) community provider enables using Google's Gemini models through the [@google/gemini-cli-core](https://www.npmjs.com/package/@google/gemini-cli-core) library and Google Cloud Code endpoints. While it works with both Gemini Code Assist (GCA) licenses and API key authentication, it's particularly useful for developers who want to use their existing GCA subscription rather than paid use API keys.
8
+
The [ai-sdk-provider-gemini-cli](https://github.com/ben-vargas/ai-sdk-provider-gemini-cli) community provider enables using Google's Gemini models through the [@google/gemini-cli-core](https://www.npmjs.com/package/@google/gemini-cli-core) library. It's useful for developers who want to use their existing Gemini Code Assist subscription or API key authentication.
9
9
10
10
## Version Compatibility
11
11
12
-
The Gemini CLI provider supports both AI SDK v4 and v5-beta:
12
+
| Provider Version | AI SDK Version | NPM Tag | Status |
-`'oauth-personal'`: Uses existing Gemini CLI credentials from `~/.gemini/oauth_creds.json`
85
-
-`'api-key'`: Standard AI SDK API key authentication (recommended)
86
-
-`'gemini-api-key'`: Gemini-specific API key authentication (identical to `'api-key'`)
62
+
// Vertex AI authentication
63
+
const gemini =createGeminiProvider({
64
+
authType: 'vertex-ai',
65
+
vertexAI: {
66
+
projectId: 'my-project',
67
+
location: 'us-central1',
68
+
},
69
+
});
87
70
88
-
Note: `'api-key'` and `'gemini-api-key'` are functionally identical. We recommend using `'api-key'` for consistency with AI SDK standards, but both options map to the same Gemini authentication method internally.
71
+
// Google Auth Library
72
+
const gemini =createGeminiProvider({
73
+
authType: 'google-auth-library',
74
+
googleAuth: myGoogleAuthInstance,
75
+
});
76
+
```
89
77
90
-
-**apiKey**_string_
78
+
Authentication options:
91
79
92
-
Required when using API key authentication. Your Gemini API key from [Google AI Studio](https://aistudio.google.com/apikey).
prompt: 'Write a story about a robot learning to paint',
249
-
});
250
-
251
-
// Both v4 and v5 use the same streaming API
252
-
forawait (const chunk ofresult.textStream) {
253
-
process.stdout.write(chunk);
254
-
}
255
-
```
256
-
257
-
For more examples and features, including tool usage and multimodal input, see the [provider documentation](https://github.com/ben-vargas/ai-sdk-provider-gemini-cli).
258
-
259
-
## Model Parameters
260
-
261
-
You can configure model behavior with standard AI SDK parameters:
262
-
263
-
```ts
264
-
// AI SDK v4
265
-
const model =gemini('gemini-2.5-pro', {
266
-
temperature: 0.7, // Controls randomness (0-2)
267
-
maxTokens: 1000, // Maximum output tokens (defaults to 65536)
268
-
topP: 0.95, // Nucleus sampling threshold
269
-
});
270
-
271
-
// AI SDK v5-beta
272
-
const model =gemini('gemini-2.5-pro', {
273
-
temperature: 0.7, // Controls randomness (0-2)
274
-
maxOutputTokens: 1000, // Maximum output tokens (defaults to 65536)
275
-
topP: 0.95, // Nucleus sampling threshold
276
-
});
277
-
```
278
-
279
-
<Note>
280
-
In AI SDK v5-beta, the `maxTokens` parameter has been renamed to
281
-
`maxOutputTokens`. Make sure to use the correct parameter name for your
282
-
version.
283
-
</Note>
284
-
285
-
## Limitations
286
-
287
-
- Requires Node.js ≥ 18
288
-
- OAuth authentication requires the Gemini CLI to be installed globally
289
-
- Image URLs not supported (use base64-encoded images)
290
-
- Very strict character length constraints in schemas may be challenging
291
-
- Some AI SDK parameters not supported: `frequencyPenalty`, `presencePenalty`, `seed`
292
-
- Only function tools supported (no provider-defined tools)
163
+
2. Set it as an environment variable: `export GEMINI_API_KEY="YOUR_API_KEY"`
0 commit comments