google-genai 0.5.0__py3-none-any.whl → 0.7.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.
google/genai/models.py CHANGED
@@ -16,13 +16,14 @@
16
16
  # Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17
17
 
18
18
  import logging
19
- from typing import AsyncIterator, Iterator, Optional, Union
19
+ from typing import AsyncIterator, Awaitable, Iterator, Optional, Union
20
20
  from urllib.parse import urlencode
21
+ from . import _api_module
21
22
  from . import _common
22
23
  from . import _extra_utils
23
24
  from . import _transformers as t
24
25
  from . import types
25
- from ._api_client import ApiClient, HttpOptionsDict
26
+ from ._api_client import ApiClient
26
27
  from ._common import get_value_by_path as getv
27
28
  from ._common import set_value_by_path as setv
28
29
  from .pagers import AsyncPager, Pager
@@ -35,7 +36,7 @@ def _Part_to_mldev(
35
36
  ) -> dict:
36
37
  to_object = {}
37
38
  if getv(from_object, ['video_metadata']) is not None:
38
- raise ValueError('video_metadata parameter is not supported in Google AI.')
39
+ raise ValueError('video_metadata parameter is not supported in Gemini API.')
39
40
 
40
41
  if getv(from_object, ['thought']) is not None:
41
42
  setv(to_object, ['thought'], getv(from_object, ['thought']))
@@ -167,51 +168,51 @@ def _Schema_to_mldev(
167
168
  ) -> dict:
168
169
  to_object = {}
169
170
  if getv(from_object, ['min_items']) is not None:
170
- raise ValueError('min_items parameter is not supported in Google AI.')
171
+ raise ValueError('min_items parameter is not supported in Gemini API.')
171
172
 
172
173
  if getv(from_object, ['example']) is not None:
173
- raise ValueError('example parameter is not supported in Google AI.')
174
+ raise ValueError('example parameter is not supported in Gemini API.')
174
175
 
175
176
  if getv(from_object, ['property_ordering']) is not None:
176
177
  raise ValueError(
177
- 'property_ordering parameter is not supported in Google AI.'
178
+ 'property_ordering parameter is not supported in Gemini API.'
178
179
  )
179
180
 
180
181
  if getv(from_object, ['pattern']) is not None:
181
- raise ValueError('pattern parameter is not supported in Google AI.')
182
+ raise ValueError('pattern parameter is not supported in Gemini API.')
182
183
 
183
184
  if getv(from_object, ['minimum']) is not None:
184
- raise ValueError('minimum parameter is not supported in Google AI.')
185
+ raise ValueError('minimum parameter is not supported in Gemini API.')
185
186
 
186
187
  if getv(from_object, ['default']) is not None:
187
- raise ValueError('default parameter is not supported in Google AI.')
188
+ raise ValueError('default parameter is not supported in Gemini API.')
188
189
 
189
190
  if getv(from_object, ['any_of']) is not None:
190
- raise ValueError('any_of parameter is not supported in Google AI.')
191
+ raise ValueError('any_of parameter is not supported in Gemini API.')
191
192
 
192
193
  if getv(from_object, ['max_length']) is not None:
193
- raise ValueError('max_length parameter is not supported in Google AI.')
194
+ raise ValueError('max_length parameter is not supported in Gemini API.')
194
195
 
195
196
  if getv(from_object, ['title']) is not None:
196
- raise ValueError('title parameter is not supported in Google AI.')
197
+ raise ValueError('title parameter is not supported in Gemini API.')
197
198
 
198
199
  if getv(from_object, ['min_length']) is not None:
199
- raise ValueError('min_length parameter is not supported in Google AI.')
200
+ raise ValueError('min_length parameter is not supported in Gemini API.')
200
201
 
201
202
  if getv(from_object, ['min_properties']) is not None:
202
- raise ValueError('min_properties parameter is not supported in Google AI.')
203
+ raise ValueError('min_properties parameter is not supported in Gemini API.')
203
204
 
204
205
  if getv(from_object, ['max_items']) is not None:
205
- raise ValueError('max_items parameter is not supported in Google AI.')
206
+ raise ValueError('max_items parameter is not supported in Gemini API.')
206
207
 
207
208
  if getv(from_object, ['maximum']) is not None:
208
- raise ValueError('maximum parameter is not supported in Google AI.')
209
+ raise ValueError('maximum parameter is not supported in Gemini API.')
209
210
 
210
211
  if getv(from_object, ['nullable']) is not None:
211
- raise ValueError('nullable parameter is not supported in Google AI.')
212
+ raise ValueError('nullable parameter is not supported in Gemini API.')
212
213
 
213
214
  if getv(from_object, ['max_properties']) is not None:
214
- raise ValueError('max_properties parameter is not supported in Google AI.')
215
+ raise ValueError('max_properties parameter is not supported in Gemini API.')
215
216
 
216
217
  if getv(from_object, ['type']) is not None:
217
218
  setv(to_object, ['type'], getv(from_object, ['type']))
@@ -323,7 +324,7 @@ def _SafetySetting_to_mldev(
323
324
  ) -> dict:
324
325
  to_object = {}
325
326
  if getv(from_object, ['method']) is not None:
326
- raise ValueError('method parameter is not supported in Google AI.')
327
+ raise ValueError('method parameter is not supported in Gemini API.')
327
328
 
328
329
  if getv(from_object, ['category']) is not None:
329
330
  setv(to_object, ['category'], getv(from_object, ['category']))
@@ -359,7 +360,7 @@ def _FunctionDeclaration_to_mldev(
359
360
  ) -> dict:
360
361
  to_object = {}
361
362
  if getv(from_object, ['response']) is not None:
362
- raise ValueError('response parameter is not supported in Google AI.')
363
+ raise ValueError('response parameter is not supported in Gemini API.')
363
364
 
364
365
  if getv(from_object, ['description']) is not None:
365
366
  setv(to_object, ['description'], getv(from_object, ['description']))
@@ -515,7 +516,7 @@ def _Tool_to_mldev(
515
516
  )
516
517
 
517
518
  if getv(from_object, ['retrieval']) is not None:
518
- raise ValueError('retrieval parameter is not supported in Google AI.')
519
+ raise ValueError('retrieval parameter is not supported in Gemini API.')
519
520
 
520
521
  if getv(from_object, ['google_search']) is not None:
521
522
  setv(
@@ -762,12 +763,41 @@ def _SpeechConfig_to_vertex(
762
763
  return to_object
763
764
 
764
765
 
766
+ def _ThinkingConfig_to_mldev(
767
+ api_client: ApiClient,
768
+ from_object: Union[dict, object],
769
+ parent_object: dict = None,
770
+ ) -> dict:
771
+ to_object = {}
772
+ if getv(from_object, ['include_thoughts']) is not None:
773
+ setv(
774
+ to_object, ['includeThoughts'], getv(from_object, ['include_thoughts'])
775
+ )
776
+
777
+ return to_object
778
+
779
+
780
+ def _ThinkingConfig_to_vertex(
781
+ api_client: ApiClient,
782
+ from_object: Union[dict, object],
783
+ parent_object: dict = None,
784
+ ) -> dict:
785
+ to_object = {}
786
+ if getv(from_object, ['include_thoughts']) is not None:
787
+ setv(
788
+ to_object, ['includeThoughts'], getv(from_object, ['include_thoughts'])
789
+ )
790
+
791
+ return to_object
792
+
793
+
765
794
  def _GenerateContentConfig_to_mldev(
766
795
  api_client: ApiClient,
767
796
  from_object: Union[dict, object],
768
797
  parent_object: dict = None,
769
798
  ) -> dict:
770
799
  to_object = {}
800
+
771
801
  if getv(from_object, ['system_instruction']) is not None:
772
802
  setv(
773
803
  parent_object,
@@ -843,7 +873,7 @@ def _GenerateContentConfig_to_mldev(
843
873
  )
844
874
 
845
875
  if getv(from_object, ['routing_config']) is not None:
846
- raise ValueError('routing_config parameter is not supported in Google AI.')
876
+ raise ValueError('routing_config parameter is not supported in Gemini API.')
847
877
 
848
878
  if getv(from_object, ['safety_settings']) is not None:
849
879
  setv(
@@ -892,7 +922,7 @@ def _GenerateContentConfig_to_mldev(
892
922
 
893
923
  if getv(from_object, ['media_resolution']) is not None:
894
924
  raise ValueError(
895
- 'media_resolution parameter is not supported in Google AI.'
925
+ 'media_resolution parameter is not supported in Gemini API.'
896
926
  )
897
927
 
898
928
  if getv(from_object, ['speech_config']) is not None:
@@ -906,6 +936,20 @@ def _GenerateContentConfig_to_mldev(
906
936
  ),
907
937
  )
908
938
 
939
+ if getv(from_object, ['audio_timestamp']) is not None:
940
+ raise ValueError(
941
+ 'audio_timestamp parameter is not supported in Gemini API.'
942
+ )
943
+
944
+ if getv(from_object, ['thinking_config']) is not None:
945
+ setv(
946
+ to_object,
947
+ ['thinkingConfig'],
948
+ _ThinkingConfig_to_mldev(
949
+ api_client, getv(from_object, ['thinking_config']), to_object
950
+ ),
951
+ )
952
+
909
953
  return to_object
910
954
 
911
955
 
@@ -915,6 +959,7 @@ def _GenerateContentConfig_to_vertex(
915
959
  parent_object: dict = None,
916
960
  ) -> dict:
917
961
  to_object = {}
962
+
918
963
  if getv(from_object, ['system_instruction']) is not None:
919
964
  setv(
920
965
  parent_object,
@@ -1053,6 +1098,18 @@ def _GenerateContentConfig_to_vertex(
1053
1098
  ),
1054
1099
  )
1055
1100
 
1101
+ if getv(from_object, ['audio_timestamp']) is not None:
1102
+ setv(to_object, ['audioTimestamp'], getv(from_object, ['audio_timestamp']))
1103
+
1104
+ if getv(from_object, ['thinking_config']) is not None:
1105
+ setv(
1106
+ to_object,
1107
+ ['thinkingConfig'],
1108
+ _ThinkingConfig_to_vertex(
1109
+ api_client, getv(from_object, ['thinking_config']), to_object
1110
+ ),
1111
+ )
1112
+
1056
1113
  return to_object
1057
1114
 
1058
1115
 
@@ -1136,8 +1193,6 @@ def _EmbedContentConfig_to_mldev(
1136
1193
  parent_object: dict = None,
1137
1194
  ) -> dict:
1138
1195
  to_object = {}
1139
- if getv(from_object, ['http_options']) is not None:
1140
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1141
1196
 
1142
1197
  if getv(from_object, ['task_type']) is not None:
1143
1198
  setv(
@@ -1157,10 +1212,10 @@ def _EmbedContentConfig_to_mldev(
1157
1212
  )
1158
1213
 
1159
1214
  if getv(from_object, ['mime_type']) is not None:
1160
- raise ValueError('mime_type parameter is not supported in Google AI.')
1215
+ raise ValueError('mime_type parameter is not supported in Gemini API.')
1161
1216
 
1162
1217
  if getv(from_object, ['auto_truncate']) is not None:
1163
- raise ValueError('auto_truncate parameter is not supported in Google AI.')
1218
+ raise ValueError('auto_truncate parameter is not supported in Gemini API.')
1164
1219
 
1165
1220
  return to_object
1166
1221
 
@@ -1171,8 +1226,6 @@ def _EmbedContentConfig_to_vertex(
1171
1226
  parent_object: dict = None,
1172
1227
  ) -> dict:
1173
1228
  to_object = {}
1174
- if getv(from_object, ['http_options']) is not None:
1175
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1176
1229
 
1177
1230
  if getv(from_object, ['task_type']) is not None:
1178
1231
  setv(
@@ -1277,17 +1330,15 @@ def _EmbedContentParameters_to_vertex(
1277
1330
  return to_object
1278
1331
 
1279
1332
 
1280
- def _GenerateImageConfig_to_mldev(
1333
+ def _GenerateImagesConfig_to_mldev(
1281
1334
  api_client: ApiClient,
1282
1335
  from_object: Union[dict, object],
1283
1336
  parent_object: dict = None,
1284
1337
  ) -> dict:
1285
1338
  to_object = {}
1286
- if getv(from_object, ['http_options']) is not None:
1287
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1288
1339
 
1289
1340
  if getv(from_object, ['output_gcs_uri']) is not None:
1290
- raise ValueError('output_gcs_uri parameter is not supported in Google AI.')
1341
+ raise ValueError('output_gcs_uri parameter is not supported in Gemini API.')
1291
1342
 
1292
1343
  if getv(from_object, ['negative_prompt']) is not None:
1293
1344
  setv(
@@ -1311,9 +1362,12 @@ def _GenerateImageConfig_to_mldev(
1311
1362
  )
1312
1363
 
1313
1364
  if getv(from_object, ['seed']) is not None:
1314
- raise ValueError('seed parameter is not supported in Google AI.')
1365
+ raise ValueError('seed parameter is not supported in Gemini API.')
1315
1366
 
1316
1367
  if getv(from_object, ['safety_filter_level']) is not None:
1368
+ _SafetyFilterLevel_to_mldev_enum_validate(
1369
+ getv(from_object, ['safety_filter_level'])
1370
+ )
1317
1371
  setv(
1318
1372
  parent_object,
1319
1373
  ['parameters', 'safetySetting'],
@@ -1321,6 +1375,9 @@ def _GenerateImageConfig_to_mldev(
1321
1375
  )
1322
1376
 
1323
1377
  if getv(from_object, ['person_generation']) is not None:
1378
+ _PersonGeneration_to_mldev_enum_validate(
1379
+ getv(from_object, ['person_generation'])
1380
+ )
1324
1381
  setv(
1325
1382
  parent_object,
1326
1383
  ['parameters', 'personGeneration'],
@@ -1363,7 +1420,7 @@ def _GenerateImageConfig_to_mldev(
1363
1420
  )
1364
1421
 
1365
1422
  if getv(from_object, ['add_watermark']) is not None:
1366
- raise ValueError('add_watermark parameter is not supported in Google AI.')
1423
+ raise ValueError('add_watermark parameter is not supported in Gemini API.')
1367
1424
 
1368
1425
  if getv(from_object, ['aspect_ratio']) is not None:
1369
1426
  setv(
@@ -1372,17 +1429,22 @@ def _GenerateImageConfig_to_mldev(
1372
1429
  getv(from_object, ['aspect_ratio']),
1373
1430
  )
1374
1431
 
1432
+ if getv(from_object, ['enhance_prompt']) is not None:
1433
+ setv(
1434
+ parent_object,
1435
+ ['parameters', 'enhancePrompt'],
1436
+ getv(from_object, ['enhance_prompt']),
1437
+ )
1438
+
1375
1439
  return to_object
1376
1440
 
1377
1441
 
1378
- def _GenerateImageConfig_to_vertex(
1442
+ def _GenerateImagesConfig_to_vertex(
1379
1443
  api_client: ApiClient,
1380
1444
  from_object: Union[dict, object],
1381
1445
  parent_object: dict = None,
1382
1446
  ) -> dict:
1383
1447
  to_object = {}
1384
- if getv(from_object, ['http_options']) is not None:
1385
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1386
1448
 
1387
1449
  if getv(from_object, ['output_gcs_uri']) is not None:
1388
1450
  setv(
@@ -1478,10 +1540,17 @@ def _GenerateImageConfig_to_vertex(
1478
1540
  getv(from_object, ['aspect_ratio']),
1479
1541
  )
1480
1542
 
1543
+ if getv(from_object, ['enhance_prompt']) is not None:
1544
+ setv(
1545
+ parent_object,
1546
+ ['parameters', 'enhancePrompt'],
1547
+ getv(from_object, ['enhance_prompt']),
1548
+ )
1549
+
1481
1550
  return to_object
1482
1551
 
1483
1552
 
1484
- def _GenerateImageParameters_to_mldev(
1553
+ def _GenerateImagesParameters_to_mldev(
1485
1554
  api_client: ApiClient,
1486
1555
  from_object: Union[dict, object],
1487
1556
  parent_object: dict = None,
@@ -1501,7 +1570,7 @@ def _GenerateImageParameters_to_mldev(
1501
1570
  setv(
1502
1571
  to_object,
1503
1572
  ['config'],
1504
- _GenerateImageConfig_to_mldev(
1573
+ _GenerateImagesConfig_to_mldev(
1505
1574
  api_client, getv(from_object, ['config']), to_object
1506
1575
  ),
1507
1576
  )
@@ -1509,7 +1578,7 @@ def _GenerateImageParameters_to_mldev(
1509
1578
  return to_object
1510
1579
 
1511
1580
 
1512
- def _GenerateImageParameters_to_vertex(
1581
+ def _GenerateImagesParameters_to_vertex(
1513
1582
  api_client: ApiClient,
1514
1583
  from_object: Union[dict, object],
1515
1584
  parent_object: dict = None,
@@ -1529,7 +1598,7 @@ def _GenerateImageParameters_to_vertex(
1529
1598
  setv(
1530
1599
  to_object,
1531
1600
  ['config'],
1532
- _GenerateImageConfig_to_vertex(
1601
+ _GenerateImagesConfig_to_vertex(
1533
1602
  api_client, getv(from_object, ['config']), to_object
1534
1603
  ),
1535
1604
  )
@@ -1544,7 +1613,7 @@ def _Image_to_mldev(
1544
1613
  ) -> dict:
1545
1614
  to_object = {}
1546
1615
  if getv(from_object, ['gcs_uri']) is not None:
1547
- raise ValueError('gcs_uri parameter is not supported in Google AI.')
1616
+ raise ValueError('gcs_uri parameter is not supported in Gemini API.')
1548
1617
 
1549
1618
  if getv(from_object, ['image_bytes']) is not None:
1550
1619
  setv(
@@ -1553,6 +1622,9 @@ def _Image_to_mldev(
1553
1622
  t.t_bytes(api_client, getv(from_object, ['image_bytes'])),
1554
1623
  )
1555
1624
 
1625
+ if getv(from_object, ['mime_type']) is not None:
1626
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1627
+
1556
1628
  return to_object
1557
1629
 
1558
1630
 
@@ -1572,6 +1644,9 @@ def _Image_to_vertex(
1572
1644
  t.t_bytes(api_client, getv(from_object, ['image_bytes'])),
1573
1645
  )
1574
1646
 
1647
+ if getv(from_object, ['mime_type']) is not None:
1648
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1649
+
1575
1650
  return to_object
1576
1651
 
1577
1652
 
@@ -1582,15 +1657,15 @@ def _MaskReferenceConfig_to_mldev(
1582
1657
  ) -> dict:
1583
1658
  to_object = {}
1584
1659
  if getv(from_object, ['mask_mode']) is not None:
1585
- raise ValueError('mask_mode parameter is not supported in Google AI.')
1660
+ raise ValueError('mask_mode parameter is not supported in Gemini API.')
1586
1661
 
1587
1662
  if getv(from_object, ['segmentation_classes']) is not None:
1588
1663
  raise ValueError(
1589
- 'segmentation_classes parameter is not supported in Google AI.'
1664
+ 'segmentation_classes parameter is not supported in Gemini API.'
1590
1665
  )
1591
1666
 
1592
1667
  if getv(from_object, ['mask_dilation']) is not None:
1593
- raise ValueError('mask_dilation parameter is not supported in Google AI.')
1668
+ raise ValueError('mask_dilation parameter is not supported in Gemini API.')
1594
1669
 
1595
1670
  return to_object
1596
1671
 
@@ -1622,12 +1697,12 @@ def _ControlReferenceConfig_to_mldev(
1622
1697
  ) -> dict:
1623
1698
  to_object = {}
1624
1699
  if getv(from_object, ['control_type']) is not None:
1625
- raise ValueError('control_type parameter is not supported in Google AI.')
1700
+ raise ValueError('control_type parameter is not supported in Gemini API.')
1626
1701
 
1627
1702
  if getv(from_object, ['enable_control_image_computation']) is not None:
1628
1703
  raise ValueError(
1629
- 'enable_control_image_computation parameter is not supported in'
1630
- ' Google AI.'
1704
+ 'enable_control_image_computation parameter is not supported in Gemini'
1705
+ ' API.'
1631
1706
  )
1632
1707
 
1633
1708
  return to_object
@@ -1660,7 +1735,7 @@ def _StyleReferenceConfig_to_mldev(
1660
1735
  to_object = {}
1661
1736
  if getv(from_object, ['style_description']) is not None:
1662
1737
  raise ValueError(
1663
- 'style_description parameter is not supported in Google AI.'
1738
+ 'style_description parameter is not supported in Gemini API.'
1664
1739
  )
1665
1740
 
1666
1741
  return to_object
@@ -1689,11 +1764,11 @@ def _SubjectReferenceConfig_to_mldev(
1689
1764
  ) -> dict:
1690
1765
  to_object = {}
1691
1766
  if getv(from_object, ['subject_type']) is not None:
1692
- raise ValueError('subject_type parameter is not supported in Google AI.')
1767
+ raise ValueError('subject_type parameter is not supported in Gemini API.')
1693
1768
 
1694
1769
  if getv(from_object, ['subject_description']) is not None:
1695
1770
  raise ValueError(
1696
- 'subject_description parameter is not supported in Google AI.'
1771
+ 'subject_description parameter is not supported in Gemini API.'
1697
1772
  )
1698
1773
 
1699
1774
  return to_object
@@ -1725,32 +1800,34 @@ def _ReferenceImageAPI_to_mldev(
1725
1800
  ) -> dict:
1726
1801
  to_object = {}
1727
1802
  if getv(from_object, ['reference_image']) is not None:
1728
- raise ValueError('reference_image parameter is not supported in Google AI.')
1803
+ raise ValueError(
1804
+ 'reference_image parameter is not supported in Gemini API.'
1805
+ )
1729
1806
 
1730
1807
  if getv(from_object, ['reference_id']) is not None:
1731
- raise ValueError('reference_id parameter is not supported in Google AI.')
1808
+ raise ValueError('reference_id parameter is not supported in Gemini API.')
1732
1809
 
1733
1810
  if getv(from_object, ['reference_type']) is not None:
1734
- raise ValueError('reference_type parameter is not supported in Google AI.')
1811
+ raise ValueError('reference_type parameter is not supported in Gemini API.')
1735
1812
 
1736
1813
  if getv(from_object, ['mask_image_config']) is not None:
1737
1814
  raise ValueError(
1738
- 'mask_image_config parameter is not supported in Google AI.'
1815
+ 'mask_image_config parameter is not supported in Gemini API.'
1739
1816
  )
1740
1817
 
1741
1818
  if getv(from_object, ['control_image_config']) is not None:
1742
1819
  raise ValueError(
1743
- 'control_image_config parameter is not supported in Google AI.'
1820
+ 'control_image_config parameter is not supported in Gemini API.'
1744
1821
  )
1745
1822
 
1746
1823
  if getv(from_object, ['style_image_config']) is not None:
1747
1824
  raise ValueError(
1748
- 'style_image_config parameter is not supported in Google AI.'
1825
+ 'style_image_config parameter is not supported in Gemini API.'
1749
1826
  )
1750
1827
 
1751
1828
  if getv(from_object, ['subject_image_config']) is not None:
1752
1829
  raise ValueError(
1753
- 'subject_image_config parameter is not supported in Google AI.'
1830
+ 'subject_image_config parameter is not supported in Gemini API.'
1754
1831
  )
1755
1832
 
1756
1833
  return to_object
@@ -1822,11 +1899,9 @@ def _EditImageConfig_to_mldev(
1822
1899
  parent_object: dict = None,
1823
1900
  ) -> dict:
1824
1901
  to_object = {}
1825
- if getv(from_object, ['http_options']) is not None:
1826
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1827
1902
 
1828
1903
  if getv(from_object, ['output_gcs_uri']) is not None:
1829
- raise ValueError('output_gcs_uri parameter is not supported in Google AI.')
1904
+ raise ValueError('output_gcs_uri parameter is not supported in Gemini API.')
1830
1905
 
1831
1906
  if getv(from_object, ['negative_prompt']) is not None:
1832
1907
  setv(
@@ -1850,9 +1925,12 @@ def _EditImageConfig_to_mldev(
1850
1925
  )
1851
1926
 
1852
1927
  if getv(from_object, ['seed']) is not None:
1853
- raise ValueError('seed parameter is not supported in Google AI.')
1928
+ raise ValueError('seed parameter is not supported in Gemini API.')
1854
1929
 
1855
1930
  if getv(from_object, ['safety_filter_level']) is not None:
1931
+ _SafetyFilterLevel_to_mldev_enum_validate(
1932
+ getv(from_object, ['safety_filter_level'])
1933
+ )
1856
1934
  setv(
1857
1935
  parent_object,
1858
1936
  ['parameters', 'safetySetting'],
@@ -1860,6 +1938,9 @@ def _EditImageConfig_to_mldev(
1860
1938
  )
1861
1939
 
1862
1940
  if getv(from_object, ['person_generation']) is not None:
1941
+ _PersonGeneration_to_mldev_enum_validate(
1942
+ getv(from_object, ['person_generation'])
1943
+ )
1863
1944
  setv(
1864
1945
  parent_object,
1865
1946
  ['parameters', 'personGeneration'],
@@ -1902,6 +1983,7 @@ def _EditImageConfig_to_mldev(
1902
1983
  )
1903
1984
 
1904
1985
  if getv(from_object, ['edit_mode']) is not None:
1986
+ _EditMode_to_mldev_enum_validate(getv(from_object, ['edit_mode']))
1905
1987
  setv(
1906
1988
  parent_object,
1907
1989
  ['parameters', 'editMode'],
@@ -1917,8 +1999,6 @@ def _EditImageConfig_to_vertex(
1917
1999
  parent_object: dict = None,
1918
2000
  ) -> dict:
1919
2001
  to_object = {}
1920
- if getv(from_object, ['http_options']) is not None:
1921
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1922
2002
 
1923
2003
  if getv(from_object, ['output_gcs_uri']) is not None:
1924
2004
  setv(
@@ -2092,8 +2172,6 @@ def _UpscaleImageAPIConfig_to_mldev(
2092
2172
  parent_object: dict = None,
2093
2173
  ) -> dict:
2094
2174
  to_object = {}
2095
- if getv(from_object, ['http_options']) is not None:
2096
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2097
2175
 
2098
2176
  if getv(from_object, ['include_rai_reason']) is not None:
2099
2177
  setv(
@@ -2135,8 +2213,6 @@ def _UpscaleImageAPIConfig_to_vertex(
2135
2213
  parent_object: dict = None,
2136
2214
  ) -> dict:
2137
2215
  to_object = {}
2138
- if getv(from_object, ['http_options']) is not None:
2139
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2140
2216
 
2141
2217
  if getv(from_object, ['include_rai_reason']) is not None:
2142
2218
  setv(
@@ -2263,6 +2339,9 @@ def _GetModelParameters_to_mldev(
2263
2339
  t.t_model(api_client, getv(from_object, ['model'])),
2264
2340
  )
2265
2341
 
2342
+ if getv(from_object, ['config']) is not None:
2343
+ setv(to_object, ['config'], getv(from_object, ['config']))
2344
+
2266
2345
  return to_object
2267
2346
 
2268
2347
 
@@ -2279,6 +2358,9 @@ def _GetModelParameters_to_vertex(
2279
2358
  t.t_model(api_client, getv(from_object, ['model'])),
2280
2359
  )
2281
2360
 
2361
+ if getv(from_object, ['config']) is not None:
2362
+ setv(to_object, ['config'], getv(from_object, ['config']))
2363
+
2282
2364
  return to_object
2283
2365
 
2284
2366
 
@@ -2288,8 +2370,6 @@ def _ListModelsConfig_to_mldev(
2288
2370
  parent_object: dict = None,
2289
2371
  ) -> dict:
2290
2372
  to_object = {}
2291
- if getv(from_object, ['http_options']) is not None:
2292
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2293
2373
 
2294
2374
  if getv(from_object, ['page_size']) is not None:
2295
2375
  setv(
@@ -2322,8 +2402,6 @@ def _ListModelsConfig_to_vertex(
2322
2402
  parent_object: dict = None,
2323
2403
  ) -> dict:
2324
2404
  to_object = {}
2325
- if getv(from_object, ['http_options']) is not None:
2326
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2327
2405
 
2328
2406
  if getv(from_object, ['page_size']) is not None:
2329
2407
  setv(
@@ -2392,6 +2470,7 @@ def _UpdateModelConfig_to_mldev(
2392
2470
  parent_object: dict = None,
2393
2471
  ) -> dict:
2394
2472
  to_object = {}
2473
+
2395
2474
  if getv(from_object, ['display_name']) is not None:
2396
2475
  setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
2397
2476
 
@@ -2407,6 +2486,7 @@ def _UpdateModelConfig_to_vertex(
2407
2486
  parent_object: dict = None,
2408
2487
  ) -> dict:
2409
2488
  to_object = {}
2489
+
2410
2490
  if getv(from_object, ['display_name']) is not None:
2411
2491
  setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
2412
2492
 
@@ -2479,6 +2559,9 @@ def _DeleteModelParameters_to_mldev(
2479
2559
  t.t_model(api_client, getv(from_object, ['model'])),
2480
2560
  )
2481
2561
 
2562
+ if getv(from_object, ['config']) is not None:
2563
+ setv(to_object, ['config'], getv(from_object, ['config']))
2564
+
2482
2565
  return to_object
2483
2566
 
2484
2567
 
@@ -2495,6 +2578,9 @@ def _DeleteModelParameters_to_vertex(
2495
2578
  t.t_model(api_client, getv(from_object, ['model'])),
2496
2579
  )
2497
2580
 
2581
+ if getv(from_object, ['config']) is not None:
2582
+ setv(to_object, ['config'], getv(from_object, ['config']))
2583
+
2498
2584
  return to_object
2499
2585
 
2500
2586
 
@@ -2504,8 +2590,6 @@ def _CountTokensConfig_to_mldev(
2504
2590
  parent_object: dict = None,
2505
2591
  ) -> dict:
2506
2592
  to_object = {}
2507
- if getv(from_object, ['http_options']) is not None:
2508
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2509
2593
 
2510
2594
  if getv(from_object, ['system_instruction']) is not None:
2511
2595
  setv(
@@ -2530,7 +2614,7 @@ def _CountTokensConfig_to_mldev(
2530
2614
 
2531
2615
  if getv(from_object, ['generation_config']) is not None:
2532
2616
  raise ValueError(
2533
- 'generation_config parameter is not supported in Google AI.'
2617
+ 'generation_config parameter is not supported in Gemini API.'
2534
2618
  )
2535
2619
 
2536
2620
  return to_object
@@ -2542,12 +2626,10 @@ def _CountTokensConfig_to_vertex(
2542
2626
  parent_object: dict = None,
2543
2627
  ) -> dict:
2544
2628
  to_object = {}
2545
- if getv(from_object, ['http_options']) is not None:
2546
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2547
2629
 
2548
2630
  if getv(from_object, ['system_instruction']) is not None:
2549
2631
  setv(
2550
- to_object,
2632
+ parent_object,
2551
2633
  ['systemInstruction'],
2552
2634
  _Content_to_vertex(
2553
2635
  api_client,
@@ -2558,7 +2640,7 @@ def _CountTokensConfig_to_vertex(
2558
2640
 
2559
2641
  if getv(from_object, ['tools']) is not None:
2560
2642
  setv(
2561
- to_object,
2643
+ parent_object,
2562
2644
  ['tools'],
2563
2645
  [
2564
2646
  _Tool_to_vertex(api_client, item, to_object)
@@ -2650,30 +2732,6 @@ def _CountTokensParameters_to_vertex(
2650
2732
  return to_object
2651
2733
 
2652
2734
 
2653
- def _ComputeTokensConfig_to_mldev(
2654
- api_client: ApiClient,
2655
- from_object: Union[dict, object],
2656
- parent_object: dict = None,
2657
- ) -> dict:
2658
- to_object = {}
2659
- if getv(from_object, ['http_options']) is not None:
2660
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2661
-
2662
- return to_object
2663
-
2664
-
2665
- def _ComputeTokensConfig_to_vertex(
2666
- api_client: ApiClient,
2667
- from_object: Union[dict, object],
2668
- parent_object: dict = None,
2669
- ) -> dict:
2670
- to_object = {}
2671
- if getv(from_object, ['http_options']) is not None:
2672
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2673
-
2674
- return to_object
2675
-
2676
-
2677
2735
  def _ComputeTokensParameters_to_mldev(
2678
2736
  api_client: ApiClient,
2679
2737
  from_object: Union[dict, object],
@@ -2688,16 +2746,10 @@ def _ComputeTokensParameters_to_mldev(
2688
2746
  )
2689
2747
 
2690
2748
  if getv(from_object, ['contents']) is not None:
2691
- raise ValueError('contents parameter is not supported in Google AI.')
2749
+ raise ValueError('contents parameter is not supported in Gemini API.')
2692
2750
 
2693
2751
  if getv(from_object, ['config']) is not None:
2694
- setv(
2695
- to_object,
2696
- ['config'],
2697
- _ComputeTokensConfig_to_mldev(
2698
- api_client, getv(from_object, ['config']), to_object
2699
- ),
2700
- )
2752
+ setv(to_object, ['config'], getv(from_object, ['config']))
2701
2753
 
2702
2754
  return to_object
2703
2755
 
@@ -2728,17 +2780,76 @@ def _ComputeTokensParameters_to_vertex(
2728
2780
  )
2729
2781
 
2730
2782
  if getv(from_object, ['config']) is not None:
2731
- setv(
2732
- to_object,
2733
- ['config'],
2734
- _ComputeTokensConfig_to_vertex(
2735
- api_client, getv(from_object, ['config']), to_object
2736
- ),
2737
- )
2783
+ setv(to_object, ['config'], getv(from_object, ['config']))
2738
2784
 
2739
2785
  return to_object
2740
2786
 
2741
2787
 
2788
+ def _MediaResolution_to_mldev_enum_validate(enum_value: any):
2789
+ if enum_value in set([
2790
+ 'MEDIA_RESOLUTION_UNSPECIFIED',
2791
+ 'MEDIA_RESOLUTION_LOW',
2792
+ 'MEDIA_RESOLUTION_MEDIUM',
2793
+ 'MEDIA_RESOLUTION_HIGH',
2794
+ ]):
2795
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2796
+
2797
+
2798
+ def _SafetyFilterLevel_to_mldev_enum_validate(enum_value: any):
2799
+ if enum_value in set(['BLOCK_NONE']):
2800
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2801
+
2802
+
2803
+ def _PersonGeneration_to_mldev_enum_validate(enum_value: any):
2804
+ if enum_value in set(['ALLOW_ALL']):
2805
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2806
+
2807
+
2808
+ def _MaskReferenceMode_to_mldev_enum_validate(enum_value: any):
2809
+ if enum_value in set([
2810
+ 'MASK_MODE_DEFAULT',
2811
+ 'MASK_MODE_USER_PROVIDED',
2812
+ 'MASK_MODE_BACKGROUND',
2813
+ 'MASK_MODE_FOREGROUND',
2814
+ 'MASK_MODE_SEMANTIC',
2815
+ ]):
2816
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2817
+
2818
+
2819
+ def _ControlReferenceType_to_mldev_enum_validate(enum_value: any):
2820
+ if enum_value in set([
2821
+ 'CONTROL_TYPE_DEFAULT',
2822
+ 'CONTROL_TYPE_CANNY',
2823
+ 'CONTROL_TYPE_SCRIBBLE',
2824
+ 'CONTROL_TYPE_FACE_MESH',
2825
+ ]):
2826
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2827
+
2828
+
2829
+ def _SubjectReferenceType_to_mldev_enum_validate(enum_value: any):
2830
+ if enum_value in set([
2831
+ 'SUBJECT_TYPE_DEFAULT',
2832
+ 'SUBJECT_TYPE_PERSON',
2833
+ 'SUBJECT_TYPE_ANIMAL',
2834
+ 'SUBJECT_TYPE_PRODUCT',
2835
+ ]):
2836
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2837
+
2838
+
2839
+ def _EditMode_to_mldev_enum_validate(enum_value: any):
2840
+ if enum_value in set([
2841
+ 'EDIT_MODE_DEFAULT',
2842
+ 'EDIT_MODE_INPAINT_REMOVAL',
2843
+ 'EDIT_MODE_INPAINT_INSERTION',
2844
+ 'EDIT_MODE_OUTPAINT',
2845
+ 'EDIT_MODE_CONTROLLED_EDITING',
2846
+ 'EDIT_MODE_STYLE',
2847
+ 'EDIT_MODE_BGSWAP',
2848
+ 'EDIT_MODE_PRODUCT_IMAGE',
2849
+ ]):
2850
+ raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2851
+
2852
+
2742
2853
  def _Part_from_mldev(
2743
2854
  api_client: ApiClient,
2744
2855
  from_object: Union[dict, object],
@@ -3207,6 +3318,9 @@ def _Image_from_mldev(
3207
3318
  t.t_bytes(api_client, getv(from_object, ['bytesBase64Encoded'])),
3208
3319
  )
3209
3320
 
3321
+ if getv(from_object, ['mimeType']) is not None:
3322
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3323
+
3210
3324
  return to_object
3211
3325
 
3212
3326
 
@@ -3226,6 +3340,9 @@ def _Image_from_vertex(
3226
3340
  t.t_bytes(api_client, getv(from_object, ['bytesBase64Encoded'])),
3227
3341
  )
3228
3342
 
3343
+ if getv(from_object, ['mimeType']) is not None:
3344
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3345
+
3229
3346
  return to_object
3230
3347
 
3231
3348
 
@@ -3275,7 +3392,7 @@ def _GeneratedImage_from_vertex(
3275
3392
  return to_object
3276
3393
 
3277
3394
 
3278
- def _GenerateImageResponse_from_mldev(
3395
+ def _GenerateImagesResponse_from_mldev(
3279
3396
  api_client: ApiClient,
3280
3397
  from_object: Union[dict, object],
3281
3398
  parent_object: dict = None,
@@ -3294,7 +3411,7 @@ def _GenerateImageResponse_from_mldev(
3294
3411
  return to_object
3295
3412
 
3296
3413
 
3297
- def _GenerateImageResponse_from_vertex(
3414
+ def _GenerateImagesResponse_from_vertex(
3298
3415
  api_client: ApiClient,
3299
3416
  from_object: Union[dict, object],
3300
3417
  parent_object: dict = None,
@@ -3674,7 +3791,7 @@ def _ComputeTokensResponse_from_vertex(
3674
3791
  return to_object
3675
3792
 
3676
3793
 
3677
- class Models(_common.BaseModule):
3794
+ class Models(_api_module.BaseModule):
3678
3795
 
3679
3796
  def _generate_content(
3680
3797
  self,
@@ -3703,10 +3820,16 @@ class Models(_common.BaseModule):
3703
3820
  if query_params:
3704
3821
  path = f'{path}?{urlencode(query_params)}'
3705
3822
  # TODO: remove the hack that pops config.
3706
- config = request_dict.pop('config', None)
3707
- http_options = config.pop('httpOptions', None) if config else None
3823
+ request_dict.pop('config', None)
3824
+
3825
+ http_options = None
3826
+ if isinstance(config, dict):
3827
+ http_options = config.get('http_options', None)
3828
+ elif hasattr(config, 'http_options'):
3829
+ http_options = config.http_options
3830
+
3708
3831
  request_dict = _common.convert_to_dict(request_dict)
3709
- request_dict = _common.apply_base64_encoding(request_dict)
3832
+ request_dict = _common.encode_unserializable_types(request_dict)
3710
3833
 
3711
3834
  response_dict = self._api_client.request(
3712
3835
  'post', path, request_dict, http_options
@@ -3722,7 +3845,7 @@ class Models(_common.BaseModule):
3722
3845
  )
3723
3846
 
3724
3847
  return_value = types.GenerateContentResponse._from_response(
3725
- response_dict, parameter_model
3848
+ response=response_dict, kwargs=parameter_model
3726
3849
  )
3727
3850
  self._api_client._verify_response(return_value)
3728
3851
  return return_value
@@ -3758,10 +3881,16 @@ class Models(_common.BaseModule):
3758
3881
  if query_params:
3759
3882
  path = f'{path}?{urlencode(query_params)}'
3760
3883
  # TODO: remove the hack that pops config.
3761
- config = request_dict.pop('config', None)
3762
- http_options = config.pop('httpOptions', None) if config else None
3884
+ request_dict.pop('config', None)
3885
+
3886
+ http_options = None
3887
+ if isinstance(config, dict):
3888
+ http_options = config.get('http_options', None)
3889
+ elif hasattr(config, 'http_options'):
3890
+ http_options = config.http_options
3891
+
3763
3892
  request_dict = _common.convert_to_dict(request_dict)
3764
- request_dict = _common.apply_base64_encoding(request_dict)
3893
+ request_dict = _common.encode_unserializable_types(request_dict)
3765
3894
 
3766
3895
  for response_dict in self._api_client.request_streamed(
3767
3896
  'post', path, request_dict, http_options
@@ -3777,7 +3906,7 @@ class Models(_common.BaseModule):
3777
3906
  )
3778
3907
 
3779
3908
  return_value = types.GenerateContentResponse._from_response(
3780
- response_dict, parameter_model
3909
+ response=response_dict, kwargs=parameter_model
3781
3910
  )
3782
3911
  self._api_client._verify_response(return_value)
3783
3912
  yield return_value
@@ -3832,10 +3961,16 @@ class Models(_common.BaseModule):
3832
3961
  if query_params:
3833
3962
  path = f'{path}?{urlencode(query_params)}'
3834
3963
  # TODO: remove the hack that pops config.
3835
- config = request_dict.pop('config', None)
3836
- http_options = config.pop('httpOptions', None) if config else None
3964
+ request_dict.pop('config', None)
3965
+
3966
+ http_options = None
3967
+ if isinstance(config, dict):
3968
+ http_options = config.get('http_options', None)
3969
+ elif hasattr(config, 'http_options'):
3970
+ http_options = config.http_options
3971
+
3837
3972
  request_dict = _common.convert_to_dict(request_dict)
3838
- request_dict = _common.apply_base64_encoding(request_dict)
3973
+ request_dict = _common.encode_unserializable_types(request_dict)
3839
3974
 
3840
3975
  response_dict = self._api_client.request(
3841
3976
  'post', path, request_dict, http_options
@@ -3851,33 +3986,33 @@ class Models(_common.BaseModule):
3851
3986
  )
3852
3987
 
3853
3988
  return_value = types.EmbedContentResponse._from_response(
3854
- response_dict, parameter_model
3989
+ response=response_dict, kwargs=parameter_model
3855
3990
  )
3856
3991
  self._api_client._verify_response(return_value)
3857
3992
  return return_value
3858
3993
 
3859
- def generate_image(
3994
+ def generate_images(
3860
3995
  self,
3861
3996
  *,
3862
3997
  model: str,
3863
3998
  prompt: str,
3864
- config: Optional[types.GenerateImageConfigOrDict] = None,
3865
- ) -> types.GenerateImageResponse:
3866
- """Generates an image based on a text description and configuration.
3999
+ config: Optional[types.GenerateImagesConfigOrDict] = None,
4000
+ ) -> types.GenerateImagesResponse:
4001
+ """Generates images based on a text description and configuration.
3867
4002
 
3868
4003
  Args:
3869
4004
  model (str): The model to use.
3870
- prompt (str): A text description of the image to generate.
3871
- config (GenerateImageConfig): Configuration for generation.
4005
+ prompt (str): A text description of the images to generate.
4006
+ config (GenerateImagesConfig): Configuration for generation.
3872
4007
 
3873
4008
  Usage:
3874
4009
 
3875
4010
  .. code-block:: python
3876
4011
 
3877
- response = client.models.generate_image(
4012
+ response = client.models.generate_images(
3878
4013
  model='imagen-3.0-generate-001',
3879
4014
  prompt='Man with a dog',
3880
- config=types.GenerateImageConfig(
4015
+ config=types.GenerateImagesConfig(
3881
4016
  number_of_images= 1,
3882
4017
  include_rai_reason= True,
3883
4018
  )
@@ -3886,19 +4021,19 @@ class Models(_common.BaseModule):
3886
4021
  # Shows a man with a dog.
3887
4022
  """
3888
4023
 
3889
- parameter_model = types._GenerateImageParameters(
4024
+ parameter_model = types._GenerateImagesParameters(
3890
4025
  model=model,
3891
4026
  prompt=prompt,
3892
4027
  config=config,
3893
4028
  )
3894
4029
 
3895
4030
  if self._api_client.vertexai:
3896
- request_dict = _GenerateImageParameters_to_vertex(
4031
+ request_dict = _GenerateImagesParameters_to_vertex(
3897
4032
  self._api_client, parameter_model
3898
4033
  )
3899
4034
  path = '{model}:predict'.format_map(request_dict.get('_url'))
3900
4035
  else:
3901
- request_dict = _GenerateImageParameters_to_mldev(
4036
+ request_dict = _GenerateImagesParameters_to_mldev(
3902
4037
  self._api_client, parameter_model
3903
4038
  )
3904
4039
  path = '{model}:predict'.format_map(request_dict.get('_url'))
@@ -3906,26 +4041,32 @@ class Models(_common.BaseModule):
3906
4041
  if query_params:
3907
4042
  path = f'{path}?{urlencode(query_params)}'
3908
4043
  # TODO: remove the hack that pops config.
3909
- config = request_dict.pop('config', None)
3910
- http_options = config.pop('httpOptions', None) if config else None
4044
+ request_dict.pop('config', None)
4045
+
4046
+ http_options = None
4047
+ if isinstance(config, dict):
4048
+ http_options = config.get('http_options', None)
4049
+ elif hasattr(config, 'http_options'):
4050
+ http_options = config.http_options
4051
+
3911
4052
  request_dict = _common.convert_to_dict(request_dict)
3912
- request_dict = _common.apply_base64_encoding(request_dict)
4053
+ request_dict = _common.encode_unserializable_types(request_dict)
3913
4054
 
3914
4055
  response_dict = self._api_client.request(
3915
4056
  'post', path, request_dict, http_options
3916
4057
  )
3917
4058
 
3918
4059
  if self._api_client.vertexai:
3919
- response_dict = _GenerateImageResponse_from_vertex(
4060
+ response_dict = _GenerateImagesResponse_from_vertex(
3920
4061
  self._api_client, response_dict
3921
4062
  )
3922
4063
  else:
3923
- response_dict = _GenerateImageResponse_from_mldev(
4064
+ response_dict = _GenerateImagesResponse_from_mldev(
3924
4065
  self._api_client, response_dict
3925
4066
  )
3926
4067
 
3927
- return_value = types.GenerateImageResponse._from_response(
3928
- response_dict, parameter_model
4068
+ return_value = types.GenerateImagesResponse._from_response(
4069
+ response=response_dict, kwargs=parameter_model
3929
4070
  )
3930
4071
  self._api_client._verify_response(return_value)
3931
4072
  return return_value
@@ -3999,10 +4140,16 @@ class Models(_common.BaseModule):
3999
4140
  if query_params:
4000
4141
  path = f'{path}?{urlencode(query_params)}'
4001
4142
  # TODO: remove the hack that pops config.
4002
- config = request_dict.pop('config', None)
4003
- http_options = config.pop('httpOptions', None) if config else None
4143
+ request_dict.pop('config', None)
4144
+
4145
+ http_options = None
4146
+ if isinstance(config, dict):
4147
+ http_options = config.get('http_options', None)
4148
+ elif hasattr(config, 'http_options'):
4149
+ http_options = config.http_options
4150
+
4004
4151
  request_dict = _common.convert_to_dict(request_dict)
4005
- request_dict = _common.apply_base64_encoding(request_dict)
4152
+ request_dict = _common.encode_unserializable_types(request_dict)
4006
4153
 
4007
4154
  response_dict = self._api_client.request(
4008
4155
  'post', path, request_dict, http_options
@@ -4018,7 +4165,7 @@ class Models(_common.BaseModule):
4018
4165
  )
4019
4166
 
4020
4167
  return_value = types.EditImageResponse._from_response(
4021
- response_dict, parameter_model
4168
+ response=response_dict, kwargs=parameter_model
4022
4169
  )
4023
4170
  self._api_client._verify_response(return_value)
4024
4171
  return return_value
@@ -4059,10 +4206,16 @@ class Models(_common.BaseModule):
4059
4206
  if query_params:
4060
4207
  path = f'{path}?{urlencode(query_params)}'
4061
4208
  # TODO: remove the hack that pops config.
4062
- config = request_dict.pop('config', None)
4063
- http_options = config.pop('httpOptions', None) if config else None
4209
+ request_dict.pop('config', None)
4210
+
4211
+ http_options = None
4212
+ if isinstance(config, dict):
4213
+ http_options = config.get('http_options', None)
4214
+ elif hasattr(config, 'http_options'):
4215
+ http_options = config.http_options
4216
+
4064
4217
  request_dict = _common.convert_to_dict(request_dict)
4065
- request_dict = _common.apply_base64_encoding(request_dict)
4218
+ request_dict = _common.encode_unserializable_types(request_dict)
4066
4219
 
4067
4220
  response_dict = self._api_client.request(
4068
4221
  'post', path, request_dict, http_options
@@ -4078,14 +4231,17 @@ class Models(_common.BaseModule):
4078
4231
  )
4079
4232
 
4080
4233
  return_value = types.UpscaleImageResponse._from_response(
4081
- response_dict, parameter_model
4234
+ response=response_dict, kwargs=parameter_model
4082
4235
  )
4083
4236
  self._api_client._verify_response(return_value)
4084
4237
  return return_value
4085
4238
 
4086
- def get(self, *, model: str) -> types.Model:
4239
+ def get(
4240
+ self, *, model: str, config: Optional[types.GetModelConfigOrDict] = None
4241
+ ) -> types.Model:
4087
4242
  parameter_model = types._GetModelParameters(
4088
4243
  model=model,
4244
+ config=config,
4089
4245
  )
4090
4246
 
4091
4247
  if self._api_client.vertexai:
@@ -4102,10 +4258,16 @@ class Models(_common.BaseModule):
4102
4258
  if query_params:
4103
4259
  path = f'{path}?{urlencode(query_params)}'
4104
4260
  # TODO: remove the hack that pops config.
4105
- config = request_dict.pop('config', None)
4106
- http_options = config.pop('httpOptions', None) if config else None
4261
+ request_dict.pop('config', None)
4262
+
4263
+ http_options = None
4264
+ if isinstance(config, dict):
4265
+ http_options = config.get('http_options', None)
4266
+ elif hasattr(config, 'http_options'):
4267
+ http_options = config.http_options
4268
+
4107
4269
  request_dict = _common.convert_to_dict(request_dict)
4108
- request_dict = _common.apply_base64_encoding(request_dict)
4270
+ request_dict = _common.encode_unserializable_types(request_dict)
4109
4271
 
4110
4272
  response_dict = self._api_client.request(
4111
4273
  'get', path, request_dict, http_options
@@ -4116,7 +4278,9 @@ class Models(_common.BaseModule):
4116
4278
  else:
4117
4279
  response_dict = _Model_from_mldev(self._api_client, response_dict)
4118
4280
 
4119
- return_value = types.Model._from_response(response_dict, parameter_model)
4281
+ return_value = types.Model._from_response(
4282
+ response=response_dict, kwargs=parameter_model
4283
+ )
4120
4284
  self._api_client._verify_response(return_value)
4121
4285
  return return_value
4122
4286
 
@@ -4141,10 +4305,16 @@ class Models(_common.BaseModule):
4141
4305
  if query_params:
4142
4306
  path = f'{path}?{urlencode(query_params)}'
4143
4307
  # TODO: remove the hack that pops config.
4144
- config = request_dict.pop('config', None)
4145
- http_options = config.pop('httpOptions', None) if config else None
4308
+ request_dict.pop('config', None)
4309
+
4310
+ http_options = None
4311
+ if isinstance(config, dict):
4312
+ http_options = config.get('http_options', None)
4313
+ elif hasattr(config, 'http_options'):
4314
+ http_options = config.http_options
4315
+
4146
4316
  request_dict = _common.convert_to_dict(request_dict)
4147
- request_dict = _common.apply_base64_encoding(request_dict)
4317
+ request_dict = _common.encode_unserializable_types(request_dict)
4148
4318
 
4149
4319
  response_dict = self._api_client.request(
4150
4320
  'get', path, request_dict, http_options
@@ -4160,7 +4330,7 @@ class Models(_common.BaseModule):
4160
4330
  )
4161
4331
 
4162
4332
  return_value = types.ListModelsResponse._from_response(
4163
- response_dict, parameter_model
4333
+ response=response_dict, kwargs=parameter_model
4164
4334
  )
4165
4335
  self._api_client._verify_response(return_value)
4166
4336
  return return_value
@@ -4190,10 +4360,16 @@ class Models(_common.BaseModule):
4190
4360
  if query_params:
4191
4361
  path = f'{path}?{urlencode(query_params)}'
4192
4362
  # TODO: remove the hack that pops config.
4193
- config = request_dict.pop('config', None)
4194
- http_options = config.pop('httpOptions', None) if config else None
4363
+ request_dict.pop('config', None)
4364
+
4365
+ http_options = None
4366
+ if isinstance(config, dict):
4367
+ http_options = config.get('http_options', None)
4368
+ elif hasattr(config, 'http_options'):
4369
+ http_options = config.http_options
4370
+
4195
4371
  request_dict = _common.convert_to_dict(request_dict)
4196
- request_dict = _common.apply_base64_encoding(request_dict)
4372
+ request_dict = _common.encode_unserializable_types(request_dict)
4197
4373
 
4198
4374
  response_dict = self._api_client.request(
4199
4375
  'patch', path, request_dict, http_options
@@ -4204,13 +4380,21 @@ class Models(_common.BaseModule):
4204
4380
  else:
4205
4381
  response_dict = _Model_from_mldev(self._api_client, response_dict)
4206
4382
 
4207
- return_value = types.Model._from_response(response_dict, parameter_model)
4383
+ return_value = types.Model._from_response(
4384
+ response=response_dict, kwargs=parameter_model
4385
+ )
4208
4386
  self._api_client._verify_response(return_value)
4209
4387
  return return_value
4210
4388
 
4211
- def delete(self, *, model: str) -> types.DeleteModelResponse:
4389
+ def delete(
4390
+ self,
4391
+ *,
4392
+ model: str,
4393
+ config: Optional[types.DeleteModelConfigOrDict] = None,
4394
+ ) -> types.DeleteModelResponse:
4212
4395
  parameter_model = types._DeleteModelParameters(
4213
4396
  model=model,
4397
+ config=config,
4214
4398
  )
4215
4399
 
4216
4400
  if self._api_client.vertexai:
@@ -4227,10 +4411,16 @@ class Models(_common.BaseModule):
4227
4411
  if query_params:
4228
4412
  path = f'{path}?{urlencode(query_params)}'
4229
4413
  # TODO: remove the hack that pops config.
4230
- config = request_dict.pop('config', None)
4231
- http_options = config.pop('httpOptions', None) if config else None
4414
+ request_dict.pop('config', None)
4415
+
4416
+ http_options = None
4417
+ if isinstance(config, dict):
4418
+ http_options = config.get('http_options', None)
4419
+ elif hasattr(config, 'http_options'):
4420
+ http_options = config.http_options
4421
+
4232
4422
  request_dict = _common.convert_to_dict(request_dict)
4233
- request_dict = _common.apply_base64_encoding(request_dict)
4423
+ request_dict = _common.encode_unserializable_types(request_dict)
4234
4424
 
4235
4425
  response_dict = self._api_client.request(
4236
4426
  'delete', path, request_dict, http_options
@@ -4246,7 +4436,7 @@ class Models(_common.BaseModule):
4246
4436
  )
4247
4437
 
4248
4438
  return_value = types.DeleteModelResponse._from_response(
4249
- response_dict, parameter_model
4439
+ response=response_dict, kwargs=parameter_model
4250
4440
  )
4251
4441
  self._api_client._verify_response(return_value)
4252
4442
  return return_value
@@ -4298,10 +4488,16 @@ class Models(_common.BaseModule):
4298
4488
  if query_params:
4299
4489
  path = f'{path}?{urlencode(query_params)}'
4300
4490
  # TODO: remove the hack that pops config.
4301
- config = request_dict.pop('config', None)
4302
- http_options = config.pop('httpOptions', None) if config else None
4491
+ request_dict.pop('config', None)
4492
+
4493
+ http_options = None
4494
+ if isinstance(config, dict):
4495
+ http_options = config.get('http_options', None)
4496
+ elif hasattr(config, 'http_options'):
4497
+ http_options = config.http_options
4498
+
4303
4499
  request_dict = _common.convert_to_dict(request_dict)
4304
- request_dict = _common.apply_base64_encoding(request_dict)
4500
+ request_dict = _common.encode_unserializable_types(request_dict)
4305
4501
 
4306
4502
  response_dict = self._api_client.request(
4307
4503
  'post', path, request_dict, http_options
@@ -4317,7 +4513,7 @@ class Models(_common.BaseModule):
4317
4513
  )
4318
4514
 
4319
4515
  return_value = types.CountTokensResponse._from_response(
4320
- response_dict, parameter_model
4516
+ response=response_dict, kwargs=parameter_model
4321
4517
  )
4322
4518
  self._api_client._verify_response(return_value)
4323
4519
  return return_value
@@ -4369,10 +4565,16 @@ class Models(_common.BaseModule):
4369
4565
  if query_params:
4370
4566
  path = f'{path}?{urlencode(query_params)}'
4371
4567
  # TODO: remove the hack that pops config.
4372
- config = request_dict.pop('config', None)
4373
- http_options = config.pop('httpOptions', None) if config else None
4568
+ request_dict.pop('config', None)
4569
+
4570
+ http_options = None
4571
+ if isinstance(config, dict):
4572
+ http_options = config.get('http_options', None)
4573
+ elif hasattr(config, 'http_options'):
4574
+ http_options = config.http_options
4575
+
4374
4576
  request_dict = _common.convert_to_dict(request_dict)
4375
- request_dict = _common.apply_base64_encoding(request_dict)
4577
+ request_dict = _common.encode_unserializable_types(request_dict)
4376
4578
 
4377
4579
  response_dict = self._api_client.request(
4378
4580
  'post', path, request_dict, http_options
@@ -4388,7 +4590,7 @@ class Models(_common.BaseModule):
4388
4590
  )
4389
4591
 
4390
4592
  return_value = types.ComputeTokensResponse._from_response(
4391
- response_dict, parameter_model
4593
+ response=response_dict, kwargs=parameter_model
4392
4594
  )
4393
4595
  self._api_client._verify_response(return_value)
4394
4596
  return return_value
@@ -4402,6 +4604,24 @@ class Models(_common.BaseModule):
4402
4604
  ) -> types.GenerateContentResponse:
4403
4605
  """Makes an API request to generate content using a model.
4404
4606
 
4607
+ For the `model` parameter, supported format for Vertex AI API includes:
4608
+ - the Gemini model ID, for example: 'gemini-1.5-flash-002'
4609
+ - the full resource name starts with 'projects/', for example:
4610
+ 'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-1.5-flash-002'
4611
+ - the partial resource name with 'publishers/', for example:
4612
+ 'publishers/google/models/gemini-1.5-flash-002' or
4613
+ 'publishers/meta/models/llama-3.1-405b-instruct-maas'
4614
+ - `/` separated publisher and model name, for example:
4615
+ 'google/gemini-1.5-flash-002' or 'meta/llama-3.1-405b-instruct-maas'
4616
+
4617
+ For the `model` parameter, supported format for Gemini API includes:
4618
+ - the Gemini model ID, for example: 'gemini-1.5-flash-002'
4619
+ - the model name starts with 'models/', for example:
4620
+ 'models/gemini-1.5-flash-002'
4621
+ - if you would like to use a tuned model, the model name starts with
4622
+ 'tunedModels/', for example:
4623
+ 'tunedModels/1234567890123456789'
4624
+
4405
4625
  Some models support multimodal input and output.
4406
4626
 
4407
4627
  Usage:
@@ -4546,9 +4766,14 @@ class Models(_common.BaseModule):
4546
4766
  *,
4547
4767
  config: Optional[types.ListModelsConfigOrDict] = None,
4548
4768
  ) -> Pager[types.Model]:
4549
- """Makes an API request to list the tuned models available to your project.
4769
+ """Makes an API request to list the available models.
4550
4770
 
4551
- This method only lists tuned models for the Vertex AI API.
4771
+ If `query_base` is set to True in the config, the API will return all
4772
+ available base models. If set to False or not set (default), it will return
4773
+ all tuned models.
4774
+
4775
+ Args:
4776
+ config (ListModelsConfigOrDict): Configuration for retrieving models.
4552
4777
 
4553
4778
  Usage:
4554
4779
 
@@ -4557,6 +4782,10 @@ class Models(_common.BaseModule):
4557
4782
  response=client.models.list(config={'page_size': 5})
4558
4783
  print(response.page)
4559
4784
  # [Model(name='projects/./locations/./models/123', display_name='my_model'
4785
+
4786
+ response=client.models.list(config={'page_size': 5, 'query_base': True})
4787
+ print(response.page)
4788
+ # [Model(name='publishers/google/models/gemini-2.0-flash-exp' ...
4560
4789
  """
4561
4790
 
4562
4791
  config = (
@@ -4565,13 +4794,7 @@ class Models(_common.BaseModule):
4565
4794
  )
4566
4795
  if self._api_client.vertexai:
4567
4796
  config = config.copy()
4568
- if config.query_base:
4569
- http_options = (
4570
- config.http_options if config.http_options else HttpOptionsDict()
4571
- )
4572
- http_options['skip_project_and_location_in_path'] = True
4573
- config.http_options = http_options
4574
- else:
4797
+ if not config.query_base:
4575
4798
  # Filter for tuning jobs artifacts by labels.
4576
4799
  filter_value = config.filter
4577
4800
  config.filter = (
@@ -4589,7 +4812,7 @@ class Models(_common.BaseModule):
4589
4812
  )
4590
4813
 
4591
4814
 
4592
- class AsyncModels(_common.BaseModule):
4815
+ class AsyncModels(_api_module.BaseModule):
4593
4816
 
4594
4817
  async def _generate_content(
4595
4818
  self,
@@ -4618,10 +4841,16 @@ class AsyncModels(_common.BaseModule):
4618
4841
  if query_params:
4619
4842
  path = f'{path}?{urlencode(query_params)}'
4620
4843
  # TODO: remove the hack that pops config.
4621
- config = request_dict.pop('config', None)
4622
- http_options = config.pop('httpOptions', None) if config else None
4844
+ request_dict.pop('config', None)
4845
+
4846
+ http_options = None
4847
+ if isinstance(config, dict):
4848
+ http_options = config.get('http_options', None)
4849
+ elif hasattr(config, 'http_options'):
4850
+ http_options = config.http_options
4851
+
4623
4852
  request_dict = _common.convert_to_dict(request_dict)
4624
- request_dict = _common.apply_base64_encoding(request_dict)
4853
+ request_dict = _common.encode_unserializable_types(request_dict)
4625
4854
 
4626
4855
  response_dict = await self._api_client.async_request(
4627
4856
  'post', path, request_dict, http_options
@@ -4637,7 +4866,7 @@ class AsyncModels(_common.BaseModule):
4637
4866
  )
4638
4867
 
4639
4868
  return_value = types.GenerateContentResponse._from_response(
4640
- response_dict, parameter_model
4869
+ response=response_dict, kwargs=parameter_model
4641
4870
  )
4642
4871
  self._api_client._verify_response(return_value)
4643
4872
  return return_value
@@ -4648,7 +4877,7 @@ class AsyncModels(_common.BaseModule):
4648
4877
  model: str,
4649
4878
  contents: Union[types.ContentListUnion, types.ContentListUnionDict],
4650
4879
  config: Optional[types.GenerateContentConfigOrDict] = None,
4651
- ) -> AsyncIterator[types.GenerateContentResponse]:
4880
+ ) -> Awaitable[AsyncIterator[types.GenerateContentResponse]]:
4652
4881
  parameter_model = types._GenerateContentParameters(
4653
4882
  model=model,
4654
4883
  contents=contents,
@@ -4673,29 +4902,40 @@ class AsyncModels(_common.BaseModule):
4673
4902
  if query_params:
4674
4903
  path = f'{path}?{urlencode(query_params)}'
4675
4904
  # TODO: remove the hack that pops config.
4676
- config = request_dict.pop('config', None)
4677
- http_options = config.pop('httpOptions', None) if config else None
4905
+ request_dict.pop('config', None)
4906
+
4907
+ http_options = None
4908
+ if isinstance(config, dict):
4909
+ http_options = config.get('http_options', None)
4910
+ elif hasattr(config, 'http_options'):
4911
+ http_options = config.http_options
4912
+
4678
4913
  request_dict = _common.convert_to_dict(request_dict)
4679
- request_dict = _common.apply_base64_encoding(request_dict)
4914
+ request_dict = _common.encode_unserializable_types(request_dict)
4680
4915
 
4681
- async for response_dict in self._api_client.async_request_streamed(
4916
+ response_stream = await self._api_client.async_request_streamed(
4682
4917
  'post', path, request_dict, http_options
4683
- ):
4918
+ )
4684
4919
 
4685
- if self._api_client.vertexai:
4686
- response_dict = _GenerateContentResponse_from_vertex(
4687
- self._api_client, response_dict
4688
- )
4689
- else:
4690
- response_dict = _GenerateContentResponse_from_mldev(
4691
- self._api_client, response_dict
4920
+ async def async_generator():
4921
+ async for response_dict in response_stream:
4922
+
4923
+ if self._api_client.vertexai:
4924
+ response_dict = _GenerateContentResponse_from_vertex(
4925
+ self._api_client, response_dict
4926
+ )
4927
+ else:
4928
+ response_dict = _GenerateContentResponse_from_mldev(
4929
+ self._api_client, response_dict
4930
+ )
4931
+
4932
+ return_value = types.GenerateContentResponse._from_response(
4933
+ response=response_dict, kwargs=parameter_model
4692
4934
  )
4935
+ self._api_client._verify_response(return_value)
4936
+ yield return_value
4693
4937
 
4694
- return_value = types.GenerateContentResponse._from_response(
4695
- response_dict, parameter_model
4696
- )
4697
- self._api_client._verify_response(return_value)
4698
- yield return_value
4938
+ return async_generator()
4699
4939
 
4700
4940
  async def embed_content(
4701
4941
  self,
@@ -4747,10 +4987,16 @@ class AsyncModels(_common.BaseModule):
4747
4987
  if query_params:
4748
4988
  path = f'{path}?{urlencode(query_params)}'
4749
4989
  # TODO: remove the hack that pops config.
4750
- config = request_dict.pop('config', None)
4751
- http_options = config.pop('httpOptions', None) if config else None
4990
+ request_dict.pop('config', None)
4991
+
4992
+ http_options = None
4993
+ if isinstance(config, dict):
4994
+ http_options = config.get('http_options', None)
4995
+ elif hasattr(config, 'http_options'):
4996
+ http_options = config.http_options
4997
+
4752
4998
  request_dict = _common.convert_to_dict(request_dict)
4753
- request_dict = _common.apply_base64_encoding(request_dict)
4999
+ request_dict = _common.encode_unserializable_types(request_dict)
4754
5000
 
4755
5001
  response_dict = await self._api_client.async_request(
4756
5002
  'post', path, request_dict, http_options
@@ -4766,33 +5012,33 @@ class AsyncModels(_common.BaseModule):
4766
5012
  )
4767
5013
 
4768
5014
  return_value = types.EmbedContentResponse._from_response(
4769
- response_dict, parameter_model
5015
+ response=response_dict, kwargs=parameter_model
4770
5016
  )
4771
5017
  self._api_client._verify_response(return_value)
4772
5018
  return return_value
4773
5019
 
4774
- async def generate_image(
5020
+ async def generate_images(
4775
5021
  self,
4776
5022
  *,
4777
5023
  model: str,
4778
5024
  prompt: str,
4779
- config: Optional[types.GenerateImageConfigOrDict] = None,
4780
- ) -> types.GenerateImageResponse:
4781
- """Generates an image based on a text description and configuration.
5025
+ config: Optional[types.GenerateImagesConfigOrDict] = None,
5026
+ ) -> types.GenerateImagesResponse:
5027
+ """Generates images based on a text description and configuration.
4782
5028
 
4783
5029
  Args:
4784
5030
  model (str): The model to use.
4785
- prompt (str): A text description of the image to generate.
4786
- config (GenerateImageConfig): Configuration for generation.
5031
+ prompt (str): A text description of the images to generate.
5032
+ config (GenerateImagesConfig): Configuration for generation.
4787
5033
 
4788
5034
  Usage:
4789
5035
 
4790
5036
  .. code-block:: python
4791
5037
 
4792
- response = client.models.generate_image(
5038
+ response = client.models.generate_images(
4793
5039
  model='imagen-3.0-generate-001',
4794
5040
  prompt='Man with a dog',
4795
- config=types.GenerateImageConfig(
5041
+ config=types.GenerateImagesConfig(
4796
5042
  number_of_images= 1,
4797
5043
  include_rai_reason= True,
4798
5044
  )
@@ -4801,19 +5047,19 @@ class AsyncModels(_common.BaseModule):
4801
5047
  # Shows a man with a dog.
4802
5048
  """
4803
5049
 
4804
- parameter_model = types._GenerateImageParameters(
5050
+ parameter_model = types._GenerateImagesParameters(
4805
5051
  model=model,
4806
5052
  prompt=prompt,
4807
5053
  config=config,
4808
5054
  )
4809
5055
 
4810
5056
  if self._api_client.vertexai:
4811
- request_dict = _GenerateImageParameters_to_vertex(
5057
+ request_dict = _GenerateImagesParameters_to_vertex(
4812
5058
  self._api_client, parameter_model
4813
5059
  )
4814
5060
  path = '{model}:predict'.format_map(request_dict.get('_url'))
4815
5061
  else:
4816
- request_dict = _GenerateImageParameters_to_mldev(
5062
+ request_dict = _GenerateImagesParameters_to_mldev(
4817
5063
  self._api_client, parameter_model
4818
5064
  )
4819
5065
  path = '{model}:predict'.format_map(request_dict.get('_url'))
@@ -4821,26 +5067,32 @@ class AsyncModels(_common.BaseModule):
4821
5067
  if query_params:
4822
5068
  path = f'{path}?{urlencode(query_params)}'
4823
5069
  # TODO: remove the hack that pops config.
4824
- config = request_dict.pop('config', None)
4825
- http_options = config.pop('httpOptions', None) if config else None
5070
+ request_dict.pop('config', None)
5071
+
5072
+ http_options = None
5073
+ if isinstance(config, dict):
5074
+ http_options = config.get('http_options', None)
5075
+ elif hasattr(config, 'http_options'):
5076
+ http_options = config.http_options
5077
+
4826
5078
  request_dict = _common.convert_to_dict(request_dict)
4827
- request_dict = _common.apply_base64_encoding(request_dict)
5079
+ request_dict = _common.encode_unserializable_types(request_dict)
4828
5080
 
4829
5081
  response_dict = await self._api_client.async_request(
4830
5082
  'post', path, request_dict, http_options
4831
5083
  )
4832
5084
 
4833
5085
  if self._api_client.vertexai:
4834
- response_dict = _GenerateImageResponse_from_vertex(
5086
+ response_dict = _GenerateImagesResponse_from_vertex(
4835
5087
  self._api_client, response_dict
4836
5088
  )
4837
5089
  else:
4838
- response_dict = _GenerateImageResponse_from_mldev(
5090
+ response_dict = _GenerateImagesResponse_from_mldev(
4839
5091
  self._api_client, response_dict
4840
5092
  )
4841
5093
 
4842
- return_value = types.GenerateImageResponse._from_response(
4843
- response_dict, parameter_model
5094
+ return_value = types.GenerateImagesResponse._from_response(
5095
+ response=response_dict, kwargs=parameter_model
4844
5096
  )
4845
5097
  self._api_client._verify_response(return_value)
4846
5098
  return return_value
@@ -4914,10 +5166,16 @@ class AsyncModels(_common.BaseModule):
4914
5166
  if query_params:
4915
5167
  path = f'{path}?{urlencode(query_params)}'
4916
5168
  # TODO: remove the hack that pops config.
4917
- config = request_dict.pop('config', None)
4918
- http_options = config.pop('httpOptions', None) if config else None
5169
+ request_dict.pop('config', None)
5170
+
5171
+ http_options = None
5172
+ if isinstance(config, dict):
5173
+ http_options = config.get('http_options', None)
5174
+ elif hasattr(config, 'http_options'):
5175
+ http_options = config.http_options
5176
+
4919
5177
  request_dict = _common.convert_to_dict(request_dict)
4920
- request_dict = _common.apply_base64_encoding(request_dict)
5178
+ request_dict = _common.encode_unserializable_types(request_dict)
4921
5179
 
4922
5180
  response_dict = await self._api_client.async_request(
4923
5181
  'post', path, request_dict, http_options
@@ -4933,7 +5191,7 @@ class AsyncModels(_common.BaseModule):
4933
5191
  )
4934
5192
 
4935
5193
  return_value = types.EditImageResponse._from_response(
4936
- response_dict, parameter_model
5194
+ response=response_dict, kwargs=parameter_model
4937
5195
  )
4938
5196
  self._api_client._verify_response(return_value)
4939
5197
  return return_value
@@ -4974,10 +5232,16 @@ class AsyncModels(_common.BaseModule):
4974
5232
  if query_params:
4975
5233
  path = f'{path}?{urlencode(query_params)}'
4976
5234
  # TODO: remove the hack that pops config.
4977
- config = request_dict.pop('config', None)
4978
- http_options = config.pop('httpOptions', None) if config else None
5235
+ request_dict.pop('config', None)
5236
+
5237
+ http_options = None
5238
+ if isinstance(config, dict):
5239
+ http_options = config.get('http_options', None)
5240
+ elif hasattr(config, 'http_options'):
5241
+ http_options = config.http_options
5242
+
4979
5243
  request_dict = _common.convert_to_dict(request_dict)
4980
- request_dict = _common.apply_base64_encoding(request_dict)
5244
+ request_dict = _common.encode_unserializable_types(request_dict)
4981
5245
 
4982
5246
  response_dict = await self._api_client.async_request(
4983
5247
  'post', path, request_dict, http_options
@@ -4993,14 +5257,17 @@ class AsyncModels(_common.BaseModule):
4993
5257
  )
4994
5258
 
4995
5259
  return_value = types.UpscaleImageResponse._from_response(
4996
- response_dict, parameter_model
5260
+ response=response_dict, kwargs=parameter_model
4997
5261
  )
4998
5262
  self._api_client._verify_response(return_value)
4999
5263
  return return_value
5000
5264
 
5001
- async def get(self, *, model: str) -> types.Model:
5265
+ async def get(
5266
+ self, *, model: str, config: Optional[types.GetModelConfigOrDict] = None
5267
+ ) -> types.Model:
5002
5268
  parameter_model = types._GetModelParameters(
5003
5269
  model=model,
5270
+ config=config,
5004
5271
  )
5005
5272
 
5006
5273
  if self._api_client.vertexai:
@@ -5017,10 +5284,16 @@ class AsyncModels(_common.BaseModule):
5017
5284
  if query_params:
5018
5285
  path = f'{path}?{urlencode(query_params)}'
5019
5286
  # TODO: remove the hack that pops config.
5020
- config = request_dict.pop('config', None)
5021
- http_options = config.pop('httpOptions', None) if config else None
5287
+ request_dict.pop('config', None)
5288
+
5289
+ http_options = None
5290
+ if isinstance(config, dict):
5291
+ http_options = config.get('http_options', None)
5292
+ elif hasattr(config, 'http_options'):
5293
+ http_options = config.http_options
5294
+
5022
5295
  request_dict = _common.convert_to_dict(request_dict)
5023
- request_dict = _common.apply_base64_encoding(request_dict)
5296
+ request_dict = _common.encode_unserializable_types(request_dict)
5024
5297
 
5025
5298
  response_dict = await self._api_client.async_request(
5026
5299
  'get', path, request_dict, http_options
@@ -5031,7 +5304,9 @@ class AsyncModels(_common.BaseModule):
5031
5304
  else:
5032
5305
  response_dict = _Model_from_mldev(self._api_client, response_dict)
5033
5306
 
5034
- return_value = types.Model._from_response(response_dict, parameter_model)
5307
+ return_value = types.Model._from_response(
5308
+ response=response_dict, kwargs=parameter_model
5309
+ )
5035
5310
  self._api_client._verify_response(return_value)
5036
5311
  return return_value
5037
5312
 
@@ -5056,10 +5331,16 @@ class AsyncModels(_common.BaseModule):
5056
5331
  if query_params:
5057
5332
  path = f'{path}?{urlencode(query_params)}'
5058
5333
  # TODO: remove the hack that pops config.
5059
- config = request_dict.pop('config', None)
5060
- http_options = config.pop('httpOptions', None) if config else None
5334
+ request_dict.pop('config', None)
5335
+
5336
+ http_options = None
5337
+ if isinstance(config, dict):
5338
+ http_options = config.get('http_options', None)
5339
+ elif hasattr(config, 'http_options'):
5340
+ http_options = config.http_options
5341
+
5061
5342
  request_dict = _common.convert_to_dict(request_dict)
5062
- request_dict = _common.apply_base64_encoding(request_dict)
5343
+ request_dict = _common.encode_unserializable_types(request_dict)
5063
5344
 
5064
5345
  response_dict = await self._api_client.async_request(
5065
5346
  'get', path, request_dict, http_options
@@ -5075,7 +5356,7 @@ class AsyncModels(_common.BaseModule):
5075
5356
  )
5076
5357
 
5077
5358
  return_value = types.ListModelsResponse._from_response(
5078
- response_dict, parameter_model
5359
+ response=response_dict, kwargs=parameter_model
5079
5360
  )
5080
5361
  self._api_client._verify_response(return_value)
5081
5362
  return return_value
@@ -5105,10 +5386,16 @@ class AsyncModels(_common.BaseModule):
5105
5386
  if query_params:
5106
5387
  path = f'{path}?{urlencode(query_params)}'
5107
5388
  # TODO: remove the hack that pops config.
5108
- config = request_dict.pop('config', None)
5109
- http_options = config.pop('httpOptions', None) if config else None
5389
+ request_dict.pop('config', None)
5390
+
5391
+ http_options = None
5392
+ if isinstance(config, dict):
5393
+ http_options = config.get('http_options', None)
5394
+ elif hasattr(config, 'http_options'):
5395
+ http_options = config.http_options
5396
+
5110
5397
  request_dict = _common.convert_to_dict(request_dict)
5111
- request_dict = _common.apply_base64_encoding(request_dict)
5398
+ request_dict = _common.encode_unserializable_types(request_dict)
5112
5399
 
5113
5400
  response_dict = await self._api_client.async_request(
5114
5401
  'patch', path, request_dict, http_options
@@ -5119,13 +5406,21 @@ class AsyncModels(_common.BaseModule):
5119
5406
  else:
5120
5407
  response_dict = _Model_from_mldev(self._api_client, response_dict)
5121
5408
 
5122
- return_value = types.Model._from_response(response_dict, parameter_model)
5409
+ return_value = types.Model._from_response(
5410
+ response=response_dict, kwargs=parameter_model
5411
+ )
5123
5412
  self._api_client._verify_response(return_value)
5124
5413
  return return_value
5125
5414
 
5126
- async def delete(self, *, model: str) -> types.DeleteModelResponse:
5415
+ async def delete(
5416
+ self,
5417
+ *,
5418
+ model: str,
5419
+ config: Optional[types.DeleteModelConfigOrDict] = None,
5420
+ ) -> types.DeleteModelResponse:
5127
5421
  parameter_model = types._DeleteModelParameters(
5128
5422
  model=model,
5423
+ config=config,
5129
5424
  )
5130
5425
 
5131
5426
  if self._api_client.vertexai:
@@ -5142,10 +5437,16 @@ class AsyncModels(_common.BaseModule):
5142
5437
  if query_params:
5143
5438
  path = f'{path}?{urlencode(query_params)}'
5144
5439
  # TODO: remove the hack that pops config.
5145
- config = request_dict.pop('config', None)
5146
- http_options = config.pop('httpOptions', None) if config else None
5440
+ request_dict.pop('config', None)
5441
+
5442
+ http_options = None
5443
+ if isinstance(config, dict):
5444
+ http_options = config.get('http_options', None)
5445
+ elif hasattr(config, 'http_options'):
5446
+ http_options = config.http_options
5447
+
5147
5448
  request_dict = _common.convert_to_dict(request_dict)
5148
- request_dict = _common.apply_base64_encoding(request_dict)
5449
+ request_dict = _common.encode_unserializable_types(request_dict)
5149
5450
 
5150
5451
  response_dict = await self._api_client.async_request(
5151
5452
  'delete', path, request_dict, http_options
@@ -5161,7 +5462,7 @@ class AsyncModels(_common.BaseModule):
5161
5462
  )
5162
5463
 
5163
5464
  return_value = types.DeleteModelResponse._from_response(
5164
- response_dict, parameter_model
5465
+ response=response_dict, kwargs=parameter_model
5165
5466
  )
5166
5467
  self._api_client._verify_response(return_value)
5167
5468
  return return_value
@@ -5213,10 +5514,16 @@ class AsyncModels(_common.BaseModule):
5213
5514
  if query_params:
5214
5515
  path = f'{path}?{urlencode(query_params)}'
5215
5516
  # TODO: remove the hack that pops config.
5216
- config = request_dict.pop('config', None)
5217
- http_options = config.pop('httpOptions', None) if config else None
5517
+ request_dict.pop('config', None)
5518
+
5519
+ http_options = None
5520
+ if isinstance(config, dict):
5521
+ http_options = config.get('http_options', None)
5522
+ elif hasattr(config, 'http_options'):
5523
+ http_options = config.http_options
5524
+
5218
5525
  request_dict = _common.convert_to_dict(request_dict)
5219
- request_dict = _common.apply_base64_encoding(request_dict)
5526
+ request_dict = _common.encode_unserializable_types(request_dict)
5220
5527
 
5221
5528
  response_dict = await self._api_client.async_request(
5222
5529
  'post', path, request_dict, http_options
@@ -5232,7 +5539,7 @@ class AsyncModels(_common.BaseModule):
5232
5539
  )
5233
5540
 
5234
5541
  return_value = types.CountTokensResponse._from_response(
5235
- response_dict, parameter_model
5542
+ response=response_dict, kwargs=parameter_model
5236
5543
  )
5237
5544
  self._api_client._verify_response(return_value)
5238
5545
  return return_value
@@ -5284,10 +5591,16 @@ class AsyncModels(_common.BaseModule):
5284
5591
  if query_params:
5285
5592
  path = f'{path}?{urlencode(query_params)}'
5286
5593
  # TODO: remove the hack that pops config.
5287
- config = request_dict.pop('config', None)
5288
- http_options = config.pop('httpOptions', None) if config else None
5594
+ request_dict.pop('config', None)
5595
+
5596
+ http_options = None
5597
+ if isinstance(config, dict):
5598
+ http_options = config.get('http_options', None)
5599
+ elif hasattr(config, 'http_options'):
5600
+ http_options = config.http_options
5601
+
5289
5602
  request_dict = _common.convert_to_dict(request_dict)
5290
- request_dict = _common.apply_base64_encoding(request_dict)
5603
+ request_dict = _common.encode_unserializable_types(request_dict)
5291
5604
 
5292
5605
  response_dict = await self._api_client.async_request(
5293
5606
  'post', path, request_dict, http_options
@@ -5303,7 +5616,7 @@ class AsyncModels(_common.BaseModule):
5303
5616
  )
5304
5617
 
5305
5618
  return_value = types.ComputeTokensResponse._from_response(
5306
- response_dict, parameter_model
5619
+ response=response_dict, kwargs=parameter_model
5307
5620
  )
5308
5621
  self._api_client._verify_response(return_value)
5309
5622
  return return_value
@@ -5396,9 +5709,14 @@ class AsyncModels(_common.BaseModule):
5396
5709
  *,
5397
5710
  config: Optional[types.ListModelsConfigOrDict] = None,
5398
5711
  ) -> AsyncPager[types.Model]:
5399
- """Makes an API request to list the tuned models available to your project.
5712
+ """Makes an API request to list the available models.
5400
5713
 
5401
- This method only lists tuned models for the Vertex AI API.
5714
+ If `query_base` is set to True in the config, the API will return all
5715
+ available base models. If set to False or not set (default), it will return
5716
+ all tuned models.
5717
+
5718
+ Args:
5719
+ config (ListModelsConfigOrDict): Configuration for retrieving models.
5402
5720
 
5403
5721
  Usage:
5404
5722
 
@@ -5407,6 +5725,12 @@ class AsyncModels(_common.BaseModule):
5407
5725
  response = await client.aio.models.list(config={'page_size': 5})
5408
5726
  print(response.page)
5409
5727
  # [Model(name='projects/./locations/./models/123', display_name='my_model'
5728
+
5729
+ response = await client.aio.models.list(
5730
+ config={'page_size': 5, 'query_base': True}
5731
+ )
5732
+ print(response.page)
5733
+ # [Model(name='publishers/google/models/gemini-2.0-flash-exp' ...
5410
5734
  """
5411
5735
 
5412
5736
  config = (
@@ -5415,13 +5739,7 @@ class AsyncModels(_common.BaseModule):
5415
5739
  )
5416
5740
  if self._api_client.vertexai:
5417
5741
  config = config.copy()
5418
- if config.query_base:
5419
- http_options = (
5420
- config.http_options if config.http_options else HttpOptionsDict()
5421
- )
5422
- http_options['skip_project_and_location_in_path'] = True
5423
- config.http_options = http_options
5424
- else:
5742
+ if not config.query_base:
5425
5743
  # Filter for tuning jobs artifacts by labels.
5426
5744
  filter_value = config.filter
5427
5745
  config.filter = (