Skip to content

Commit 5c008e1

Browse files
matthew29tangcopybara-github
authored andcommitted
feat: Add generation_output_config to GenerateContentConfig
PiperOrigin-RevId: 1003500044
1 parent 4c1abcc commit 5c008e1

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

‎google/genai/batches.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,12 @@ def _GenerateContentConfig_to_mldev(
11601160
getv(from_object, ['continuation_token']),
11611161
)
11621162

1163+
if getv(from_object, ['generation_output_config']) is not None:
1164+
raise ValueError(
1165+
'generation_output_config parameter is only supported in Gemini'
1166+
' Enterprise Agent Platform mode, not in Gemini Developer API mode.'
1167+
)
1168+
11631169
return to_object
11641170

11651171

‎google/genai/models.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,12 @@ def _GenerateContentConfig_to_mldev(
13491349
getv(from_object, ['continuation_token']),
13501350
)
13511351

1352+
if getv(from_object, ['generation_output_config']) is not None:
1353+
raise ValueError(
1354+
'generation_output_config parameter is only supported in Gemini'
1355+
' Enterprise Agent Platform mode, not in Gemini Developer API mode.'
1356+
)
1357+
13521358
return to_object
13531359

13541360

@@ -1553,6 +1559,13 @@ def _GenerateContentConfig_to_vertex(
15531559
getv(from_object, ['continuation_token']),
15541560
)
15551561

1562+
if getv(from_object, ['generation_output_config']) is not None:
1563+
setv(
1564+
parent_object,
1565+
['outputConfig'],
1566+
getv(from_object, ['generation_output_config']),
1567+
)
1568+
15561569
return to_object
15571570

15581571

‎google/genai/types.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5932,6 +5932,37 @@ class ImageConfigDict(TypedDict, total=False):
59325932
ImageConfigOrDict = Union[ImageConfig, ImageConfigDict]
59335933

59345934

5935+
class GenerationOutputConfig(_common.BaseModel):
5936+
"""Configuration for persisting output assets to external storage."""
5937+
5938+
output_uri_prefix: Optional[str] = Field(
5939+
default=None,
5940+
description="""Optional. The Cloud Storage URI prefix or directory where
5941+
generated media assets should be written (e.g. "gs://my-bucket/prefix/").
5942+
Supported URI schemes: "gs://". When set, media bytes are written directly
5943+
to this location and returned as FileData with a file_uri instead of raw
5944+
inline bytes.
5945+
""",
5946+
)
5947+
5948+
5949+
class GenerationOutputConfigDict(TypedDict, total=False):
5950+
"""Configuration for persisting output assets to external storage."""
5951+
5952+
output_uri_prefix: Optional[str]
5953+
"""Optional. The Cloud Storage URI prefix or directory where
5954+
generated media assets should be written (e.g. "gs://my-bucket/prefix/").
5955+
Supported URI schemes: "gs://". When set, media bytes are written directly
5956+
to this location and returned as FileData with a file_uri instead of raw
5957+
inline bytes.
5958+
"""
5959+
5960+
5961+
GenerationOutputConfigOrDict = Union[
5962+
GenerationOutputConfig, GenerationOutputConfigDict
5963+
]
5964+
5965+
59355966
class FileStatus(_common.BaseModel):
59365967
"""Status of a File that uses a common error model."""
59375968

@@ -6756,6 +6787,12 @@ class GenerateContentConfig(_common.BaseModel):
67566787
billing apply to each request. Set to false to turn this off.
67576788
""",
67586789
)
6790+
generation_output_config: Optional[GenerationOutputConfig] = Field(
6791+
default=None,
6792+
description="""Optional. Configuration for persisting output assets to external
6793+
storage.
6794+
""",
6795+
)
67596796

67606797
@pydantic.field_validator('response_schema', mode='before')
67616798
@classmethod
@@ -6990,6 +7027,11 @@ class GenerateContentConfigDict(TypedDict, total=False):
69907027
billing apply to each request. Set to false to turn this off.
69917028
"""
69927029

7030+
generation_output_config: Optional[GenerationOutputConfigDict]
7031+
"""Optional. Configuration for persisting output assets to external
7032+
storage.
7033+
"""
7034+
69937035

69947036
GenerateContentConfigOrDict = Union[
69957037
GenerateContentConfig, GenerateContentConfigDict

0 commit comments

Comments
 (0)