Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Changelog

## [2.2.0](https://github.com/googleapis/python-genai/compare/v2.1.0...v2.2.0) (2026-05-12)


### Features

* Added missing FunctionCallResultDelta type and `arguments` field to the ArgumentDelta type ([b0131f8](https://github.com/googleapis/python-genai/commit/b0131f80c2da97926bcef00b4abef9334272ee7a))

## [2.1.0](https://github.com/googleapis/python-genai/compare/v2.0.1...v2.1.0) (2026-05-12)


Expand Down
13 changes: 13 additions & 0 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,13 @@ def _LiveConnectConfig_to_mldev(
],
)

if getv(from_object, ['stream_translation_config']) is not None:
setv(
parent_object,
['setup', 'generationConfig', 'streamTranslationConfig'],
getv(from_object, ['stream_translation_config']),
)

return to_object


Expand Down Expand Up @@ -1113,6 +1120,12 @@ def _LiveConnectConfig_to_vertex(
[item for item in getv(from_object, ['safety_settings'])],
)

if getv(from_object, ['stream_translation_config']) is not None:
raise ValueError(
'stream_translation_config parameter is only supported in Gemini'
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object


Expand Down
7 changes: 7 additions & 0 deletions google/genai/_tokens_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ def _LiveConnectConfig_to_mldev(
],
)

if getv(from_object, ['stream_translation_config']) is not None:
setv(
parent_object,
['setup', 'generationConfig', 'streamTranslationConfig'],
getv(from_object, ['stream_translation_config']),
)

return to_object


Expand Down
49 changes: 49 additions & 0 deletions google/genai/tests/live/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,55 @@ async def test_bidi_setup_to_api_with_transparent_session_resumption(vertexai):
assert result == expected_result


@pytest.mark.parametrize('vertexai', [True, False])
@pytest.mark.asyncio
async def test_bidi_setup_to_api_with_stream_translation_config(vertexai):
api_client = mock_api_client(vertexai=vertexai)

# Test 1: Config defined using dict representation.
config_dict = {
'stream_translation_config': {
'echo_target_language': True,
'target_language_code': 'es',
},
}

with pytest_helper.exception_if_vertex(api_client, ValueError):
result = await get_connect_message(
api_client=api_client, model='test_model', config=config_dict
)

if not vertexai:
expected_result = {
'setup': {
'model': 'models/test_model',
'generationConfig': {
'streamTranslationConfig': {
'echo_target_language': True,
'target_language_code': 'es',
},
},
}
}
assert result == expected_result

# Test 2: Config defined using types.LiveConnectConfig.
config = types.LiveConnectConfig(
stream_translation_config=types.StreamTranslationConfig(
echo_target_language=True,
target_language_code='es',
)
)

with pytest_helper.exception_if_vertex(api_client, ValueError):
result = await get_connect_message(
api_client=api_client, model='test_model', config=config
)

if not vertexai:
assert result == expected_result


@pytest.mark.parametrize('vertexai', [True, False])
def test_parse_client_message_str( mock_websocket, vertexai):
session = live.AsyncSession(
Expand Down
40 changes: 40 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19507,6 +19507,40 @@ class RealtimeInputConfigDict(TypedDict, total=False):
RealtimeInputConfigOrDict = Union[RealtimeInputConfig, RealtimeInputConfigDict]


class StreamTranslationConfig(_common.BaseModel):
"""Config for stream translation."""

echo_target_language: Optional[bool] = Field(
default=None,
description="""If true, the model will generate audio when the target language is
spoken, essentially it will parrot the input. If false, we will not produce
audio for the target language.""",
)
target_language_code: Optional[str] = Field(
default=None,
description="""The target language for translation. Supported values are BCP-47
language codes (e.g. "en", "es", "fr").""",
)


class StreamTranslationConfigDict(TypedDict, total=False):
"""Config for stream translation."""

echo_target_language: Optional[bool]
"""If true, the model will generate audio when the target language is
spoken, essentially it will parrot the input. If false, we will not produce
audio for the target language."""

target_language_code: Optional[str]
"""The target language for translation. Supported values are BCP-47
language codes (e.g. "en", "es", "fr")."""


StreamTranslationConfigOrDict = Union[
StreamTranslationConfig, StreamTranslationConfigDict
]


class LiveConnectConfig(_common.BaseModel):
"""Session config for the API connection."""

Expand Down Expand Up @@ -19645,6 +19679,9 @@ class LiveConnectConfig(_common.BaseModel):
response.
""",
)
stream_translation_config: Optional[StreamTranslationConfig] = Field(
default=None, description="""Config for stream translation."""
)


class LiveConnectConfigDict(TypedDict, total=False):
Expand Down Expand Up @@ -19763,6 +19800,9 @@ class LiveConnectConfigDict(TypedDict, total=False):
response.
"""

stream_translation_config: Optional[StreamTranslationConfigDict]
"""Config for stream translation."""


LiveConnectConfigOrDict = Union[LiveConnectConfig, LiveConnectConfigDict]

Expand Down
2 changes: 1 addition & 1 deletion google/genai/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.
#

__version__ = '2.2.0' # x-release-please-version
__version__ = '2.1.0' # x-release-please-version
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools", "wheel", "twine>=6.1.0", "packaging>=24.2", "pkginfo>=

[project]
name = "google-genai"
version = "2.2.0"
version = "2.1.0"
description = "GenAI Python SDK"
readme = "README.md"
license = "Apache-2.0"
Expand Down
Loading