Once you run the Gemini API in production, the first things you watch are token counts and latency. But after a while, an earlier question surfaces: did this call's output actually get used in the end?
Averages come out cleanly enough. The trouble is that staring at an average rarely moves your hand to fix anything. What made Google AI Studio's logging and datasets tool worth it for me wasn't fancy analytics — it was finally being able to track, in one list, what survived and what got thrown away. These are field notes for reading logs from that angle.
The First Column to Keep Is "What Happened to It"
The easy detour in log design is picking what to record from a feature list. Token count, latency, model name — you can record all of them. But they answer "how much did it cost" and "how long did it wait," not "was it any good."
My suggestion is to add, as the very first column, a custom field describing what became of each output: did it survive to publication, get rejected by a quality check, or get rewritten by hand. That single column changes how much you can read out of your logs later. The standard fields then sit behind it as supporting evidence — that ordering worked far better for me.
What Gets Logged, and What I Actually Read From It
Requests and responses are logged automatically. Here are the main fields and what I actually read from each.
| Logged field | What I read from it |
|---|---|
| Input prompt (text, image, video) | Shared phrasing habits in rejected outputs |
| Output response | Patterns prone to boilerplate or duplication |
| Token usage | Where expensive calls cluster |
| Latency | Whether slow steps are eroding UX |
| Model name / version | Whether the Pro vs Flash split is justified |
| Error information | When overloads and rate limits tend to hit |
Rather than the fields themselves, decide what judgment you want each field to support, then narrow the recording scope. Logging everything balloons until you no longer want to open it.
Building a Dataset From Logs for Evaluation
Accumulated logs become material for evaluation or fine-tuning as-is. Filtering by date or model into a dataset makes later comparisons much easier.
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
# Create dataset from logs
dataset = genai.datasets.create(
name="customer-support-logs",
description="Customer support API call logs",
source="logs",
filter={
"date_range": {"start": "2026-03-01", "end": "2026-03-12"},
"model": "gemini-2.5-pro"
}
)You can run the same prompt set through multiple models and line up quality, latency, and cost side by side. This is usually the stage where you realize a job you'd been running on Pro was fine on Flash all along.
# Model comparison using datasets
evaluation = genai.evaluations.run(
dataset="customer-support-logs",
models=["gemini-2.5-pro", "gemini-2.5-flash"],
metrics=["quality", "latency", "cost"]
)
print(evaluation.summary())The Detour I Took in Log Design
As an indie developer, I run Gemini- and Claude-based content pipelines across several sites in parallel. For a long time my logs only stored token counts and latency, so I had no visibility into which prompts kept getting rejected.
My pipeline runs generated text through several quality gates. If a passage looks like boilerplate, or duplicates a paragraph word-for-word from another article, the output is discarded and rewritten. So I added a custom passed_gate field (pass/fail) to each request's metadata, and a pattern emerged immediately.
Prompts asking for sweeping coverage — "explain this comprehensively," "write it in complete form" — produced thin, templated output and were rejected at a noticeably higher rate. Prompts that handed the model a single concrete situation or constraint passed far more consistently. evaluations.run gives you a quality score, but if, like me, you care about a binary "did it clear my own bar," the shortcut is to use filter to pull only the low-score band and read the actual prompt wording that collects there.
Closing the Loop With Cost Caps and Key Hygiene
Once you can read logs by their "results column," cost and key management follow naturally. Through 2026, the Gemini API gained Project Spend Caps — a monthly USD ceiling set per project. Once your logs show where expensive calls cluster, setting that cap structurally stops surprise bills.
Worth checking alongside it is the provenance of your API keys. As of June 19, 2026, requests from unrestricted keys are blocked. If your logs retain model names and error info, you can trace which key is calling what. If you find idle keys, or calls whose origin you can't identify, take the moment to split keys by purpose and restrict the allowed models and referrers. Logs, spend caps, and key restrictions look like separate chores, but they're really three sides of the same "don't let operations drift" checkup.
Viewing in Google AI Studio
- Go to Google AI Studio
- Select "Logs & Datasets" from the left menu
- Review log summaries on the dashboard
- Apply filters to drill into the details
The first thing to open is the low response-quality-score band. Prompts that quietly drag quality down are harder to spot — and offer more room to improve — than a noisy stretch of errors.
Retention and Privacy Notes
- Log data is scoped to your project and inaccessible to other users
- Logs containing sensitive data are stored encrypted
- Default retention is 30 days, adjustable as needed
- The feature's delivery may change, so review retention and cost settings periodically in production
Large log volumes incur storage costs. Rather than keeping everything, keep only the fields that inform a judgment — the same opening principle pays off here too.
Your Next Step
Open a few dozen of your real production logs in the dashboard and read just five prompts from the low-quality-score band. If you spot a shared phrasing, that is the first thing to fix in your prompt template. Carry that momentum into setting a cap on your most expensive calls and tidying up one key whose purpose you can't explain — operations get a lot quieter.
Thanks for reading. I hope it helps anyone else running the API in production think about how to design their logs.