Skip to content

Docs Mismatch: response_format dictionary syntax conflicting with types.GenerateContentConfig #2512

@kaveh0007

Description

@kaveh0007

Description

There is a syntax conflict in the official structured output documentation. The Python code blocks on the Structured outputs documentation page use a deeply nested raw dictionary structure for configuring JSON schemas.

config={
    "response_format": {"text": {"mime_type": "application/json", "schema": Recipe.model_json_schema()}},
}

However, the modern google-genai Python SDK recommends and implements structured generation using flat, top-level keys within types.GenerateContentConfig (or equivalent dictionary mapping):

Example:

config={
    response_mime_type="application/json",
    response_schema=Recipe
}

Environment details

  • Programming language: Python
  • OS: linux-mint
  • Language runtime version: 3.12.3
  • Package version: 2.6.0

Steps to reproduce

  1. Navigate to the documentation at: https://ai.google.dev/gemini-api/docs/structured-output

  2. Observe the Python tabs under the "Recipe Extractor", "Streaming", and "Structured outputs with tools" sections.

  3. They all use the nested "response_format" dictionary configuration instead of the native SDK schema parameters.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions