@@ -68,6 +68,8 @@ public abstract class ApiClient implements AutoCloseable {
6868 private static final ImmutableSet <String > VALID_HTTP_METHODS =
6969 ImmutableSet .<String >builder ().addAll (METHODS_WITH_BODY ).add ("GET" ).add ("DELETE" ).build ();
7070
71+ private static final ImmutableSet <String > MULTI_REGIONAL_LOCATIONS = ImmutableSet .of ("us" , "eu" );
72+
7173 private static Optional <String > geminiBaseUrl = Optional .empty ();
7274 private static Optional <String > vertexBaseUrl = Optional .empty ();
7375
@@ -236,7 +238,9 @@ protected ApiClient(
236238 && locationValue .equals ("global" )
237239 && !customBaseUrl .isPresent ())) {
238240 initHttpOptionsBuilder .baseUrl ("https://aiplatform.googleapis.com" );
239- } else if (locationValue != null && locationValue .equals ("us" ) && !customBaseUrl .isPresent ()) {
241+ } else if (locationValue != null
242+ && MULTI_REGIONAL_LOCATIONS .contains (locationValue )
243+ && !customBaseUrl .isPresent ()) {
240244 initHttpOptionsBuilder .baseUrl (
241245 String .format ("https://aiplatform.%s.rep.googleapis.com" , locationValue ));
242246 } else if (locationValue != null && !customBaseUrl .isPresent ()) {
@@ -713,7 +717,7 @@ static HttpOptions defaultHttpOptions(
713717 defaultHttpOptionsBuilder .baseUrl (customBaseUrl .get ());
714718 } else if (apiKey .isPresent () || location .get ().equalsIgnoreCase ("global" )) {
715719 defaultHttpOptionsBuilder .baseUrl ("https://aiplatform.googleapis.com" );
716- } else if (location .get (). equals ( "us" )) {
720+ } else if (MULTI_REGIONAL_LOCATIONS . contains ( location .get ())) {
717721 defaultHttpOptionsBuilder .baseUrl (
718722 String .format ("https://aiplatform.%s.rep.googleapis.com" , location .get ()));
719723 } else {
0 commit comments