@@ -279,6 +279,9 @@ def create(
279279 sync = True ,
280280 create_request_timeout : Optional [float ] = None ,
281281 endpoint_id : Optional [str ] = None ,
282+ enable_request_response_logging = False ,
283+ request_response_logging_sampling_rate : Optional [float ] = None ,
284+ request_response_logging_bq_destination_table : Optional [str ] = None ,
282285 ) -> "Endpoint" :
283286 """Creates a new endpoint.
284287
@@ -339,12 +342,18 @@ def create(
339342 is populated based on a query string argument, such as
340343 ``?endpoint_id=12345``. This is the fallback for fields
341344 that are not included in either the URI or the body.
345+ enable_request_response_logging (bool):
346+ Optional. Whether to enable request & response logging for this endpoint.
347+ request_response_logging_sampling_rate (float):
348+ Optional. The request response logging sampling rate. If not set, default is 0.0.
349+ request_response_logging_bq_destination_table (str):
350+ Optional. The request response logging bigquery destination. If not set, will create a table with name:
351+ ``bq://{project_id}.logging_{endpoint_display_name}_{endpoint_id}.request_response_logging``.
342352
343353 Returns:
344354 endpoint (aiplatform.Endpoint):
345355 Created endpoint.
346356 """
347-
348357 api_client = cls ._instantiate_client (location = location , credentials = credentials )
349358
350359 if not display_name :
@@ -357,6 +366,17 @@ def create(
357366 project = project or initializer .global_config .project
358367 location = location or initializer .global_config .location
359368
369+ predict_request_response_logging_config = None
370+ if enable_request_response_logging :
371+ predict_request_response_logging_config = (
372+ gca_endpoint_compat .PredictRequestResponseLoggingConfig (
373+ enabled = True ,
374+ sampling_rate = request_response_logging_sampling_rate ,
375+ bigquery_destination = gca_io_compat .BigQueryDestination (
376+ output_uri = request_response_logging_bq_destination_table
377+ ),
378+ )
379+ )
360380 return cls ._create (
361381 api_client = api_client ,
362382 display_name = display_name ,
@@ -372,6 +392,7 @@ def create(
372392 sync = sync ,
373393 create_request_timeout = create_request_timeout ,
374394 endpoint_id = endpoint_id ,
395+ predict_request_response_logging_config = predict_request_response_logging_config ,
375396 )
376397
377398 @classmethod
@@ -391,6 +412,9 @@ def _create(
391412 sync = True ,
392413 create_request_timeout : Optional [float ] = None ,
393414 endpoint_id : Optional [str ] = None ,
415+ predict_request_response_logging_config : Optional [
416+ gca_endpoint_compat .PredictRequestResponseLoggingConfig
417+ ] = None ,
394418 ) -> "Endpoint" :
395419 """Creates a new endpoint by calling the API client.
396420
@@ -453,6 +477,8 @@ def _create(
453477 is populated based on a query string argument, such as
454478 ``?endpoint_id=12345``. This is the fallback for fields
455479 that are not included in either the URI or the body.
480+ predict_request_response_logging_config (aiplatform.endpoint.PredictRequestResponseLoggingConfig):
481+ Optional. The request response logging configuration for online prediction.
456482
457483 Returns:
458484 endpoint (aiplatform.Endpoint):
@@ -469,6 +495,7 @@ def _create(
469495 labels = labels ,
470496 encryption_spec = encryption_spec ,
471497 network = network ,
498+ predict_request_response_logging_config = predict_request_response_logging_config ,
472499 )
473500
474501 operation_future = api_client .create_endpoint (
0 commit comments