googleapis / googleapis/python-genai

Docs Mismatch: response_format dictionary syntax conflicting with types.GenerateContentConfig

Open
#2,512 3 comments 0 reactions 1 assignee Assigned to @kkorpal View on GitHub
priority: p2 type: bug
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

#### Description
There is a syntax conflict in the official structured output documentation. The Python code blocks on the [Structured outputs](https://ai.google.dev/gemini-api/docs/structured-output) documentation page use a deeply nested raw dictionary structure for configuring JSON schemas.

```python
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:
```python
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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.