@@ -838,7 +838,7 @@ def to_agent_engine(
838838 artifact_service_uri : Optional [str ] = None ,
839839 adk_version : Optional [str ] = None ,
840840):
841- """Deploys an agent to Vertex AI Agent Engine .
841+ """Deploys an agent to Agent Platform Runtime .
842842
843843 `agent_folder` should contain the following files:
844844
@@ -1104,19 +1104,33 @@ def to_agent_engine(
11041104
11051105 from ..utils ._google_client_headers import get_tracking_headers
11061106
1107- if not project or not region :
1108- click .echo ('No project/region provided. Starting onboarding flow...' )
1107+ if not (api_key or project or region ):
1108+ click .echo (
1109+ 'No apikey/project/region provided. Starting onboarding flow...'
1110+ )
11091111 auth_info = _onboarding .handle_login_with_google ()
11101112 project = auth_info .project_id
11111113 region = auth_info .region
11121114
1113- click .echo ('Initializing Vertex AI...' )
1114- client = vertexai .Client (
1115- project = project ,
1116- location = region ,
1117- http_options = {'headers' : get_tracking_headers ()},
1118- )
1119- click .echo ('Vertex AI initialized.' )
1115+ click .echo ('Initializing Agent Platform client...' )
1116+ if project and region :
1117+ client = vertexai .Client (
1118+ project = project ,
1119+ location = region ,
1120+ http_options = {'headers' : get_tracking_headers ()},
1121+ )
1122+ elif api_key :
1123+ client = vertexai .Client (
1124+ api_key = api_key ,
1125+ http_options = {'headers' : get_tracking_headers ()},
1126+ )
1127+ else :
1128+ click .echo (
1129+ 'Failed to initialize Agent Platform client. Please provide an API'
1130+ 'key or project and region.'
1131+ )
1132+ return
1133+ click .echo ('Agent Platform client initialized.' )
11201134
11211135 if skip_agent_import_validation :
11221136 warnings .warn (
0 commit comments