Skip to content

feat: Add response metadata fields - #179

Merged
aydinfatih merged 2 commits into
mainfrom
feat/response-metadata-fields
Oct 12, 2026
Merged

aydinfatih merged 2 commits into
mainfrom
feat/response-metadata-fields

Conversation

@aydinfatih

Copy link
Copy Markdown
Member

Refs #168

Adds output fields from the API reference that are currently dropped while parsing.

Changes

Class New property
GenerateContentResponse responseId, modelStatus (ModelStatus)
Candidate finishMessage, urlContextMetadata (UrlContextMetadata)
UsageMetadata serviceTier (ServiceTier)

Backward compatibility

  • New constructor parameters are nullable and appended at the end.
  • Missing fields resolve to null.
  • New enum values are parsed with tryFrom, like DocumentState, PromptFeedback and ModalityTokenCount, so values added to the API later resolve to null instead of failing the whole response.
  • urlRetrievalMetadata is kept as is.

Tests

  • All new fields parsed from a full response, including toArray() round trip
  • Unknown enum values resolve to null
  • Responses without the new fields still parse

Parse output fields from the API reference that were dropped so far:

- GenerateContentResponse: responseId, modelStatus
- Candidate: finishMessage, urlContextMetadata
- UsageMetadata: serviceTier

New enums (ModelStage, UrlRetrievalStatus, ServiceTier) are parsed with
tryFrom, so values added to the API later resolve to null instead of
failing the whole response.

Refs #168
…a-fields

# Conflicts:
#	tests/Responses/GenerativeModel/GenerateContentResponse.php
@aydinfatih
aydinfatih merged commit 21e9bbe into main Oct 12, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant