Skip to content

CitationMetadata model deviates from docs #1222

@alexandersteinhauer

Description

@alexandersteinhauer

GenerationContentResponse coming from the Batch API contains CitationMetadata as specified in the docs: https://ai.google.dev/api/generate-content#citationmetadata

class CitationMetadata:
    citationSources: list[CitationSource]

The library models it different though, leading to a mismatch:

class CitationMetadata:
    citations: list[Citation]

As CitationMetadata also inherits from _common.BaseModel all extra properties lead to an exception.
And because (at least) the Batch API returns the "correct" model, parsing it using the library is not possible.

Environment details

  • Programming language: Python
  • OS: Linux
  • Language runtime version: Python 3.13
  • Package version: 1.28.0

Steps to reproduce

  1. Download jsonl output file from Batch API that has response.candidates.0.citationMetadata.citationSources populated.
  2. Try to parse response with GenerateContentResponse.model_validate_json

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions