google-genai 1.22.0__py3-none-any.whl → 1.24.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-genai
3
- Version: 1.22.0
3
+ Version: 1.24.0
4
4
  Summary: GenAI Python SDK
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -743,6 +743,53 @@ response = client.models.generate_content(
743
743
  ),
744
744
  )
745
745
  ```
746
+
747
+ #### Model Context Protocol (MCP) support (experimental)
748
+
749
+ Built-in [MCP](https://modelcontextprotocol.io/introduction) support is an
750
+ experimental feature. You can pass a local MCP server as a tool directly.
751
+
752
+ ```python
753
+ import os
754
+ import asyncio
755
+ from datetime import datetime
756
+ from mcp import ClientSession, StdioServerParameters
757
+ from mcp.client.stdio import stdio_client
758
+ from google import genai
759
+
760
+ client = genai.Client()
761
+
762
+ # Create server parameters for stdio connection
763
+ server_params = StdioServerParameters(
764
+ command="npx", # Executable
765
+ args=["-y", "@philschmid/weather-mcp"], # MCP Server
766
+ env=None, # Optional environment variables
767
+ )
768
+
769
+ async def run():
770
+ async with stdio_client(server_params) as (read, write):
771
+ async with ClientSession(read, write) as session:
772
+ # Prompt to get the weather for the current day in London.
773
+ prompt = f"What is the weather in London in {datetime.now().strftime('%Y-%m-%d')}?"
774
+
775
+ # Initialize the connection between client and server
776
+ await session.initialize()
777
+
778
+ # Send request to the model with MCP function declarations
779
+ response = await client.aio.models.generate_content(
780
+ model="gemini-2.5-flash",
781
+ contents=prompt,
782
+ config=genai.types.GenerateContentConfig(
783
+ temperature=0,
784
+ tools=[session], # uses the session, will automatically call the tool using automatic function calling
785
+ ),
786
+ )
787
+ print(response.text)
788
+
789
+ # Start the asyncio event loop and run the main function
790
+ asyncio.run(run())
791
+ ```
792
+
746
793
  ### JSON Response Schema
747
794
 
748
795
  However you define your schema, don't duplicate it in your input prompt,
@@ -1085,9 +1132,9 @@ response3.generated_images[0].image.show()
1085
1132
 
1086
1133
  ### Veo
1087
1134
 
1088
- #### Generate Videos
1135
+ Support for generating videos is considered public preview
1089
1136
 
1090
- Support for generate videos in Vertex and Gemini Developer API is behind an allowlist
1137
+ #### Generate Videos (Text to Video)
1091
1138
 
1092
1139
  ```python
1093
1140
  from google.genai import types
@@ -1098,7 +1145,6 @@ operation = client.models.generate_videos(
1098
1145
  prompt='A neon hologram of a cat driving at top speed',
1099
1146
  config=types.GenerateVideosConfig(
1100
1147
  number_of_videos=1,
1101
- fps=24,
1102
1148
  duration_seconds=5,
1103
1149
  enhance_prompt=True,
1104
1150
  ),
@@ -1109,7 +1155,73 @@ while not operation.done:
1109
1155
  time.sleep(20)
1110
1156
  operation = client.operations.get(operation)
1111
1157
 
1112
- video = operation.result.generated_videos[0].video
1158
+ video = operation.response.generated_videos[0].video
1159
+ video.show()
1160
+ ```
1161
+
1162
+ #### Generate Videos (Image to Video)
1163
+
1164
+ ```python
1165
+ from google.genai import types
1166
+
1167
+ # Read local image (uses mimetypes.guess_type to infer mime type)
1168
+ image = types.Image.from_file("local/path/file.png")
1169
+
1170
+ # Create operation
1171
+ operation = client.models.generate_videos(
1172
+ model='veo-2.0-generate-001',
1173
+ # Prompt is optional if image is provided
1174
+ prompt='Night sky',
1175
+ image=image,
1176
+ config=types.GenerateVideosConfig(
1177
+ number_of_videos=1,
1178
+ duration_seconds=5,
1179
+ enhance_prompt=True,
1180
+ # Can also pass an Image into last_frame for frame interpolation
1181
+ ),
1182
+ )
1183
+
1184
+ # Poll operation
1185
+ while not operation.done:
1186
+ time.sleep(20)
1187
+ operation = client.operations.get(operation)
1188
+
1189
+ video = operation.response.generated_videos[0].video
1190
+ video.show()
1191
+ ```
1192
+
1193
+ #### Generate Videos (Video to Video)
1194
+
1195
+ Currently, only Vertex supports Video to Video generation (Video extension).
1196
+
1197
+ ```python
1198
+ from google.genai import types
1199
+
1200
+ # Read local video (uses mimetypes.guess_type to infer mime type)
1201
+ video = types.Video.from_file("local/path/video.mp4")
1202
+
1203
+ # Create operation
1204
+ operation = client.models.generate_videos(
1205
+ model='veo-2.0-generate-001',
1206
+ # Prompt is optional if Video is provided
1207
+ prompt='Night sky',
1208
+ # Input video must be in GCS
1209
+ video=types.Video(
1210
+ uri="gs://bucket-name/inputs/videos/cat_driving.mp4",
1211
+ ),
1212
+ config=types.GenerateVideosConfig(
1213
+ number_of_videos=1,
1214
+ duration_seconds=5,
1215
+ enhance_prompt=True,
1216
+ ),
1217
+ )
1218
+
1219
+ # Poll operation
1220
+ while not operation.done:
1221
+ time.sleep(20)
1222
+ operation = client.operations.get(operation)
1223
+
1224
+ video = operation.response.generated_videos[0].video
1113
1225
  video.show()
1114
1226
  ```
1115
1227
 
@@ -1260,7 +1372,7 @@ client.
1260
1372
 
1261
1373
  ### Tune
1262
1374
 
1263
- - Vertex AI supports tuning from GCS source
1375
+ - Vertex AI supports tuning from GCS source or from a Vertex Multimodal Dataset
1264
1376
  - Gemini Developer API supports tuning from inline examples
1265
1377
 
1266
1378
  ```python
@@ -1269,10 +1381,12 @@ from google.genai import types
1269
1381
  if client.vertexai:
1270
1382
  model = 'gemini-2.0-flash-001'
1271
1383
  training_dataset = types.TuningDataset(
1384
+ # or gcs_uri=my_vertex_multimodal_dataset
1272
1385
  gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
1273
1386
  )
1274
1387
  else:
1275
1388
  model = 'models/gemini-2.0-flash-001'
1389
+ # or gcs_uri=my_vertex_multimodal_dataset.resource_name
1276
1390
  training_dataset = types.TuningDataset(
1277
1391
  examples=[
1278
1392
  types.TuningExample(
@@ -1,35 +1,35 @@
1
1
  google/genai/__init__.py,sha256=SYTxz3Ho06pP2TBlvDU0FkUJz8ytbR3MgEpS9HvVYq4,709
2
2
  google/genai/_adapters.py,sha256=Kok38miNYJff2n--l0zEK_hbq0y2rWOH7k75J7SMYbQ,1744
3
- google/genai/_api_client.py,sha256=AoCuJp2lI9zHvybCzcki2IK2DyUhfUDly4s9CGxUmoc,49887
3
+ google/genai/_api_client.py,sha256=ISgrtT7-XVOdyv3Dtwz2Eve9w3C3RO4ylEY1bND8ElY,52757
4
4
  google/genai/_api_module.py,sha256=lj8eUWx8_LBGBz-49qz6_ywWm3GYp3d8Bg5JoOHbtbI,902
5
5
  google/genai/_automatic_function_calling_util.py,sha256=IJkPq2fT9pYxYm5Pbu5-e0nBoZKoZla7yT4_txWRKLs,10324
6
6
  google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
7
7
  google/genai/_common.py,sha256=CuG7wvroFu9kV0Im-asXJGmfbaFCAjCocZyRxYDss5g,19849
8
8
  google/genai/_extra_utils.py,sha256=GoIh_SxB5nf_0sjErYkjm8wdg93sfemLKrU_5QhlcBo,20562
9
- google/genai/_live_converters.py,sha256=lbpN5E8DjL74a2XLcgND4pzs3bHDeVpUtPDN8s7IZCU,108613
9
+ google/genai/_live_converters.py,sha256=mkxudlXXXAxuK6eWMj_-jVLQs9eOr4EX0GYCBvhIZAw,108962
10
10
  google/genai/_mcp_utils.py,sha256=khECx-DMuHemKzOQQ3msWp7FivPeEOnl3n1lvWc_b5o,3833
11
11
  google/genai/_replay_api_client.py,sha256=0IXroewCZbyZ01qN3ZQwW5OUZRMzCrf2-3nyfTerqNY,21363
12
12
  google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
13
- google/genai/_tokens_converters.py,sha256=LxLZGgSWn6VC2-1R-4ArcuaPK45svg5P-bpC1LjBb3w,48901
13
+ google/genai/_tokens_converters.py,sha256=jQlwRZU4mlIBv6i8Lu62e6u9dvgNtOnko5WEYnjkU_A,49159
14
14
  google/genai/_transformers.py,sha256=Nd_h_zYVOkWN1XTSnM9r3IR7R_qg3tPe2mE9jozaX-Q,36935
15
- google/genai/batches.py,sha256=ZpF3qgJUkPcpWjbaJtESiQq5qiZ0obsJl77yCtgZknA,170525
16
- google/genai/caches.py,sha256=Ckqqi0osoxNmkqYGvBGpvrZUx19D6hmuwS9UXcnGWmk,65911
15
+ google/genai/batches.py,sha256=qnyWQ1RfAdSVQgV7vGor9BIWmRwUilJ0wfqOvxUwpq8,172745
16
+ google/genai/caches.py,sha256=q8N3YIpgJYWrLWSy-zUZ6w9CPRjH113E8ff4MyykYA8,66169
17
17
  google/genai/chats.py,sha256=0QdOUeWEYDQgAWBy1f7a3z3yY9S8tXSowUzNrzazzj4,16651
18
18
  google/genai/client.py,sha256=wXnfZBSv9p-yKtX_gabUrfBXoYHuqHhzK_VgwRttMgY,10777
19
19
  google/genai/errors.py,sha256=UebysH1cDeIdtp1O06CW7lQjnNrWtuqZTeVgEJylX48,5589
20
20
  google/genai/files.py,sha256=MCcHRXiMFKjbnt78yVPejszEgGz_MHRXfJyDi5-07Gs,39655
21
- google/genai/live.py,sha256=6zKjLZKnd4J-t0XQ61yuzRJv8TwbhTW96Wr8dqeFPI8,38891
21
+ google/genai/live.py,sha256=8Vts1bX8ZWOa0PiS3zmYhG1QMhLtBPC_ATLTSAIrazs,38945
22
22
  google/genai/live_music.py,sha256=3GG9nsto8Vhkohcs-4CPMS4DFp1ZtMuLYzHfvEPYAeg,6971
23
- google/genai/models.py,sha256=7gBXwg6_RdW_HRD_iRFIAdqu0bkUkW0fAp_PMEPVwoU,239309
23
+ google/genai/models.py,sha256=DQx31b43CxVg2YCWHVGGKBzcuB-AfBApmPm9zPVLq6o,239567
24
24
  google/genai/operations.py,sha256=99zs__fTWsyQu7rMGmBI1_4tuAJxLR0g3yp7ymsUsBA,19609
25
25
  google/genai/pagers.py,sha256=nyVYxp92rS-UaewO_oBgP593knofeLU6yOn6RolNoGQ,6797
26
26
  google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
27
27
  google/genai/tokens.py,sha256=oew9I0fGuGLlXMdCn2Ot9Lv_herHMnvZOYjjdOz2CAM,12324
28
- google/genai/tunings.py,sha256=aUtotVuvn66vtsYiqwH3Av3arZ-sl3ooHCwkLijb6K4,48298
29
- google/genai/types.py,sha256=UmIBjW0qFbA2LN113DUtz8ZtgG1_7I0vIAPE0fVmTrc,459025
30
- google/genai/version.py,sha256=KWnZScqB5t3VtG5YNrQoE4_p36-OUcoYjWaKRdmLbQc,627
31
- google_genai-1.22.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
- google_genai-1.22.0.dist-info/METADATA,sha256=bOufmJ0EEGx9pwhd0hPURu6MM7sR6WQnLGZiM7KY0hs,37123
33
- google_genai-1.22.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- google_genai-1.22.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
- google_genai-1.22.0.dist-info/RECORD,,
28
+ google/genai/tunings.py,sha256=fSiD4RQZI8YsFaPbBoXOIoSDA0BIuJwGg2Ac_uy5_kM,49596
29
+ google/genai/types.py,sha256=dj1Va75V8kLkrtFPIiIYXQNukE5xuogoJmqo0nu0-N4,469923
30
+ google/genai/version.py,sha256=3V_J-TpVrcSp70_3LzpCOt3SQpDmFAXnGSiq5eVjSrU,627
31
+ google_genai-1.24.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
+ google_genai-1.24.0.dist-info/METADATA,sha256=yxyVgjMGvqGuGrRM8HO9fO35MTuewHnGMQYohChHULs,40539
33
+ google_genai-1.24.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ google_genai-1.24.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
+ google_genai-1.24.0.dist-info/RECORD,,