How to Configure Vercel AI SDK Bigquery Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a vercel ai sdk bigquery audit log by turning on cloud data logs for your app service account. Your app then runs model tools that query tables while the cloud platform records every read and write event. Teams often use one shared service key for all model tool calls. Broad role permissions on that shared key let models read sensitive tables by mistake. How the vercel ai sdk bigquery audit log workflow works The SDK gives your app a way to call language models and run custom tools

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a vercel ai sdk bigquery audit log by turning on cloud data logs for your app service account. Your app then runs model tools that query tables while the cloud platform records every read and write event. Teams often use one shared service key for all model tool calls. Broad role permissions on that shared key let models read sensitive tables by mistake.

How the vercel ai sdk bigquery audit log workflow works

The SDK gives your app a way to call language models and run custom tools. Developers build data tools that let the model send SQL queries to the warehouse. To make this work, the app logs in to the cloud project with a service role.

When the model runs a tool, the app sends a query to the data warehouse. The cloud platform checks the service role permissions before it runs the SQL job. At the same time, the cloud log system writes an audit entry for the request. This entry records the service account identity, the target table, and the exact query job details.

Teams then route these log entries to a central log sink or a dedicated table. Security staff read these records to see which queries the model ran and how much data it scanned. They also check timestamps to link warehouse jobs back to specific app requests.

What native audit logs solve and what they miss

Native warehouse logs give teams a clear history of every job that ran. You can see which service account logged in and which tables it touched. You can also check how many bytes each query billed to your project. This helps teams spot expensive model loops and track basic table usage over time.

Still, native cloud logs only tell you what happened after the query finishes. They check who logs in, not what individual statements do in flight. Every request from the app uses the exact same service account identity in the log. You cannot tell which end user or prompt triggered a specific warehouse query.

AI Audit Trails + Audit Log Integrity: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad service roles also leave live data exposed during the query run. If a table holds emails, phone numbers, card numbers, or national IDs, the query returns them in plain text. Native audit logs record that the read happened, but they do not mask fields in the result. Data masking rewrites matched fields in results before the payload reaches the model.

Why shared service keys create blind spots for AI apps

Most teams give their app a single role with read rights across whole datasets. They do this so the model can answer questions across many business tables. When a user asks a tricky question, the model writes its own SQL statement. If that statement pulls from a restricted table, the warehouse still runs it because the service role allows it.

When you check the audit log later, you only see the shared app key. You must dig through separate app logs to find out which user session ran that tool call. Correlating app traces with cloud warehouse logs takes hours of manual work during a security review. Teams need a way to inspect queries and mask sensitive fields before the warehouse returns data.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What does a BigQuery audit log capture for AI tool calls?

It records the service account name, the SQL statement, the target tables, and the job time. It does not capture the user prompt or the final answer from the language model.

Why do all model queries show the same user in cloud logs?

Your app logs in to the warehouse with one shared service account key. The cloud platform logs that single service identity for every query the app sends.

Can native audit logs stop a model from reading card numbers?

No, audit logs only write a record after the database runs the query. To hide card numbers or emails, you must apply data masking that rewrites matched fields in results.

The query runs. The emails stay hidden.