@@ -20,6 +20,7 @@ export class CodeIndexConfigManager {
2020 private geminiOptions ?: { apiKey : string }
2121 private mistralOptions ?: { apiKey : string }
2222 private vercelAiGatewayOptions ?: { apiKey : string }
23+ private openRouterOptions ?: { apiKey : string ; baseUrl ?: string }
2324 private qdrantUrl ?: string = "http://localhost:6333"
2425 private qdrantApiKey ?: string
2526 private searchMinScore ?: number
@@ -71,6 +72,9 @@ export class CodeIndexConfigManager {
7172 const geminiApiKey = this . contextProxy ?. getSecret ( "codebaseIndexGeminiApiKey" ) ?? ""
7273 const mistralApiKey = this . contextProxy ?. getSecret ( "codebaseIndexMistralApiKey" ) ?? ""
7374 const vercelAiGatewayApiKey = this . contextProxy ?. getSecret ( "codebaseIndexVercelAiGatewayApiKey" ) ?? ""
75+ // Use existing openRouterApiKey from chat model settings for embeddings
76+ const openRouterApiKey = this . contextProxy ?. getSecret ( "openRouterApiKey" ) ?? ""
77+ const openRouterBaseUrl = codebaseIndexConfig . codebaseIndexEmbedderBaseUrl ?? ""
7478
7579 // Update instance variables with configuration
7680 this . codebaseIndexEnabled = codebaseIndexEnabled ?? true
@@ -108,6 +112,8 @@ export class CodeIndexConfigManager {
108112 this . embedderProvider = "mistral"
109113 } else if ( codebaseIndexEmbedderProvider === "vercel-ai-gateway" ) {
110114 this . embedderProvider = "vercel-ai-gateway"
115+ } else if ( codebaseIndexEmbedderProvider === "openrouter" ) {
116+ this . embedderProvider = "openrouter"
111117 } else {
112118 this . embedderProvider = "openai"
113119 }
@@ -129,6 +135,9 @@ export class CodeIndexConfigManager {
129135 this . geminiOptions = geminiApiKey ? { apiKey : geminiApiKey } : undefined
130136 this . mistralOptions = mistralApiKey ? { apiKey : mistralApiKey } : undefined
131137 this . vercelAiGatewayOptions = vercelAiGatewayApiKey ? { apiKey : vercelAiGatewayApiKey } : undefined
138+ this . openRouterOptions = openRouterApiKey
139+ ? { apiKey : openRouterApiKey , baseUrl : openRouterBaseUrl || undefined }
140+ : undefined
132141 }
133142
134143 /**
@@ -147,6 +156,7 @@ export class CodeIndexConfigManager {
147156 geminiOptions ?: { apiKey : string }
148157 mistralOptions ?: { apiKey : string }
149158 vercelAiGatewayOptions ?: { apiKey : string }
159+ openRouterOptions ?: { apiKey : string ; baseUrl ?: string }
150160 qdrantUrl ?: string
151161 qdrantApiKey ?: string
152162 searchMinScore ?: number
@@ -167,6 +177,8 @@ export class CodeIndexConfigManager {
167177 geminiApiKey : this . geminiOptions ?. apiKey ?? "" ,
168178 mistralApiKey : this . mistralOptions ?. apiKey ?? "" ,
169179 vercelAiGatewayApiKey : this . vercelAiGatewayOptions ?. apiKey ?? "" ,
180+ openRouterApiKey : this . openRouterOptions ?. apiKey ?? "" ,
181+ openRouterBaseUrl : this . openRouterOptions ?. baseUrl ?? "" ,
170182 qdrantUrl : this . qdrantUrl ?? "" ,
171183 qdrantApiKey : this . qdrantApiKey ?? "" ,
172184 }
@@ -192,6 +204,7 @@ export class CodeIndexConfigManager {
192204 geminiOptions : this . geminiOptions ,
193205 mistralOptions : this . mistralOptions ,
194206 vercelAiGatewayOptions : this . vercelAiGatewayOptions ,
207+ openRouterOptions : this . openRouterOptions ,
195208 qdrantUrl : this . qdrantUrl ,
196209 qdrantApiKey : this . qdrantApiKey ,
197210 searchMinScore : this . currentSearchMinScore ,
@@ -234,6 +247,11 @@ export class CodeIndexConfigManager {
234247 const qdrantUrl = this . qdrantUrl
235248 const isConfigured = ! ! ( apiKey && qdrantUrl )
236249 return isConfigured
250+ } else if ( this . embedderProvider === "openrouter" ) {
251+ const apiKey = this . openRouterOptions ?. apiKey
252+ const qdrantUrl = this . qdrantUrl
253+ const isConfigured = ! ! ( apiKey && qdrantUrl )
254+ return isConfigured
237255 }
238256 return false // Should not happen if embedderProvider is always set correctly
239257 }
@@ -269,6 +287,8 @@ export class CodeIndexConfigManager {
269287 const prevGeminiApiKey = prev ?. geminiApiKey ?? ""
270288 const prevMistralApiKey = prev ?. mistralApiKey ?? ""
271289 const prevVercelAiGatewayApiKey = prev ?. vercelAiGatewayApiKey ?? ""
290+ const prevOpenRouterApiKey = prev ?. openRouterApiKey ?? ""
291+ const prevOpenRouterBaseUrl = prev ?. openRouterBaseUrl ?? ""
272292 const prevQdrantUrl = prev ?. qdrantUrl ?? ""
273293 const prevQdrantApiKey = prev ?. qdrantApiKey ?? ""
274294
@@ -307,6 +327,8 @@ export class CodeIndexConfigManager {
307327 const currentGeminiApiKey = this . geminiOptions ?. apiKey ?? ""
308328 const currentMistralApiKey = this . mistralOptions ?. apiKey ?? ""
309329 const currentVercelAiGatewayApiKey = this . vercelAiGatewayOptions ?. apiKey ?? ""
330+ const currentOpenRouterApiKey = this . openRouterOptions ?. apiKey ?? ""
331+ const currentOpenRouterBaseUrl = this . openRouterOptions ?. baseUrl ?? ""
310332 const currentQdrantUrl = this . qdrantUrl ?? ""
311333 const currentQdrantApiKey = this . qdrantApiKey ?? ""
312334
@@ -337,6 +359,10 @@ export class CodeIndexConfigManager {
337359 return true
338360 }
339361
362+ if ( prevOpenRouterApiKey !== currentOpenRouterApiKey || prevOpenRouterBaseUrl !== currentOpenRouterBaseUrl ) {
363+ return true
364+ }
365+
340366 // Check for model dimension changes (generic for all providers)
341367 if ( prevModelDimension !== currentModelDimension ) {
342368 return true
@@ -395,6 +421,7 @@ export class CodeIndexConfigManager {
395421 geminiOptions : this . geminiOptions ,
396422 mistralOptions : this . mistralOptions ,
397423 vercelAiGatewayOptions : this . vercelAiGatewayOptions ,
424+ openRouterOptions : this . openRouterOptions ,
398425 qdrantUrl : this . qdrantUrl ,
399426 qdrantApiKey : this . qdrantApiKey ,
400427 searchMinScore : this . currentSearchMinScore ,
0 commit comments