Skip to content

Commit 0184d6e

Browse files
committed
feat: add Gemini CLI provider integration
- Add @google/gemini-cli-core dependency - Create GeminiCliHandler provider implementation using OAuth authentication - Add type definitions for gemini-cli models - Update provider exports and buildApiHandler - Add comprehensive tests for the new provider This integration allows users to authenticate with Gemini CLI using OAuth and access Gemini models through the official CLI library.
1 parent cd9e92f commit 0184d6e

File tree

9 files changed

+1494
-17
lines changed

9 files changed

+1494
-17
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@
6262
"form-data": ">=4.0.4",
6363
"bluebird": ">=3.7.2"
6464
}
65+
},
66+
"dependencies": {
67+
"@google/gemini-cli-core": "^0.2.2"
6568
}
6669
}

packages/types/src/provider-settings.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
featherlessModels,
1414
fireworksModels,
1515
geminiModels,
16+
geminiCliModels,
1617
groqModels,
1718
ioIntelligenceModels,
1819
mistralModels,
@@ -470,7 +471,7 @@ export const getApiProtocol = (provider: ProviderName | undefined, modelId?: str
470471
}
471472

472473
export const MODELS_BY_PROVIDER: Record<
473-
Exclude<ProviderName, "fake-ai" | "human-relay" | "gemini-cli" | "lmstudio" | "openai" | "ollama">,
474+
Exclude<ProviderName, "fake-ai" | "human-relay" | "lmstudio" | "openai" | "ollama">,
474475
{ id: ProviderName; label: string; models: string[] }
475476
> = {
476477
anthropic: {
@@ -515,6 +516,11 @@ export const MODELS_BY_PROVIDER: Record<
515516
label: "Google Gemini",
516517
models: Object.keys(geminiModels),
517518
},
519+
"gemini-cli": {
520+
id: "gemini-cli",
521+
label: "Google Gemini CLI",
522+
models: Object.keys(geminiCliModels),
523+
},
518524
groq: { id: "groq", label: "Groq", models: Object.keys(groqModels) },
519525
"io-intelligence": {
520526
id: "io-intelligence",
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import type { ModelInfo } from "../model.js"
2+
3+
// Gemini CLI models - using the same models as regular Gemini
4+
// The CLI provides access to the same models through OAuth authentication
5+
export type GeminiCliModelId = keyof typeof geminiCliModels
6+
7+
export const geminiCliDefaultModelId: GeminiCliModelId = "gemini-2.0-flash-001"
8+
9+
// Re-use the same model definitions as the regular Gemini provider
10+
// since Gemini CLI provides access to the same models
11+
export const geminiCliModels = {
12+
"gemini-2.0-flash-001": {
13+
maxTokens: 8192,
14+
contextWindow: 1_048_576,
15+
supportsImages: true,
16+
supportsPromptCache: true,
17+
inputPrice: 0.1,
18+
outputPrice: 0.4,
19+
cacheReadsPrice: 0.025,
20+
cacheWritesPrice: 1.0,
21+
},
22+
"gemini-1.5-flash-002": {
23+
maxTokens: 8192,
24+
contextWindow: 1_048_576,
25+
supportsImages: true,
26+
supportsPromptCache: true,
27+
inputPrice: 0.15, // This is the pricing for prompts above 128k tokens.
28+
outputPrice: 0.6,
29+
cacheReadsPrice: 0.0375,
30+
cacheWritesPrice: 1.0,
31+
tiers: [
32+
{
33+
contextWindow: 128_000,
34+
inputPrice: 0.075,
35+
outputPrice: 0.3,
36+
cacheReadsPrice: 0.01875,
37+
},
38+
{
39+
contextWindow: Infinity,
40+
inputPrice: 0.15,
41+
outputPrice: 0.6,
42+
cacheReadsPrice: 0.0375,
43+
},
44+
],
45+
},
46+
"gemini-1.5-pro-002": {
47+
maxTokens: 8192,
48+
contextWindow: 2_097_152,
49+
supportsImages: true,
50+
supportsPromptCache: false,
51+
inputPrice: 0,
52+
outputPrice: 0,
53+
},
54+
} as const satisfies Record<string, ModelInfo>

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from "./doubao.js"
88
export * from "./featherless.js"
99
export * from "./fireworks.js"
1010
export * from "./gemini.js"
11+
export * from "./gemini-cli.js"
1112
export * from "./glama.js"
1213
export * from "./groq.js"
1314
export * from "./huggingface.js"

0 commit comments

Comments
 (0)