@@ -194,12 +194,19 @@ impl ApiClient {
194194 } ,
195195 }
196196
197- let profile = match database. get_auth_profile ( ) {
198- Ok ( profile) => profile,
199- Err ( err) => {
200- error ! ( "Failed to get auth profile: {err}" ) ;
201- None
202- } ,
197+ // Check if using custom endpoint
198+ let use_profile = !Self :: is_custom_endpoint ( database) ;
199+ let profile = if use_profile {
200+ match database. get_auth_profile ( ) {
201+ Ok ( profile) => profile,
202+ Err ( err) => {
203+ error ! ( "Failed to get auth profile: {err}" ) ;
204+ None
205+ } ,
206+ }
207+ } else {
208+ debug ! ( "Custom endpoint detected, skipping profile ARN" ) ;
209+ None
203210 } ;
204211
205212 Ok ( Self {
@@ -231,7 +238,7 @@ impl ApiClient {
231238 true => OptOutPreference :: OptIn ,
232239 false => OptOutPreference :: OptOut ,
233240 } )
234- // .set_profile_arn(self.profile.as_ref().map(|p| p.arn.clone()))
241+ . set_profile_arn ( self . profile . as_ref ( ) . map ( |p| p. arn . clone ( ) ) )
235242 . set_model_id ( model)
236243 . send ( )
237244 . await ?;
@@ -278,8 +285,11 @@ impl ApiClient {
278285
279286 let mut models = Vec :: new ( ) ;
280287 let mut default_model = None ;
281- let request = self . client . list_available_models ( ) . set_origin ( Some ( Cli ) ) ;
282- // .set_profile_arn(self.profile.as_ref().map(|p| p.arn.clone()));
288+ let request = self
289+ . client
290+ . list_available_models ( )
291+ . set_origin ( Some ( Cli ) )
292+ . set_profile_arn ( self . profile . as_ref ( ) . map ( |p| p. arn . clone ( ) ) ) ;
283293 let mut paginator = request. into_paginator ( ) . send ( ) ;
284294
285295 while let Some ( result) = paginator. next ( ) . await {
@@ -336,8 +346,10 @@ impl ApiClient {
336346 }
337347
338348 pub async fn is_mcp_enabled ( & self ) -> Result < bool , ApiClientError > {
339- let request = self . client . get_profile ( ) ;
340- // .set_profile_arn(self.profile.as_ref().map(|p| p.arn.clone()));
349+ let request = self
350+ . client
351+ . get_profile ( )
352+ . set_profile_arn ( self . profile . as_ref ( ) . map ( |p| p. arn . clone ( ) ) ) ;
341353
342354 let response = request. send ( ) . await ?;
343355 let mcp_enabled = response
@@ -395,7 +407,7 @@ impl ApiClient {
395407 match client
396408 . generate_assistant_response ( )
397409 . conversation_state ( conversation_state)
398- // .set_profile_arn(self.profile.as_ref().map(|p| p.arn.clone()))
410+ . set_profile_arn ( self . profile . as_ref ( ) . map ( |p| p. arn . clone ( ) ) )
399411 . send ( )
400412 . await
401413 {
@@ -594,6 +606,11 @@ impl ApiClient {
594606
595607 self . mock_client = Some ( Arc :: new ( Mutex :: new ( mock. into_iter ( ) ) ) ) ;
596608 }
609+
610+ // Add a helper method to check if using non-default endpoint
611+ fn is_custom_endpoint ( database : & Database ) -> bool {
612+ database. settings . get ( Setting :: ApiCodeWhispererService ) . is_ok ( )
613+ }
597614}
598615
599616fn timeout_config ( database : & Database ) -> TimeoutConfig {
0 commit comments