This guide shows you how to configure request-response logging for foundation and fine-tuned models in Vertex AI. The logs are saved to a BigQuery table for viewing and analysis. This page describes the following: The following diagram summarizes the workflow for setting up request-response logging: You can log requests and responses in Vertex AI using two different methods, depending on whether you use a base foundation model or a fine-tuned model. The following table compares the two methods. Request-response logs are supported for all Gemini models that use The following partner models that use To configure request-response logs for base foundation models, you can use the REST API or the Python SDK. Logging configurations can take a few minutes to take effect. To enable request-response logs for a base foundation model, select one of the following tabs. For Anthropic models, only the REST API is supported for logging configuration. To enable logging, set the publisher to Use this method to create or update a To create or update a PublisherModelConfig, use the
Before using any of the request data,
make the following replacements:
HTTP method and URL:
Request JSON body:
To send your request, choose one of these options:
Save the request body in a file named
Save the request body in a file named You should receive a JSON response similar to the following: To get the request-response logging configuration for a foundation model, use the REST API. To get the request-response logging configuration, use the
Before using any of the request data,
make the following replacements:
HTTP method and URL:
To send your request, choose one of these options:
Execute the following command:
Execute the following command:
You should receive a JSON response similar to the following: To disable request-response logging for a foundation model, use the REST API or the Python SDK. To disable logging, use the
Before using any of the request data,
make the following replacements:
HTTP method and URL:
Request JSON body:
To send your request, choose one of these options:
Save the request body in a file named
Save the request body in a file named You should receive a JSON response similar to the following: You can configure request-response logs for fine-tuned models by using the REST
API or Python SDK. To enable request-response logs for a fine-tuned model, select one of the following tabs. Use this method to update the request-response logging configuration for an endpoint. You can enable request-response logging when you create an endpoint using Requests and responses are logged at the endpoint level, so requests sent to any deployed models under the same endpoint are logged. When you create or patch an endpoint, populate the To view the BigQuery table schema, see Logging table schema. The following example shows a configuration: To get the request-response logging configuration for a fine-tuned model, use the REST API.
Before using any of the request data,
make the following replacements:
HTTP method and URL:
To send your request, choose one of these options:
Execute the following command:
Execute the following command:
You should receive a JSON response similar to the following: To disable the request-response logging configuration for the endpoint, use the Python SDK or the REST API. In BigQuery, the logs are recorded using the following schema: Note that request-response pairs larger than the BigQuery write API 10MB row limit are not recorded.
Choose a logging method
Model Type
Description
Configuration Method
Use Case
Base Foundation Models
Logging is configured directly on a specific publisher model (for example,
gemini-1.5-pro-001
). The configuration applies to all requests made to that model version across the project.Use the
PublisherModelConfig
resource through the REST API or Python SDK.You want to log requests for a general-purpose, pre-trained model without deploying it to a dedicated endpoint.
Fine-tuned Models
Logging is configured on the endpoint where your fine-tuned model is deployed. The configuration applies to all requests sent to that specific endpoint.
Set the
predictRequestResponseLoggingConfig
field when creating or patching an Endpoint resource.You have a fine-tuned model deployed to a Vertex AI endpoint and want to log its specific traffic.
Supported API methods for logging
generateContent
or streamGenerateContent
.rawPredict
or streamrawPredict
are also supported:
Request-response logs for base foundation models
Enable request-response logging
anthropic
and the model name to one of the supported Claude models.Python SDK
PublisherModelConfig
.publisher_model = GenerativeModel('gemini-2.0-pro-001')
# Set logging configuration
publisher_model.set_request_response_logging_config(
enabled=True,
sampling_rate=1.0,
bigquery_destination="bq://PROJECT_ID.DATASET_NAME.TABLE_NAME",
enable_otel_logging=True
)
REST API
setPublisherModelConfig
method:
-
. For example, us-central1-
. If using
the global endpoint, leave blank. Request-response logging is supported for
all regions supported
by the model.global
.google
.gemini-2.0-flash-001
.logging_ENDPOINT_DISPLAY_NAME\_ENDPOINT_ID
,
where ENDPOINT_DISPLAY_NAME
follows the
BigQuery naming rules. If you don't specify a table
name, a new table is created with the name request_response_logging
.POST https://ENDPOINT_PREFIXaiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:setPublisherModelConfig
{
"publisherModelConfig": {
"loggingConfig": {
"enabled": true,
"samplingRate": SAMPLING_RATE,
"bigqueryDestination": {
"outputUri": "BQ_URI"
},
"enableOtelLogging": true
}
}
}
curl
request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://ENDPOINT_PREFIXaiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:setPublisherModelConfig"PowerShell
request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://ENDPOINT_PREFIXaiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:setPublisherModelConfig" | Select-Object -Expand ContentGet logging configuration
REST API
fetchPublisherModelConfig
method:
google
.gemini-2.0-flash-001
.GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:fetchPublisherModelConfig
curl
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:fetchPublisherModelConfig"PowerShell
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:fetchPublisherModelConfig" | Select-Object -Expand ContentDisable logging
Python SDK
publisher_model.set_request_response_logging_config(
enabled=False,
sampling_rate=0,
bigquery_destination=''
)
REST API
setPublisherModelConfig
method:
google
.gemini-2.0-flash-001
.POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:setPublisherModelConfig
{
"publisherModelConfig": {
"loggingConfig": {
"enabled": false
}
}
}
curl
request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:setPublisherModelConfig"PowerShell
request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/PUBLISHER/models/MODEL:setPublisherModelConfig" | Select-Object -Expand ContentRequest-response logs for fine-tuned models
Enable request-response logs
Python SDK
tuned_model = GenerativeModel("projects/PROJECT_ID/locations/REGION/endpoints/ENDPOINT_ID")
# Set logging configuration
tuned_model.set_request_response_logging_config(
enabled=True,
sampling_rate=1.0,
bigquery_destination="bq://PROJECT_ID.DATASET_NAME.TABLE_NAME",
enable_otel_logging=True
)
REST API
projects.locations.endpoints.create
or patch an existing endpoint using projects.locations.endpoints.patch
.predictRequestResponseLoggingConfig
field of the Endpoint resource with the following entries:
enabled
: Set to true
to enable request-response logging.samplingRate
: To reduce storage costs, you can set a number between 0 and 1 to define the fraction of requests to log. For example, a value of 1
logs all requests, and a value of 0.1
logs 10% of requests.BigQueryDestination
: The BigQuery table to use for logging. If you specify only a project name, Vertex AI creates a new dataset with the name logging_ENDPOINT_DISPLAY_NAME_ENDPOINT_ID
. The ENDPOINT_DISPLAY_NAME
follows the BigQuery naming rules. If you don't specify a table name, Vertex AI creates a new table with the name request_response_logging
.enableOtelLogging
: Set to true
to enable OpenTelemetry (OTEL) logging in addition to the default request-response logging.
{
"predictRequestResponseLoggingConfig": {
"enabled": true,
"samplingRate": 0.5,
"bigqueryDestination": {
"outputUri": "bq://PROJECT_ID.DATASET_NAME.TABLE_NAME"
},
"enableOtelLogging": true
}
}
Get logging configuration
REST API
gemini-2.0-flash-001
.GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/ENDPOINT_ID
curl
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/ENDPOINT_ID"PowerShell
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/endpoints/ENDPOINT_ID" | Select-Object -Expand ContentDisable logging
Python SDK
tuned_model = GenerativeModel("projects/PROJECT_ID/locations/REGION/endpoints/ENDPOINT_ID")
# Set logging configuration
tuned_model.set_request_response_logging_config(
enabled=False,
sampling_rate=1.0,
bigquery_destination="bq://PROJECT_ID.DATASET_NAME.TABLE_NAME",
enable_otel_logging=False
)
REST API
{
"predictRequestResponseLoggingConfig": {
"enabled": false
}
}
Logging table schema
Field name
Type
Notes
endpoint
STRING
Resource name of the endpoint to which the tuned model is deployed.
deployed_model_id
STRING
Deployed model ID for a tuned model deployed to an endpoint.
logging_time
TIMESTAMP
The time that logging is performed. This is roughly the time that the response is returned.
request_id
NUMERIC
The auto-generated integer request ID based on the API request.
request_payload
STRING
Included for partner model logging and backward compatibility with the Vertex AI endpoint request-response log.
response_payload
STRING
Included for partner model logging and backward compatibility with the Vertex AI endpoint request-response log.
model
STRING
Model resource name.
model_version
STRING
The model version. This is often "default" for Gemini models.
api_method
STRING
generateContent, streamGenerateContent, rawPredict, streamRawPredict
full_request
JSON
The full
GenerateContentRequest
.
full_response
JSON
The full
GenerateContentResponse
.
metadata
JSON
Any metadata of the call; contains the request latency.
otel_log
JSON
Logs in OpenTelemetry schema format. Only available if
otel_logging
is enabled in the logging configuration.What's next
Log requests and responses
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-27 UTC.