← Blog

Gemini Model Version and Response ID Belong in Every Audit Record

Parminder Singh
Parminder Singh··6 min read
Summarize with AI

Gemini GenerateContent responses expose modelVersion and responseId as output-only fields. Logging both values beside the requested model, route policy, candidate outcome, and local delivery decision lets engineers reconstruct which resolved model produced a specific response, especially when aliases can move to newer releases.

Platform & Architectureai-securityllm-securitypolicy-enforcementzero-trustforensic-auditarchitecture
Gemini Model Version and Response ID Belong in Every Audit Record

Gemini GenerateContentResponse exposes two output-only correlation fields that production logs should keep: modelVersion identifies the model version used to generate the response, and responseId identifies the response. Those values answer a different question from the model string in the request because a caller may submit an alias, which Google then resolves to the version reported in the response.

I want five values in one route record: requested model, returned model version, response ID, selected candidate, and the application disposition. An incident review can then identify the exact exchange without guessing from today's model catalog.

TL;DR

  • Log the requested Gemini model string and returned modelVersion as separate fields.
  • Retain responseId as provider correlation evidence for each response.
  • Bind both fields to candidate outcome and delivery decision under the recorded route policy and parser version.
  • Hold identifiers that are missing or malformed, including contradictory values, according to the route's evidence requirements.

Requested model and resolved version differ

Google AI Studio's GenerateContent API reference defines the output-only modelVersion as the model version used to generate the response. The provider-returned value belongs beside the exact model path or alias sent in the request.

Use distinct names such as requested_model and provider_model_version. A single model column invites the request value to overwrite the response value, especially in middleware that initializes a log record before dispatch. Preserve the API version and endpoint as well, because a model string without its route context leaves part of the contract unstated.

The route should also record policy version, request digest, response timestamp, and parser version. Add candidate indexes and finish reasons. The AI audit log schema provides the common structure for identity and authorization evidence, plus delivery evidence.

Do not infer a missing response version from the request. Record provider_model_version_absent, then apply the route's declared evidence policy. Inference makes a clean dashboard by manufacturing the fact an audit needs to establish.

Model aliases create a moving reference

Google's official Gemini models documentation separates stable, preview, latest, and experimental name patterns. It says a stable name points to a specific stable model and usually does not change, while the latest alias points to the newest release for a model variation and can be swapped as new releases arrive. Preview and experimental endpoints have different stability and availability expectations.

That naming system makes response logging operationally useful. If a request used a latest alias, the returned modelVersion records what served that specific exchange. A later incident should not depend on the model currently behind the alias because the catalog can change after the traffic has left production.

My opinion is direct: logging only gemini-flash-latest is an avoidable evidence failure. The alias is a routing instruction. It is not a durable account of what answered.

A per-route AI policy can permit specific stable names and restrict preview endpoints. It can also require returned version evidence before a high-impact response is delivered.

Response ID anchors one provider response

The GenerateContent reference says responseId is output-only and identifies each response. Store it without treating it as an application idempotency key or an authorization token. The application still needs its own operation ID, attempt ID, trace ID, and user or agent identity.

These identifiers form a useful chain: the local operation ID groups the business action, each outbound attempt gets an attempt ID, and Gemini's response ID identifies the provider response returned for that attempt. A selected candidate index then points to the content the application considered for delivery.

Keep the raw responseId under the audit access policy. Index it for exact lookup if incident responders use it, but avoid placing it in public error messages. Its presence proves correlation within the stored exchange, while safety, completeness, and application acceptance require separate evidence.

On a review screen, print the request alias and returned version on adjacent lines in a narrow card. Put the response ID beneath them in monospace text. The physical separation prevents a reviewer from reading three identifiers as one long model name.

Candidate and delivery evidence completes the record

Version fields describe provenance, while candidate metadata describes the generation outcome. For every candidate, retain the index, content presence, finish reason, safety evidence required by the route, and any structured-output validation result. If the application chooses one candidate, record the selected index and selection rule.

The application disposition needs its own field. A Gemini response can arrive over HTTP 200 and still be withheld because generation stopped for a safety reason or output failed its schema, while a response version that violated route policy can also cause withholding. Store values such as accepted and withheld, with quarantined available under a versioned local vocabulary.

The Google Gemini enterprise audit logs guide covers wider platform evidence. Route-level response logging answers a narrower question: it shows which authenticated call produced this provider response and under which local policy, then records what left the gateway.

Streaming requires terminal response metadata to be assembled before downstream actions rely on a final version and candidate state. If a stream ends without required identifiers, preserve the partial-delivery count and mark the evidence incomplete rather than guessing the resolved version from an earlier chunk or request alias and weakening the record.

Logging needs bounded sensitive-data retention

Model version and response ID are usually lower-risk than prompt and output text, but they still belong to an access-controlled operational record. A response ID can become a correlation handle across support cases, incident timelines, and internal dashboards. Limit access according to the route's audit role rather than copying it into every analytics event.

Use a protected request or response digest when full content retention is unnecessary. The digest must identify the canonical bytes and algorithm used. Store raw prompt and candidate text only where the route's approved retention and encryption rules, including its deletion policy, allow it. Model provenance survives without turning the general log index into a second prompt database.

Cardinality matters. modelVersion works as a bounded dimension after validation. responseId is high-cardinality and belongs in traces or searchable evidence, not a metrics label, because putting unique IDs into time-series labels creates needless cost and a dashboard that cannot aggregate useful behavior.

The safe idempotent LLM retries guide supplies the attempt model for ambiguous transport outcomes. A retry can produce a new response ID and different output. Retain every attempt rather than overwriting the first row with the final success.

Release fixtures should simulate version drift

Put a controllable Gemini-compatible stub behind the deployed HTTP route. Send requested-model-alias, then return resolved-model-2026-11-24 in modelVersion with a syntactically valid responseId. Verify that the audit record keeps both model strings and binds the provider ID to the correct attempt.

Next, replay the same application operation with a second attempt and a different response ID. The operation should contain two immutable attempt records, with candidate selection and delivery pointing to the attempt whose content was actually used.

The next fixture should omit the model version and return a blank response ID. Separate cases can change that identifier to a number or an oversized string, while another can use an unknown version value. Add a response version disallowed by the route even though candidate content is valid. The validator should preserve raw evidence and stop delivery where policy requires it. It should also emit a named finding.

Finally, simulate an alias change between two accepted calls. The requested alias stays fixed. The returned model version changes. Alerting should identify a version transition without claiming provider fault, proving that the log can show drift instead of hiding it behind a stable request label.

DeepInspect

DeepInspect can inspect Gemini GenerateContent responses on authenticated user or agent HTTP traffic deliberately routed through its proxy. Before response delivery, it can bind requested model and returned model version with response ID, candidate outcome, and route policy into a per-decision audit record.

The application owns business-operation IDs, candidate selection, structured-output validation, content retention, retry orchestration, and downstream effects. Calls that bypass the proxy and local processing after delivery remain outside DeepInspect's enforcement and evidence.

Book a technical deep dive at deepinspect.ai.

Frequently asked questions

Is the requested Gemini model enough for an audit log?

The request records what the caller asked for, while the returned modelVersion records the version Google says generated that response. Keep both, especially when the request uses an alias that can point to a newer release.

What does Gemini responseId identify?

Google defines responseId as an output-only string used to identify each response. Store it as provider correlation evidence beside the application's own operation and attempt identifiers, along with its trace identifier.

Can responseId serve as an idempotency key?

The documented field identifies a returned response. Application idempotency requires a client-controlled key and effect policy established before the provider response exists. Keep the two identifiers in separate fields.

What should happen when modelVersion is missing?

Record the field as absent and follow the route's evidence policy. A high-impact route may quarantine the response, while a lower-risk route may deliver it with an explicit version_evidence_missing finding. Never copy the requested alias into the response field.