File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9191INITIAL_RETRY_DELAY = 1 # second
9292DELAY_MULTIPLIER = 2
9393
94+ _MULTI_REGIONAL_LOCATIONS = {'us' , 'eu' }
95+
9496
9597class EphemeralTokenAPIKeyError (ValueError ):
9698 """Error raised when the API key is invalid."""
@@ -702,7 +704,10 @@ def __init__(
702704 self .api_key or self .location == 'global'
703705 ) and not self .custom_base_url :
704706 self ._http_options .base_url = f'https://aiplatform.googleapis.com/'
705- elif self .location == 'us' and not self .custom_base_url :
707+ elif (
708+ self .location in _MULTI_REGIONAL_LOCATIONS
709+ and not self .custom_base_url
710+ ):
706711 self ._http_options .base_url = (
707712 f'https://aiplatform.{ self .location } .rep.googleapis.com/'
708713 )
Original file line number Diff line number Diff line change @@ -532,6 +532,22 @@ def test_vertexai_location_us_routing(monkeypatch):
532532 )
533533
534534
535+ def test_vertexai_location_eu_routing (monkeypatch ):
536+ # Verify that location='eu' correctly routes to the eu.rep endpoint
537+ project_id = "fake_project_id"
538+ location = "eu"
539+
540+ with monkeypatch .context () as m :
541+ m .delenv ("GOOGLE_CLOUD_LOCATION" , raising = False )
542+ client = Client (vertexai = True , project = project_id , location = location )
543+ assert client .models ._api_client .location == location
544+ assert client .models ._api_client .project == project_id
545+ assert (
546+ client .models ._api_client .get_read_only_http_options ()["base_url" ]
547+ == "https://aiplatform.eu.rep.googleapis.com/"
548+ )
549+
550+
535551def test_vertexai_location_us_routing_base_url_override (monkeypatch ):
536552 # Verify that base_url override takes precedence over location='us' routing
537553 project_id = "fake_project_id"
You can’t perform that action at this time.
0 commit comments