Skip to content

Commit 41d96f1

Browse files
committed
feat: add Gemini-CLI provider support
- Add GeminiCliHandler class to interface with gemini CLI tool - Implement OAuth authentication flow handling - Add telemetry collection for token usage tracking - Create UI component for provider configuration - Add comprehensive test coverage for the provider - Support both free and paid (project ID) usage modes Fixes #6043
1 parent b1bc085 commit 41d96f1

File tree

10 files changed

+772
-0
lines changed

10 files changed

+772
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import type { ModelInfo } from "../model.js"
2+
3+
// Gemini-CLI specific model IDs
4+
export type GeminiCliModelId = keyof typeof geminiCliModels
5+
6+
export const geminiCliDefaultModelId: GeminiCliModelId = "gemini-2.0-flash-001"
7+
8+
// Models available through Gemini CLI
9+
export const geminiCliModels = {
10+
"gemini-2.0-flash-001": {
11+
maxTokens: 8192,
12+
contextWindow: 1_048_576,
13+
supportsImages: true,
14+
supportsPromptCache: true,
15+
inputPrice: 0.1,
16+
outputPrice: 0.4,
17+
cacheReadsPrice: 0.025,
18+
cacheWritesPrice: 1.0,
19+
},
20+
"gemini-1.5-flash-002": {
21+
maxTokens: 8192,
22+
contextWindow: 1_048_576,
23+
supportsImages: true,
24+
supportsPromptCache: true,
25+
inputPrice: 0.15,
26+
outputPrice: 0.6,
27+
cacheReadsPrice: 0.0375,
28+
cacheWritesPrice: 1.0,
29+
tiers: [
30+
{
31+
contextWindow: 128_000,
32+
inputPrice: 0.075,
33+
outputPrice: 0.3,
34+
cacheReadsPrice: 0.01875,
35+
},
36+
{
37+
contextWindow: Infinity,
38+
inputPrice: 0.15,
39+
outputPrice: 0.6,
40+
cacheReadsPrice: 0.0375,
41+
},
42+
],
43+
},
44+
"gemini-1.5-pro-002": {
45+
maxTokens: 8192,
46+
contextWindow: 2_097_152,
47+
supportsImages: true,
48+
supportsPromptCache: false,
49+
inputPrice: 0,
50+
outputPrice: 0,
51+
},
52+
} 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
@@ -4,6 +4,7 @@ export * from "./chutes.js"
44
export * from "./claude-code.js"
55
export * from "./deepseek.js"
66
export * from "./gemini.js"
7+
export * from "./gemini-cli.js"
78
export * from "./glama.js"
89
export * from "./groq.js"
910
export * from "./lite-llm.js"

src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
ChutesHandler,
2929
LiteLLMHandler,
3030
ClaudeCodeHandler,
31+
GeminiCliHandler,
3132
} from "./providers"
3233

3334
export interface SingleCompletionHandler {
@@ -85,6 +86,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
8586
return new LmStudioHandler(options)
8687
case "gemini":
8788
return new GeminiHandler(options)
89+
case "gemini-cli":
90+
return new GeminiCliHandler(options)
8891
case "openai-native":
8992
return new OpenAiNativeHandler(options)
9093
case "deepseek":

0 commit comments

Comments
 (0)