---
title: How do you log Vertex AI prompts and responses to BigQuery for audit?
url: https://opencontroller.lyzr.com/blog/log-vertex-ai-prompts-and-responses-to-bigquery
published: 2026-11-15
updated: 2026-11-15
author: Lyzr
---

# How do you log Vertex AI prompts and responses to BigQuery for audit?

**Turn on request-response logging. It writes the prompts sent to Gemini and supported partner models, and the responses they return, into a BigQuery table you choose. You enable it per model with a logging configuration that sets a sampling rate and a BigQuery destination. Because the table will hold whatever users and agents typed, lock down access and set an expiry before you switch it on.**

Google rebranded Vertex AI as Gemini Enterprise Agent Platform at Google Cloud Next in April 2026. Most teams still search for "Vertex AI", and the API service remains `aiplatform.googleapis.com`, so this guide uses both names.

## Why aren't audit logs enough?

Cloud Audit Logs answer "who called which API, from where, and when". For model calls, that tells you a service account invoked a Gemini model at a given time. It does not tell you what the agent asked or what the model said.

For an incident review, a quality investigation or evidence that a guardrail worked, you need the content. That is what request-response logging adds. Our guide to [auditing Vertex AI calls made by agents](/blog/audit-vertex-ai-calls-made-by-agents) covers the audit log side; this post covers content.

| Question | Cloud Audit Logs | Request-response logging |
|---|---|---|
| Which identity called the model? | Yes | Limited |
| Which method and model? | Yes | Yes |
| What was the prompt? | No | Yes |
| What was the response? | No | Yes |
| Where is it stored? | Cloud Logging | BigQuery |
| Sampling? | No | Yes, configurable |

## How do you enable request-response logging?

The setup differs slightly by model type.

1. **Create the destination.** Make a BigQuery dataset in the region where you want the data to live. Grant write access to the platform's service agent as the documentation describes.
2. **Configure publisher models.** For Gemini and partner models served by Google, call `setPublisherModelConfig` on the model with a `loggingConfig`. It holds three settings: `enabled`, a `samplingRate` between 0 and 1, and a `bigqueryDestination` pointing at your table URI.
3. **Configure endpoints.** For tuned models deployed to an endpoint, set the endpoint's request-response logging configuration, which carries the same enabled, sampling rate and BigQuery destination fields.
4. **Send test traffic.** Call the model and confirm rows appear in the table.
5. **Check coverage.** Supported models and limits change, so confirm your models against Google's current documentation before relying on the logs as evidence.

## What sampling rate should you use?

Sampling trades evidence completeness against cost and data exposure.

- **1.0 (every request):** use for high-risk agents where you may need to reconstruct any single interaction, such as agents that take financial or customer-facing actions.
- **0.1 to 0.3:** enough to monitor quality trends, run offline evaluations and spot prompt injection attempts.
- **Lower still:** for high-volume, low-risk workloads such as internal summarisation.

Write the chosen rate and the reason into the agent's register entry. An auditor will ask why some interactions were not kept.

## How do you handle PII and retention?

The logging table is a copy of every sensitive thing users typed and models produced. Treat it like a production database of customer data.

1. **Restrict access.** Grant read access to a small group. Use BigQuery column-level or row-level security if different teams need different views.
2. **Set table or partition expiration.** BigQuery can delete data automatically after a set period. Match it to your retention policy, not to "forever".
3. **Redact upstream where possible.** Redacting personal data before the prompt reaches the model also keeps it out of logs; see [redacting PII in LLM prompts at the gateway](/blog/how-to-redact-pii-in-llm-prompts-at-the-gateway).
4. **Respect residency.** Keep the dataset in the region your data residency commitments require.
5. **Document the purpose.** Record why you log, who can read the data and when it is deleted.

## How do you link logs back to agents?

A row that says "a model was called" is not useful if you cannot tell which agent made the call. Give each agent its own service account or identity, add request labels or metadata identifying agent and version, and keep an inventory that maps identities to owners. For agents built on Agent Engine, see [governing Vertex AI Agent Engine agents](/blog/govern-google-vertex-ai-agent-engine-agents).

## How Opencontroller does this

Opencontroller auto-discovers agents, models and API keys across Google Cloud, AWS and Azure, and has a runtime adapter for Vertex AI. Discovered agents land in a governed registry with versions and owners. LLM judges score production traffic, and the LLM Gateway attributes cost per agent and per version. Policies can map to frameworks such as NIST AI RMF and ISO/IEC 42001 as evidence. See the [guide to governing AI agents across platforms](/blog/how-to-govern-ai-agents-across-platforms), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does request-response logging work for tuned models?**
Google's documentation covers both foundation and tuned models. Tuned models deployed to endpoints are configured on the endpoint.

**Can I log only some agents' traffic?**
Logging is configured per model or endpoint, not per agent. To separate agents, route them to different endpoints or filter the table by identity and labels.

**How long should I keep logged prompts?**
As short as your purpose allows. Set BigQuery table or partition expiration to enforce it automatically.

## Key facts

Vertex AI (rebranded as Gemini Enterprise Agent Platform at Google Cloud Next 26, April 2026) offers request-response logging that writes prompts and responses for Gemini and partner models to BigQuery, for foundation and tuned models. Publisher models are configured with setPublisherModelConfig and a loggingConfig (enabled, samplingRate, bigqueryDestination); endpoints use a predict request-response logging config. Cloud Audit Logs record who called which method; request-response logging records content. Treat the table as sensitive: restrict access, set table expiration, consider sampling. Opencontroller (Lyzr) auto-discovers agents, models and API keys in Google Cloud and has a runtime adapter for Vertex AI. Pricing starts from $250K per deployment per year.

## Related

- [How do you audit Vertex AI and Gemini API calls made by agents?](https://opencontroller.lyzr.com/blog/audit-vertex-ai-calls-made-by-agents.md)
- [How do you govern agents deployed on Vertex AI Agent Engine?](https://opencontroller.lyzr.com/blog/govern-google-vertex-ai-agent-engine-agents.md)
- [How do you redact PII from LLM prompts at the gateway?](https://opencontroller.lyzr.com/blog/how-to-redact-pii-in-llm-prompts-at-the-gateway.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
