@@ -130,6 +130,12 @@ export class ClineProvider implements vscode.WebviewViewProvider {
130130 this . workspaceTracker = new WorkspaceTracker ( this )
131131 this . mcpHub = new McpHub ( this )
132132 this . configManager = new ConfigManager ( this . context )
133+
134+ this . context . subscriptions . push (
135+ vscode . commands . registerCommand ( "roo-cline.setApiConfiguration" , async ( config : ApiConfiguration ) => {
136+ await this . handleApiConfigurationUpdate ( config )
137+ } ) ,
138+ )
133139 }
134140
135141 /*
@@ -508,6 +514,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
508514 case "apiConfiguration" :
509515 if ( message . apiConfiguration ) {
510516 await this . updateApiConfiguration ( message . apiConfiguration )
517+ await this . handleApiConfigurationUpdate ( message . apiConfiguration )
511518 }
512519 await this . postStateToWebview ( )
513520 break
@@ -1205,6 +1212,69 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12051212 }
12061213 }
12071214
1215+ private async handleApiConfigurationUpdate ( config : ApiConfiguration ) {
1216+ if ( config ) {
1217+ const {
1218+ apiProvider,
1219+ apiModelId,
1220+ apiKey,
1221+ openRouterApiKey,
1222+ awsAccessKey,
1223+ awsSecretKey,
1224+ awsSessionToken,
1225+ awsRegion,
1226+ awsUseCrossRegionInference,
1227+ vertexProjectId,
1228+ vertexRegion,
1229+ openAiBaseUrl,
1230+ openAiApiKey,
1231+ openAiModelId,
1232+ ollamaModelId,
1233+ ollamaBaseUrl,
1234+ lmStudioModelId,
1235+ lmStudioBaseUrl,
1236+ anthropicBaseUrl,
1237+ geminiApiKey,
1238+ openAiNativeApiKey,
1239+ deepSeekApiKey,
1240+ mistralApiKey,
1241+ azureApiVersion,
1242+ openRouterModelId,
1243+ openRouterModelInfo,
1244+ } = config
1245+ await this . updateGlobalState ( "apiProvider" , apiProvider )
1246+ await this . updateGlobalState ( "apiModelId" , apiModelId )
1247+ await this . storeSecret ( "apiKey" , apiKey )
1248+ await this . storeSecret ( "openRouterApiKey" , openRouterApiKey )
1249+ await this . storeSecret ( "awsAccessKey" , awsAccessKey )
1250+ await this . storeSecret ( "awsSecretKey" , awsSecretKey )
1251+ await this . storeSecret ( "awsSessionToken" , awsSessionToken )
1252+ await this . updateGlobalState ( "awsRegion" , awsRegion )
1253+ await this . updateGlobalState ( "awsUseCrossRegionInference" , awsUseCrossRegionInference )
1254+ await this . updateGlobalState ( "vertexProjectId" , vertexProjectId )
1255+ await this . updateGlobalState ( "vertexRegion" , vertexRegion )
1256+ await this . updateGlobalState ( "openAiBaseUrl" , openAiBaseUrl )
1257+ await this . storeSecret ( "openAiApiKey" , openAiApiKey )
1258+ await this . updateGlobalState ( "openAiModelId" , openAiModelId )
1259+ await this . updateGlobalState ( "ollamaModelId" , ollamaModelId )
1260+ await this . updateGlobalState ( "ollamaBaseUrl" , ollamaBaseUrl )
1261+ await this . updateGlobalState ( "lmStudioModelId" , lmStudioModelId )
1262+ await this . updateGlobalState ( "lmStudioBaseUrl" , lmStudioBaseUrl )
1263+ await this . updateGlobalState ( "anthropicBaseUrl" , anthropicBaseUrl )
1264+ await this . storeSecret ( "geminiApiKey" , geminiApiKey )
1265+ await this . storeSecret ( "openAiNativeApiKey" , openAiNativeApiKey )
1266+ await this . storeSecret ( "deepSeekApiKey" , deepSeekApiKey )
1267+ await this . storeSecret ( "mistralApiKey" , mistralApiKey )
1268+ await this . updateGlobalState ( "azureApiVersion" , azureApiVersion )
1269+ await this . updateGlobalState ( "openRouterModelId" , openRouterModelId )
1270+ await this . updateGlobalState ( "openRouterModelInfo" , openRouterModelInfo )
1271+
1272+ if ( this . cline ) {
1273+ this . cline . api = buildApiHandler ( config )
1274+ }
1275+ }
1276+ }
1277+
12081278 async updateCustomInstructions ( instructions ?: string ) {
12091279 // User may be clearing the field
12101280 await this . updateGlobalState ( "customInstructions" , instructions || undefined )
0 commit comments