google-genai 1.55.0__py3-none-any.whl → 1.57.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. google/genai/_api_client.py +37 -18
  2. google/genai/_interactions/_base_client.py +8 -2
  3. google/genai/_interactions/resources/interactions.py +6 -6
  4. google/genai/_interactions/types/__init__.py +4 -0
  5. google/genai/_interactions/types/audio_content.py +0 -1
  6. google/genai/_interactions/types/audio_content_param.py +0 -1
  7. google/genai/_interactions/types/code_execution_call_content.py +0 -1
  8. google/genai/_interactions/types/code_execution_call_content_param.py +0 -1
  9. google/genai/_interactions/types/code_execution_result_content.py +0 -1
  10. google/genai/_interactions/types/code_execution_result_content_param.py +0 -1
  11. google/genai/_interactions/types/content.py +63 -0
  12. google/genai/_interactions/types/content_delta.py +7 -23
  13. google/genai/_interactions/types/content_param.py +61 -0
  14. google/genai/_interactions/types/content_start.py +4 -44
  15. google/genai/_interactions/types/deep_research_agent_config.py +0 -1
  16. google/genai/_interactions/types/deep_research_agent_config_param.py +0 -1
  17. google/genai/_interactions/types/document_content.py +3 -2
  18. google/genai/_interactions/types/document_content_param.py +3 -2
  19. google/genai/_interactions/types/document_mime_type.py +23 -0
  20. google/genai/_interactions/types/document_mime_type_param.py +25 -0
  21. google/genai/_interactions/types/dynamic_agent_config.py +0 -1
  22. google/genai/_interactions/types/dynamic_agent_config_param.py +0 -1
  23. google/genai/_interactions/types/file_search_result_content.py +0 -1
  24. google/genai/_interactions/types/file_search_result_content_param.py +0 -1
  25. google/genai/_interactions/types/function_call_content.py +0 -1
  26. google/genai/_interactions/types/function_call_content_param.py +0 -1
  27. google/genai/_interactions/types/function_result_content.py +1 -2
  28. google/genai/_interactions/types/function_result_content_param.py +1 -2
  29. google/genai/_interactions/types/google_search_call_content.py +0 -1
  30. google/genai/_interactions/types/google_search_call_content_param.py +0 -1
  31. google/genai/_interactions/types/google_search_result_content.py +0 -1
  32. google/genai/_interactions/types/google_search_result_content_param.py +0 -1
  33. google/genai/_interactions/types/image_content.py +1 -2
  34. google/genai/_interactions/types/image_content_param.py +1 -2
  35. google/genai/_interactions/types/interaction.py +4 -52
  36. google/genai/_interactions/types/interaction_create_params.py +2 -22
  37. google/genai/_interactions/types/mcp_server_tool_call_content.py +0 -1
  38. google/genai/_interactions/types/mcp_server_tool_call_content_param.py +0 -1
  39. google/genai/_interactions/types/mcp_server_tool_result_content.py +1 -2
  40. google/genai/_interactions/types/mcp_server_tool_result_content_param.py +1 -2
  41. google/genai/_interactions/types/model.py +1 -0
  42. google/genai/_interactions/types/model_param.py +1 -0
  43. google/genai/_interactions/types/text_content.py +0 -1
  44. google/genai/_interactions/types/text_content_param.py +0 -1
  45. google/genai/_interactions/types/thinking_level.py +1 -1
  46. google/genai/_interactions/types/thought_content.py +0 -1
  47. google/genai/_interactions/types/thought_content_param.py +0 -1
  48. google/genai/_interactions/types/turn.py +3 -44
  49. google/genai/_interactions/types/turn_param.py +4 -40
  50. google/genai/_interactions/types/url_context_call_content.py +0 -1
  51. google/genai/_interactions/types/url_context_call_content_param.py +0 -1
  52. google/genai/_interactions/types/url_context_result_content.py +0 -1
  53. google/genai/_interactions/types/url_context_result_content_param.py +0 -1
  54. google/genai/_interactions/types/usage.py +1 -1
  55. google/genai/_interactions/types/usage_param.py +1 -1
  56. google/genai/_interactions/types/video_content.py +1 -2
  57. google/genai/_interactions/types/video_content_param.py +1 -2
  58. google/genai/_live_converters.py +36 -64
  59. google/genai/_local_tokenizer_loader.py +1 -0
  60. google/genai/_tokens_converters.py +14 -14
  61. google/genai/batches.py +27 -22
  62. google/genai/caches.py +42 -42
  63. google/genai/chats.py +0 -2
  64. google/genai/client.py +3 -1
  65. google/genai/files.py +224 -0
  66. google/genai/models.py +57 -72
  67. google/genai/tests/chats/test_get_history.py +9 -8
  68. google/genai/tests/chats/test_validate_response.py +1 -1
  69. google/genai/tests/client/test_client_requests.py +1 -135
  70. google/genai/tests/files/test_register.py +272 -0
  71. google/genai/tests/files/test_register_table.py +70 -0
  72. google/genai/tests/interactions/test_auth.py +479 -0
  73. google/genai/tests/interactions/test_integration.py +2 -0
  74. google/genai/tests/interactions/test_paths.py +105 -0
  75. google/genai/tests/live/test_live.py +2 -36
  76. google/genai/tests/local_tokenizer/test_local_tokenizer.py +1 -1
  77. google/genai/tests/models/test_function_call_streaming.py +90 -90
  78. google/genai/tests/models/test_generate_content.py +1 -2
  79. google/genai/tests/models/test_recontext_image.py +1 -1
  80. google/genai/tests/pytest_helper.py +17 -0
  81. google/genai/tunings.py +1 -27
  82. google/genai/types.py +603 -518
  83. google/genai/version.py +1 -1
  84. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/METADATA +224 -22
  85. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/RECORD +88 -80
  86. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/WHEEL +0 -0
  87. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/licenses/LICENSE +0 -0
  88. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/top_level.txt +0 -0
@@ -984,12 +984,7 @@ class BaseApiClient:
984
984
  self.project = project
985
985
 
986
986
  if self._credentials:
987
- if self._credentials.expired or not self._credentials.token:
988
- # Only refresh when it needs to. Default expiration is 3600 seconds.
989
- refresh_auth(self._credentials)
990
- if not self._credentials.token:
991
- raise RuntimeError('Could not resolve API token from the environment')
992
- return self._credentials.token # type: ignore[no-any-return]
987
+ return get_token_from_credentials(self, self._credentials) # type: ignore[no-any-return]
993
988
  else:
994
989
  raise RuntimeError('Could not resolve API token from the environment')
995
990
 
@@ -1034,18 +1029,10 @@ class BaseApiClient:
1034
1029
  self.project = project
1035
1030
 
1036
1031
  if self._credentials:
1037
- if self._credentials.expired or not self._credentials.token:
1038
- # Only refresh when it needs to. Default expiration is 3600 seconds.
1039
- async_auth_lock = await self._get_async_auth_lock()
1040
- async with async_auth_lock:
1041
- if self._credentials.expired or not self._credentials.token:
1042
- # Double check that the credentials expired before refreshing.
1043
- await asyncio.to_thread(refresh_auth, self._credentials)
1044
-
1045
- if not self._credentials.token:
1046
- raise RuntimeError('Could not resolve API token from the environment')
1047
-
1048
- return self._credentials.token
1032
+ return await async_get_token_from_credentials(
1033
+ self,
1034
+ self._credentials
1035
+ ) # type: ignore[no-any-return]
1049
1036
  else:
1050
1037
  raise RuntimeError('Could not resolve API token from the environment')
1051
1038
 
@@ -1925,3 +1912,35 @@ class BaseApiClient:
1925
1912
  asyncio.get_running_loop().create_task(self.aclose())
1926
1913
  except Exception: # pylint: disable=broad-except
1927
1914
  pass
1915
+
1916
+ def get_token_from_credentials(
1917
+ client: 'BaseApiClient',
1918
+ credentials: google.auth.credentials.Credentials
1919
+ ) -> str:
1920
+ """Refreshes the authentication token for the given credentials."""
1921
+ if credentials.expired or not credentials.token:
1922
+ # Only refresh when it needs to. Default expiration is 3600 seconds.
1923
+ refresh_auth(credentials)
1924
+ if not credentials.token:
1925
+ raise RuntimeError('Could not resolve API token from the environment')
1926
+ return credentials.token # type: ignore[no-any-return]
1927
+
1928
+ async def async_get_token_from_credentials(
1929
+ client: 'BaseApiClient',
1930
+ credentials: google.auth.credentials.Credentials
1931
+ ) -> str:
1932
+ """Refreshes the authentication token for the given credentials."""
1933
+ if credentials.expired or not credentials.token:
1934
+ # Only refresh when it needs to. Default expiration is 3600 seconds.
1935
+ async_auth_lock = await client._get_async_auth_lock()
1936
+ async with async_auth_lock:
1937
+ if credentials.expired or not credentials.token:
1938
+ # Double check that the credentials expired before refreshing.
1939
+ await asyncio.to_thread(refresh_auth, credentials)
1940
+
1941
+ if not credentials.token:
1942
+ raise RuntimeError('Could not resolve API token from the environment')
1943
+
1944
+ return credentials.token # type: ignore[no-any-return]
1945
+
1946
+
@@ -1271,9 +1271,12 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1271
1271
  *,
1272
1272
  cast_to: Type[ResponseT],
1273
1273
  body: Body | None = None,
1274
+ files: RequestFiles | None = None,
1274
1275
  options: RequestOptions = {},
1275
1276
  ) -> ResponseT:
1276
- opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
1277
+ opts = FinalRequestOptions.construct(
1278
+ method="patch", url=path, json_data=body, files=to_httpx_files(files), **options
1279
+ )
1277
1280
  return self.request(cast_to, opts)
1278
1281
 
1279
1282
  def put(
@@ -1791,9 +1794,12 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1791
1794
  *,
1792
1795
  cast_to: Type[ResponseT],
1793
1796
  body: Body | None = None,
1797
+ files: RequestFiles | None = None,
1794
1798
  options: RequestOptions = {},
1795
1799
  ) -> ResponseT:
1796
- opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
1800
+ opts = FinalRequestOptions.construct(
1801
+ method="patch", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1802
+ )
1797
1803
  return await self.request(cast_to, opts)
1798
1804
 
1799
1805
  async def put(
@@ -475,7 +475,7 @@ class InteractionsResource(SyncAPIResource):
475
475
  if not api_version:
476
476
  raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
477
477
  return self._delete(
478
- f"/{api_version}/interactions/{id}",
478
+ self._client._build_maybe_vertex_path(api_version=api_version, path=f'interactions/{id}'),
479
479
  options=make_request_options(
480
480
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
481
481
  ),
@@ -514,7 +514,7 @@ class InteractionsResource(SyncAPIResource):
514
514
  if not api_version:
515
515
  raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
516
516
  return self._post(
517
- f"/{api_version}/interactions/{id}/cancel",
517
+ self._client._build_maybe_vertex_path(api_version=api_version, path=f'interactions/{id}/cancel'),
518
518
  options=make_request_options(
519
519
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
520
520
  ),
@@ -641,7 +641,7 @@ class InteractionsResource(SyncAPIResource):
641
641
  if not api_version:
642
642
  raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
643
643
  return self._get(
644
- f"/{api_version}/interactions/{id}",
644
+ self._client._build_maybe_vertex_path(api_version=api_version, path=f'interactions/{id}'),
645
645
  options=make_request_options(
646
646
  extra_headers=extra_headers,
647
647
  extra_query=extra_query,
@@ -1092,7 +1092,7 @@ class AsyncInteractionsResource(AsyncAPIResource):
1092
1092
  if not api_version:
1093
1093
  raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
1094
1094
  return await self._delete(
1095
- f"/{api_version}/interactions/{id}",
1095
+ self._client._build_maybe_vertex_path(api_version=api_version, path=f'interactions/{id}'),
1096
1096
  options=make_request_options(
1097
1097
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1098
1098
  ),
@@ -1131,7 +1131,7 @@ class AsyncInteractionsResource(AsyncAPIResource):
1131
1131
  if not api_version:
1132
1132
  raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
1133
1133
  return await self._post(
1134
- f"/{api_version}/interactions/{id}/cancel",
1134
+ self._client._build_maybe_vertex_path(api_version=api_version, path=f'interactions/{id}/cancel'),
1135
1135
  options=make_request_options(
1136
1136
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1137
1137
  ),
@@ -1258,7 +1258,7 @@ class AsyncInteractionsResource(AsyncAPIResource):
1258
1258
  if not api_version:
1259
1259
  raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
1260
1260
  return await self._get(
1261
- f"/{api_version}/interactions/{id}",
1261
+ self._client._build_maybe_vertex_path(api_version=api_version, path=f'interactions/{id}'),
1262
1262
  options=make_request_options(
1263
1263
  extra_headers=extra_headers,
1264
1264
  extra_query=extra_query,
@@ -21,6 +21,7 @@ from .tool import Tool as Tool
21
21
  from .turn import Turn as Turn
22
22
  from .model import Model as Model
23
23
  from .usage import Usage as Usage
24
+ from .content import Content as Content
24
25
  from .function import Function as Function
25
26
  from .annotation import Annotation as Annotation
26
27
  from .tool_param import ToolParam as ToolParam
@@ -35,6 +36,7 @@ from .text_content import TextContent as TextContent
35
36
  from .allowed_tools import AllowedTools as AllowedTools
36
37
  from .audio_content import AudioContent as AudioContent
37
38
  from .content_delta import ContentDelta as ContentDelta
39
+ from .content_param import ContentParam as ContentParam
38
40
  from .content_start import ContentStart as ContentStart
39
41
  from .image_content import ImageContent as ImageContent
40
42
  from .speech_config import SpeechConfig as SpeechConfig
@@ -51,6 +53,7 @@ from .tool_choice_type import ToolChoiceType as ToolChoiceType
51
53
  from .generation_config import GenerationConfig as GenerationConfig
52
54
  from .interaction_event import InteractionEvent as InteractionEvent
53
55
  from .tool_choice_param import ToolChoiceParam as ToolChoiceParam
56
+ from .document_mime_type import DocumentMimeType as DocumentMimeType
54
57
  from .text_content_param import TextContentParam as TextContentParam
55
58
  from .tool_choice_config import ToolChoiceConfig as ToolChoiceConfig
56
59
  from .url_context_result import URLContextResult as URLContextResult
@@ -71,6 +74,7 @@ from .document_content_param import DocumentContentParam as DocumentContentParam
71
74
  from .interaction_get_params import InteractionGetParams as InteractionGetParams
72
75
  from .function_result_content import FunctionResultContent as FunctionResultContent
73
76
  from .generation_config_param import GenerationConfigParam as GenerationConfigParam
77
+ from .document_mime_type_param import DocumentMimeTypeParam as DocumentMimeTypeParam
74
78
  from .tool_choice_config_param import ToolChoiceConfigParam as ToolChoiceConfigParam
75
79
  from .url_context_call_content import URLContextCallContent as URLContextCallContent
76
80
  from .url_context_result_param import URLContextResultParam as URLContextResultParam
@@ -28,7 +28,6 @@ class AudioContent(BaseModel):
28
28
  """An audio content block."""
29
29
 
30
30
  type: Literal["audio"]
31
- """Used as the OpenAPI type discriminator for the content oneof."""
32
31
 
33
32
  data: Optional[str] = None
34
33
 
@@ -32,7 +32,6 @@ class AudioContentParam(TypedDict, total=False):
32
32
  """An audio content block."""
33
33
 
34
34
  type: Required[Literal["audio"]]
35
- """Used as the OpenAPI type discriminator for the content oneof."""
36
35
 
37
36
  data: Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]
38
37
 
@@ -28,7 +28,6 @@ class CodeExecutionCallContent(BaseModel):
28
28
  """Code execution content."""
29
29
 
30
30
  type: Literal["code_execution_call"]
31
- """Used as the OpenAPI type discriminator for the content oneof."""
32
31
 
33
32
  id: Optional[str] = None
34
33
  """A unique ID for this specific tool call."""
@@ -28,7 +28,6 @@ class CodeExecutionCallContentParam(TypedDict, total=False):
28
28
  """Code execution content."""
29
29
 
30
30
  type: Required[Literal["code_execution_call"]]
31
- """Used as the OpenAPI type discriminator for the content oneof."""
32
31
 
33
32
  id: str
34
33
  """A unique ID for this specific tool call."""
@@ -27,7 +27,6 @@ class CodeExecutionResultContent(BaseModel):
27
27
  """Code execution result content."""
28
28
 
29
29
  type: Literal["code_execution_result"]
30
- """Used as the OpenAPI type discriminator for the content oneof."""
31
30
 
32
31
  call_id: Optional[str] = None
33
32
  """ID to match the ID from the code execution call block."""
@@ -26,7 +26,6 @@ class CodeExecutionResultContentParam(TypedDict, total=False):
26
26
  """Code execution result content."""
27
27
 
28
28
  type: Required[Literal["code_execution_result"]]
29
- """Used as the OpenAPI type discriminator for the content oneof."""
30
29
 
31
30
  call_id: str
32
31
  """ID to match the ID from the code execution call block."""
@@ -0,0 +1,63 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17
+
18
+ from typing import Union
19
+ from typing_extensions import Annotated, TypeAlias
20
+
21
+ from .._utils import PropertyInfo
22
+ from .text_content import TextContent
23
+ from .audio_content import AudioContent
24
+ from .image_content import ImageContent
25
+ from .video_content import VideoContent
26
+ from .thought_content import ThoughtContent
27
+ from .document_content import DocumentContent
28
+ from .function_call_content import FunctionCallContent
29
+ from .function_result_content import FunctionResultContent
30
+ from .url_context_call_content import URLContextCallContent
31
+ from .file_search_result_content import FileSearchResultContent
32
+ from .google_search_call_content import GoogleSearchCallContent
33
+ from .url_context_result_content import URLContextResultContent
34
+ from .code_execution_call_content import CodeExecutionCallContent
35
+ from .google_search_result_content import GoogleSearchResultContent
36
+ from .mcp_server_tool_call_content import MCPServerToolCallContent
37
+ from .code_execution_result_content import CodeExecutionResultContent
38
+ from .mcp_server_tool_result_content import MCPServerToolResultContent
39
+
40
+ __all__ = ["Content"]
41
+
42
+ Content: TypeAlias = Annotated[
43
+ Union[
44
+ TextContent,
45
+ ImageContent,
46
+ AudioContent,
47
+ DocumentContent,
48
+ VideoContent,
49
+ ThoughtContent,
50
+ FunctionCallContent,
51
+ FunctionResultContent,
52
+ CodeExecutionCallContent,
53
+ CodeExecutionResultContent,
54
+ URLContextCallContent,
55
+ URLContextResultContent,
56
+ GoogleSearchCallContent,
57
+ GoogleSearchResultContent,
58
+ MCPServerToolCallContent,
59
+ MCPServerToolResultContent,
60
+ FileSearchResultContent,
61
+ ],
62
+ PropertyInfo(discriminator="type"),
63
+ ]
@@ -26,6 +26,7 @@ from .image_content import ImageContent
26
26
  from .audio_mime_type import AudioMimeType
27
27
  from .image_mime_type import ImageMimeType
28
28
  from .video_mime_type import VideoMimeType
29
+ from .document_mime_type import DocumentMimeType
29
30
  from .url_context_result import URLContextResult
30
31
  from .google_search_result import GoogleSearchResult
31
32
  from .url_context_call_arguments import URLContextCallArguments
@@ -66,7 +67,6 @@ __all__ = [
66
67
 
67
68
  class DeltaTextDelta(BaseModel):
68
69
  type: Literal["text"]
69
- """Used as the OpenAPI type discriminator for the content oneof."""
70
70
 
71
71
  annotations: Optional[List[Annotation]] = None
72
72
  """Citation information for model-generated content."""
@@ -76,14 +76,13 @@ class DeltaTextDelta(BaseModel):
76
76
 
77
77
  class DeltaImageDelta(BaseModel):
78
78
  type: Literal["image"]
79
- """Used as the OpenAPI type discriminator for the content oneof."""
80
79
 
81
80
  data: Optional[str] = None
82
81
 
83
82
  mime_type: Optional[ImageMimeType] = None
84
83
  """The mime type of the image."""
85
84
 
86
- resolution: Optional[Literal["low", "medium", "high"]] = None
85
+ resolution: Optional[Literal["low", "medium", "high", "ultra_high"]] = None
87
86
  """The resolution of the media."""
88
87
 
89
88
  uri: Optional[str] = None
@@ -91,7 +90,6 @@ class DeltaImageDelta(BaseModel):
91
90
 
92
91
  class DeltaAudioDelta(BaseModel):
93
92
  type: Literal["audio"]
94
- """Used as the OpenAPI type discriminator for the content oneof."""
95
93
 
96
94
  data: Optional[str] = None
97
95
 
@@ -103,25 +101,24 @@ class DeltaAudioDelta(BaseModel):
103
101
 
104
102
  class DeltaDocumentDelta(BaseModel):
105
103
  type: Literal["document"]
106
- """Used as the OpenAPI type discriminator for the content oneof."""
107
104
 
108
105
  data: Optional[str] = None
109
106
 
110
- mime_type: Optional[str] = None
107
+ mime_type: Optional[DocumentMimeType] = None
108
+ """The mime type of the document."""
111
109
 
112
110
  uri: Optional[str] = None
113
111
 
114
112
 
115
113
  class DeltaVideoDelta(BaseModel):
116
114
  type: Literal["video"]
117
- """Used as the OpenAPI type discriminator for the content oneof."""
118
115
 
119
116
  data: Optional[str] = None
120
117
 
121
118
  mime_type: Optional[VideoMimeType] = None
122
119
  """The mime type of the video."""
123
120
 
124
- resolution: Optional[Literal["low", "medium", "high"]] = None
121
+ resolution: Optional[Literal["low", "medium", "high", "ultra_high"]] = None
125
122
  """The resolution of the media."""
126
123
 
127
124
  uri: Optional[str] = None
@@ -134,7 +131,6 @@ DeltaThoughtSummaryDeltaContent: TypeAlias = Annotated[
134
131
 
135
132
  class DeltaThoughtSummaryDelta(BaseModel):
136
133
  type: Literal["thought_summary"]
137
- """Used as the OpenAPI type discriminator for the content oneof."""
138
134
 
139
135
  content: Optional[DeltaThoughtSummaryDeltaContent] = None
140
136
  """A text content block."""
@@ -142,7 +138,6 @@ class DeltaThoughtSummaryDelta(BaseModel):
142
138
 
143
139
  class DeltaThoughtSignatureDelta(BaseModel):
144
140
  type: Literal["thought_signature"]
145
- """Used as the OpenAPI type discriminator for the content oneof."""
146
141
 
147
142
  signature: Optional[str] = None
148
143
  """Signature to match the backend source to be part of the generation."""
@@ -150,7 +145,6 @@ class DeltaThoughtSignatureDelta(BaseModel):
150
145
 
151
146
  class DeltaFunctionCallDelta(BaseModel):
152
147
  type: Literal["function_call"]
153
- """Used as the OpenAPI type discriminator for the content oneof."""
154
148
 
155
149
  id: Optional[str] = None
156
150
  """A unique ID for this specific tool call."""
@@ -160,7 +154,7 @@ class DeltaFunctionCallDelta(BaseModel):
160
154
  name: Optional[str] = None
161
155
 
162
156
 
163
- DeltaFunctionResultDeltaResultItemsItem: TypeAlias = Union[str, ImageContent]
157
+ DeltaFunctionResultDeltaResultItemsItem: TypeAlias = Union[str, ImageContent, object]
164
158
 
165
159
 
166
160
  class DeltaFunctionResultDeltaResultItems(BaseModel):
@@ -172,7 +166,6 @@ DeltaFunctionResultDeltaResult: TypeAlias = Union[DeltaFunctionResultDeltaResult
172
166
 
173
167
  class DeltaFunctionResultDelta(BaseModel):
174
168
  type: Literal["function_result"]
175
- """Used as the OpenAPI type discriminator for the content oneof."""
176
169
 
177
170
  call_id: Optional[str] = None
178
171
  """ID to match the ID from the function call block."""
@@ -187,7 +180,6 @@ class DeltaFunctionResultDelta(BaseModel):
187
180
 
188
181
  class DeltaCodeExecutionCallDelta(BaseModel):
189
182
  type: Literal["code_execution_call"]
190
- """Used as the OpenAPI type discriminator for the content oneof."""
191
183
 
192
184
  id: Optional[str] = None
193
185
  """A unique ID for this specific tool call."""
@@ -198,7 +190,6 @@ class DeltaCodeExecutionCallDelta(BaseModel):
198
190
 
199
191
  class DeltaCodeExecutionResultDelta(BaseModel):
200
192
  type: Literal["code_execution_result"]
201
- """Used as the OpenAPI type discriminator for the content oneof."""
202
193
 
203
194
  call_id: Optional[str] = None
204
195
  """ID to match the ID from the function call block."""
@@ -212,7 +203,6 @@ class DeltaCodeExecutionResultDelta(BaseModel):
212
203
 
213
204
  class DeltaURLContextCallDelta(BaseModel):
214
205
  type: Literal["url_context_call"]
215
- """Used as the OpenAPI type discriminator for the content oneof."""
216
206
 
217
207
  id: Optional[str] = None
218
208
  """A unique ID for this specific tool call."""
@@ -223,7 +213,6 @@ class DeltaURLContextCallDelta(BaseModel):
223
213
 
224
214
  class DeltaURLContextResultDelta(BaseModel):
225
215
  type: Literal["url_context_result"]
226
- """Used as the OpenAPI type discriminator for the content oneof."""
227
216
 
228
217
  call_id: Optional[str] = None
229
218
  """ID to match the ID from the function call block."""
@@ -237,7 +226,6 @@ class DeltaURLContextResultDelta(BaseModel):
237
226
 
238
227
  class DeltaGoogleSearchCallDelta(BaseModel):
239
228
  type: Literal["google_search_call"]
240
- """Used as the OpenAPI type discriminator for the content oneof."""
241
229
 
242
230
  id: Optional[str] = None
243
231
  """A unique ID for this specific tool call."""
@@ -248,7 +236,6 @@ class DeltaGoogleSearchCallDelta(BaseModel):
248
236
 
249
237
  class DeltaGoogleSearchResultDelta(BaseModel):
250
238
  type: Literal["google_search_result"]
251
- """Used as the OpenAPI type discriminator for the content oneof."""
252
239
 
253
240
  call_id: Optional[str] = None
254
241
  """ID to match the ID from the function call block."""
@@ -262,7 +249,6 @@ class DeltaGoogleSearchResultDelta(BaseModel):
262
249
 
263
250
  class DeltaMCPServerToolCallDelta(BaseModel):
264
251
  type: Literal["mcp_server_tool_call"]
265
- """Used as the OpenAPI type discriminator for the content oneof."""
266
252
 
267
253
  id: Optional[str] = None
268
254
  """A unique ID for this specific tool call."""
@@ -274,7 +260,7 @@ class DeltaMCPServerToolCallDelta(BaseModel):
274
260
  server_name: Optional[str] = None
275
261
 
276
262
 
277
- DeltaMCPServerToolResultDeltaResultItemsItem: TypeAlias = Union[str, ImageContent]
263
+ DeltaMCPServerToolResultDeltaResultItemsItem: TypeAlias = Union[str, ImageContent, object]
278
264
 
279
265
 
280
266
  class DeltaMCPServerToolResultDeltaResultItems(BaseModel):
@@ -286,7 +272,6 @@ DeltaMCPServerToolResultDeltaResult: TypeAlias = Union[DeltaMCPServerToolResultD
286
272
 
287
273
  class DeltaMCPServerToolResultDelta(BaseModel):
288
274
  type: Literal["mcp_server_tool_result"]
289
- """Used as the OpenAPI type discriminator for the content oneof."""
290
275
 
291
276
  call_id: Optional[str] = None
292
277
  """ID to match the ID from the function call block."""
@@ -314,7 +299,6 @@ class DeltaFileSearchResultDeltaResult(BaseModel):
314
299
 
315
300
  class DeltaFileSearchResultDelta(BaseModel):
316
301
  type: Literal["file_search_result"]
317
- """Used as the OpenAPI type discriminator for the content oneof."""
318
302
 
319
303
  result: Optional[List[DeltaFileSearchResultDeltaResult]] = None
320
304
 
@@ -0,0 +1,61 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17
+
18
+ from __future__ import annotations
19
+
20
+ from typing import Union
21
+ from typing_extensions import TypeAlias
22
+
23
+ from .text_content_param import TextContentParam
24
+ from .audio_content_param import AudioContentParam
25
+ from .image_content_param import ImageContentParam
26
+ from .video_content_param import VideoContentParam
27
+ from .thought_content_param import ThoughtContentParam
28
+ from .document_content_param import DocumentContentParam
29
+ from .function_call_content_param import FunctionCallContentParam
30
+ from .function_result_content_param import FunctionResultContentParam
31
+ from .url_context_call_content_param import URLContextCallContentParam
32
+ from .file_search_result_content_param import FileSearchResultContentParam
33
+ from .google_search_call_content_param import GoogleSearchCallContentParam
34
+ from .url_context_result_content_param import URLContextResultContentParam
35
+ from .code_execution_call_content_param import CodeExecutionCallContentParam
36
+ from .google_search_result_content_param import GoogleSearchResultContentParam
37
+ from .mcp_server_tool_call_content_param import MCPServerToolCallContentParam
38
+ from .code_execution_result_content_param import CodeExecutionResultContentParam
39
+ from .mcp_server_tool_result_content_param import MCPServerToolResultContentParam
40
+
41
+ __all__ = ["ContentParam"]
42
+
43
+ ContentParam: TypeAlias = Union[
44
+ TextContentParam,
45
+ ImageContentParam,
46
+ AudioContentParam,
47
+ DocumentContentParam,
48
+ VideoContentParam,
49
+ ThoughtContentParam,
50
+ FunctionCallContentParam,
51
+ FunctionResultContentParam,
52
+ CodeExecutionCallContentParam,
53
+ CodeExecutionResultContentParam,
54
+ URLContextCallContentParam,
55
+ URLContextResultContentParam,
56
+ GoogleSearchCallContentParam,
57
+ GoogleSearchResultContentParam,
58
+ MCPServerToolCallContentParam,
59
+ MCPServerToolResultContentParam,
60
+ FileSearchResultContentParam,
61
+ ]
@@ -15,53 +15,13 @@
15
15
 
16
16
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17
17
 
18
- from typing import Union, Optional
19
- from typing_extensions import Literal, Annotated, TypeAlias
18
+ from typing import Optional
19
+ from typing_extensions import Literal
20
20
 
21
- from .._utils import PropertyInfo
21
+ from .content import Content
22
22
  from .._models import BaseModel
23
- from .text_content import TextContent
24
- from .audio_content import AudioContent
25
- from .image_content import ImageContent
26
- from .video_content import VideoContent
27
- from .thought_content import ThoughtContent
28
- from .document_content import DocumentContent
29
- from .function_call_content import FunctionCallContent
30
- from .function_result_content import FunctionResultContent
31
- from .url_context_call_content import URLContextCallContent
32
- from .file_search_result_content import FileSearchResultContent
33
- from .google_search_call_content import GoogleSearchCallContent
34
- from .url_context_result_content import URLContextResultContent
35
- from .code_execution_call_content import CodeExecutionCallContent
36
- from .google_search_result_content import GoogleSearchResultContent
37
- from .mcp_server_tool_call_content import MCPServerToolCallContent
38
- from .code_execution_result_content import CodeExecutionResultContent
39
- from .mcp_server_tool_result_content import MCPServerToolResultContent
40
23
 
41
- __all__ = ["ContentStart", "Content"]
42
-
43
- Content: TypeAlias = Annotated[
44
- Union[
45
- TextContent,
46
- ImageContent,
47
- AudioContent,
48
- DocumentContent,
49
- VideoContent,
50
- ThoughtContent,
51
- FunctionCallContent,
52
- FunctionResultContent,
53
- CodeExecutionCallContent,
54
- CodeExecutionResultContent,
55
- URLContextCallContent,
56
- URLContextResultContent,
57
- GoogleSearchCallContent,
58
- GoogleSearchResultContent,
59
- MCPServerToolCallContent,
60
- MCPServerToolResultContent,
61
- FileSearchResultContent,
62
- ],
63
- PropertyInfo(discriminator="type"),
64
- ]
24
+ __all__ = ["ContentStart"]
65
25
 
66
26
 
67
27
  class ContentStart(BaseModel):
@@ -30,4 +30,3 @@ class DeepResearchAgentConfig(BaseModel):
30
30
  """Whether to include thought summaries in the response."""
31
31
 
32
32
  type: Optional[Literal["deep-research"]] = None
33
- """Used as the OpenAPI type discriminator for the content oneof."""
@@ -29,4 +29,3 @@ class DeepResearchAgentConfigParam(TypedDict, total=False):
29
29
  """Whether to include thought summaries in the response."""
30
30
 
31
31
  type: Literal["deep-research"]
32
- """Used as the OpenAPI type discriminator for the content oneof."""
@@ -19,6 +19,7 @@ from typing import Optional
19
19
  from typing_extensions import Literal
20
20
 
21
21
  from .._models import BaseModel
22
+ from .document_mime_type import DocumentMimeType
22
23
 
23
24
  __all__ = ["DocumentContent"]
24
25
 
@@ -27,10 +28,10 @@ class DocumentContent(BaseModel):
27
28
  """A document content block."""
28
29
 
29
30
  type: Literal["document"]
30
- """Used as the OpenAPI type discriminator for the content oneof."""
31
31
 
32
32
  data: Optional[str] = None
33
33
 
34
- mime_type: Optional[str] = None
34
+ mime_type: Optional[DocumentMimeType] = None
35
+ """The mime type of the document."""
35
36
 
36
37
  uri: Optional[str] = None
@@ -23,6 +23,7 @@ from typing_extensions import Literal, Required, Annotated, TypedDict
23
23
  from .._types import Base64FileInput
24
24
  from .._utils import PropertyInfo
25
25
  from .._models import set_pydantic_config
26
+ from .document_mime_type_param import DocumentMimeTypeParam
26
27
 
27
28
  __all__ = ["DocumentContentParam"]
28
29
 
@@ -31,11 +32,11 @@ class DocumentContentParam(TypedDict, total=False):
31
32
  """A document content block."""
32
33
 
33
34
  type: Required[Literal["document"]]
34
- """Used as the OpenAPI type discriminator for the content oneof."""
35
35
 
36
36
  data: Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]
37
37
 
38
- mime_type: str
38
+ mime_type: DocumentMimeTypeParam
39
+ """The mime type of the document."""
39
40
 
40
41
  uri: str
41
42