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
4 changes: 2 additions & 2 deletions google/genai/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,8 @@ async def _t_live_connect_config(
if parameter_model_copy.generation_config is not None:
warnings.warn(
'Setting `LiveConnectConfig.generation_config` is deprecated, '
'please set the fields on `LiveConnectConfig` directly. This will '
'become an error in a future version (not before Q3 2025)',
'please set the fields on `LiveConnectConfig` directly. It will be '
'removed in the next major version (not before 7/31/2026).',
DeprecationWarning,
stacklevel=4,
)
Expand Down
73 changes: 63 additions & 10 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import logging
from typing import Any, AsyncIterator, Awaitable, Iterator, Optional, Union
from urllib.parse import urlencode
import warnings

from . import _api_module
from . import _base_transformers as base_t
Expand Down Expand Up @@ -6362,6 +6363,8 @@ def _generate_videos(
self._api_client._verify_response(return_value)
return return_value

_logged_generate_videos_deprecation_warning = False

def embed_content(
self,
*,
Expand Down Expand Up @@ -6802,6 +6805,14 @@ def generate_content_stream(
automatic_function_calling_history.append(func_call_content)
automatic_function_calling_history.append(func_response_content)

@_common.experimental_warning(
'The generate_images method is deprecated and will be removed in the '
'next major release (not before Jan. 1 2027). Please use the '
'generate_content method with image models instead. '
'See https://ai.google.dev/gemini-api/docs/deprecations#imagen-models'
' and '
'https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/image-generation#generate-images',
)
def generate_images(
self,
*,
Expand Down Expand Up @@ -6857,6 +6868,12 @@ def generate_images(
)
return response

@_common.experimental_warning(
'The edit_image method is deprecated and will be removed in the next '
'major release (not before Jan. 1 2027). Please use the '
'generate_content method with image models instead. '
'See https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/gemini-edit-images#edit-an-image',
)
def edit_image(
self,
*,
Expand Down Expand Up @@ -7036,11 +7053,21 @@ def generate_videos(
operation.result.generated_videos[0].video.uri
```
"""
if (prompt or image or video) and source:
raise ValueError(
'Source and prompt/image/video are mutually exclusive.'
+ ' Please only use source.'
)
if prompt or image or video:
if source:
raise ValueError(
'Source and prompt/image/video are mutually exclusive.'
+ ' Please only use source.'
)
if not Models._logged_generate_videos_deprecation_warning:
warnings.warn(
'The generate_videos method with prompt/image/video arguments is'
' deprecated and will be removed in a future major release (not'
' before 2026-07-31). Please use the source argument instead.',
DeprecationWarning,
stacklevel=2,
)
Models._logged_generate_videos_deprecation_warning = True
# Gemini Developer API does not support video bytes.
video_dct: dict[str, Any] = {}
if not self._api_client.vertexai and video:
Expand Down Expand Up @@ -8572,6 +8599,8 @@ async def _generate_videos(
self._api_client._verify_response(return_value)
return return_value

_logged_generate_videos_deprecation_warning = False

async def generate_content(
self,
*,
Expand Down Expand Up @@ -9078,6 +9107,12 @@ async def stream_generator(): # type: ignore[no-untyped-def]

return stream_generator() # type: ignore[no-untyped-call, no-any-return]

@_common.experimental_warning(
'The edit_image method is deprecated and will be removed in the next '
'major release (not before Jan. 1 2027). Please use the '
'generate_content method with image models instead. '
'See https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/gemini-edit-images#edit-an-image',
)
async def edit_image(
self,
*,
Expand Down Expand Up @@ -9186,6 +9221,14 @@ async def list(
config,
)

@_common.experimental_warning(
'The generate_images method is deprecated and will be removed in the '
'next major release (not before Jan. 1 2027). Please use the '
'generate_content method with image models instead. '
'See https://ai.google.dev/gemini-api/docs/deprecations#imagen-models'
' and '
'https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/image-generation#generate-images',
)
async def generate_images(
self,
*,
Expand Down Expand Up @@ -9364,11 +9407,21 @@ async def generate_videos(
operation.result.generated_videos[0].video.uri
```
"""
if (prompt or image or video) and source:
raise ValueError(
'Source and prompt/image/video are mutually exclusive.'
+ ' Please only use source.'
)
if prompt or image or video:
if source:
raise ValueError(
'Source and prompt/image/video are mutually exclusive.'
+ ' Please only use source.'
)
if not AsyncModels._logged_generate_videos_deprecation_warning:
warnings.warn(
'The generate_videos method with prompt/image/video arguments is'
' deprecated and will be removed in a future major release (not'
' before 2026-07-31). Please use the source argument instead.',
DeprecationWarning,
stacklevel=2,
)
AsyncModels._logged_generate_videos_deprecation_warning = True
# Gemini Developer API does not support video bytes.
video_dct: dict[str, Any] = {}
if not self._api_client.vertexai and video:
Expand Down
Loading