Skip to content

Commit 4d5a978

Browse files
google-genai-botcopybara-github
authored andcommitted
docs: Update README and codegen_instructions for structured outputs
- Use `response_json_schema` instead of `response_schema` in all examples - Use `response.text` instead of `response.parsed` - Removed examples demonstrating Enum response schemas PiperOrigin-RevId: 872352935
1 parent cff95b4 commit 4d5a978

5 files changed

Lines changed: 7 additions & 69 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# Changelog
22

3-
## [1.64.0](https://github.com/googleapis/python-genai/compare/v1.63.0...v1.64.0) (2026-02-18)
4-
5-
6-
### Features
7-
8-
* Add UnifiedMetric support to Vertex Tuning evaluation config ([9a9908a](https://github.com/googleapis/python-genai/commit/9a9908a9605756a94404359187cad09b21c094e0))
9-
* Support multimodal embedding for Gemini Embedding 2.0 and support MaaS models in Models.embed_content() (Vertex AI API) ([af40cc6](https://github.com/googleapis/python-genai/commit/af40cc629751b2d389eecb75741e9c3531cc8e6e))
10-
113
## [1.63.0](https://github.com/googleapis/python-genai/compare/v1.62.0...v1.63.0) (2026-02-11)
124

135

README.md

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ response = client.models.generate_content(
939939
'response_json_schema': user_profile
940940
},
941941
)
942-
print(response.parsed)
942+
print(response.text)
943943
```
944944

945945
#### Pydantic Model Schema support
@@ -966,7 +966,7 @@ response = client.models.generate_content(
966966
contents='Give me information for the United States.',
967967
config=types.GenerateContentConfig(
968968
response_mime_type='application/json',
969-
response_schema=CountryInfo,
969+
response_json_schema=CountryInfo.model_json_schema(),
970970
),
971971
)
972972
print(response.text)
@@ -980,7 +980,7 @@ response = client.models.generate_content(
980980
contents='Give me information for the United States.',
981981
config=types.GenerateContentConfig(
982982
response_mime_type='application/json',
983-
response_schema={
983+
response_json_schema={
984984
'required': [
985985
'name',
986986
'population',
@@ -1006,60 +1006,6 @@ response = client.models.generate_content(
10061006
print(response.text)
10071007
```
10081008

1009-
### Enum Response Schema
1010-
1011-
#### Text Response
1012-
1013-
You can set response_mime_type to 'text/x.enum' to return one of those enum
1014-
values as the response.
1015-
1016-
```python
1017-
from enum import Enum
1018-
1019-
class InstrumentEnum(Enum):
1020-
PERCUSSION = 'Percussion'
1021-
STRING = 'String'
1022-
WOODWIND = 'Woodwind'
1023-
BRASS = 'Brass'
1024-
KEYBOARD = 'Keyboard'
1025-
1026-
response = client.models.generate_content(
1027-
model='gemini-2.5-flash',
1028-
contents='What instrument plays multiple notes at once?',
1029-
config={
1030-
'response_mime_type': 'text/x.enum',
1031-
'response_schema': InstrumentEnum,
1032-
},
1033-
)
1034-
print(response.text)
1035-
```
1036-
1037-
#### JSON Response
1038-
1039-
You can also set `response_mime_type` to `'application/json'`, the response will be
1040-
identical but in quotes.
1041-
1042-
```python
1043-
from enum import Enum
1044-
1045-
class InstrumentEnum(Enum):
1046-
PERCUSSION = 'Percussion'
1047-
STRING = 'String'
1048-
WOODWIND = 'Woodwind'
1049-
BRASS = 'Brass'
1050-
KEYBOARD = 'Keyboard'
1051-
1052-
response = client.models.generate_content(
1053-
model='gemini-2.5-flash',
1054-
contents='What instrument plays multiple notes at once?',
1055-
config={
1056-
'response_mime_type': 'application/json',
1057-
'response_schema': InstrumentEnum,
1058-
},
1059-
)
1060-
print(response.text)
1061-
```
1062-
10631009
### Generate Content (Synchronous Streaming)
10641010

10651011
Generate content in a streaming format so that the model outputs streams back

codegen_instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,15 @@ response = client.models.generate_content(
375375
contents='Provide a classic recipe for chocolate chip cookies.',
376376
config=types.GenerateContentConfig(
377377
response_mime_type='application/json',
378-
response_schema=Recipe,
378+
response_json_schema=Recipe,
379379
),
380380
)
381381

382382
# response.text is guaranteed to be valid JSON matching the schema
383383
print(response.text)
384384

385385
# Access the response as a Pydantic object
386-
parsed_response = response.parsed
386+
recipe = Recipe.model_validate_json(response.text)
387387
```
388388

389389
### Function Calling

google/genai/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
#
1515

16-
__version__ = '1.64.0' # x-release-please-version
16+
__version__ = '1.63.0' # x-release-please-version

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel", "twine>=6.1.0", "packaging>=24.2", "pkginfo>=
33

44
[project]
55
name = "google-genai"
6-
version = "1.64.0"
6+
version = "1.63.0"
77
description = "GenAI Python SDK"
88
readme = "README.md"
99
license = "Apache-2.0"

0 commit comments

Comments
 (0)