@@ -789,7 +789,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
789789 // to OpenRouter it would be showing outdated model info
790790 // if we hadn't retrieved the latest at this point
791791 // (see normalizeApiConfiguration > openrouter).
792- getOpenRouterModels ( ) . then ( async ( openRouterModels ) => {
792+ const { apiConfiguration : currentApiConfig } = await this . getState ( )
793+ getOpenRouterModels ( currentApiConfig ) . then ( async ( openRouterModels ) => {
793794 if ( Object . keys ( openRouterModels ) . length > 0 ) {
794795 await fs . writeFile (
795796 path . join ( cacheDir , GlobalFileNames . openRouterModels ) ,
@@ -1038,8 +1039,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10381039 case "resetState" :
10391040 await this . resetState ( )
10401041 break
1041- case "refreshOpenRouterModels" :
1042- const openRouterModels = await getOpenRouterModels ( )
1042+ case "refreshOpenRouterModels" : {
1043+ const { apiConfiguration : configForRefresh } = await this . getState ( )
1044+ const openRouterModels = await getOpenRouterModels ( configForRefresh )
10431045
10441046 if ( Object . keys ( openRouterModels ) . length > 0 ) {
10451047 const cacheDir = await this . ensureCacheDirectoryExists ( )
@@ -1051,6 +1053,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10511053 }
10521054
10531055 break
1056+ }
10541057 case "refreshGlamaModels" :
10551058 const glamaModels = await getGlamaModels ( )
10561059
@@ -2154,7 +2157,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
21542157 async handleOpenRouterCallback ( code : string ) {
21552158 let apiKey : string
21562159 try {
2157- const response = await axios . post ( "https://openrouter.ai/api/v1/auth/keys" , { code } )
2160+ const { apiConfiguration } = await this . getState ( )
2161+ const baseUrl = apiConfiguration . openRouterBaseUrl || "https://openrouter.ai/api/v1"
2162+ // Extract the base domain for the auth endpoint
2163+ const baseUrlDomain = baseUrl . match ( / ^ ( h t t p s ? : \/ \/ [ ^ \/ ] + ) / ) ?. [ 1 ] || "https://openrouter.ai"
2164+ const response = await axios . post ( `${ baseUrlDomain } /api/v1/auth/keys` , { code } )
21582165 if ( response . data && response . data . key ) {
21592166 apiKey = response . data . key
21602167 } else {
0 commit comments