google-genai 0.6.0__py3-none-any.whl → 0.8.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(
@@ -796,6 +797,7 @@ def _GenerateContentConfig_to_mldev(
796
797
  parent_object: dict = None,
797
798
  ) -> dict:
798
799
  to_object = {}
800
+
799
801
  if getv(from_object, ['system_instruction']) is not None:
800
802
  setv(
801
803
  parent_object,
@@ -871,7 +873,7 @@ def _GenerateContentConfig_to_mldev(
871
873
  )
872
874
 
873
875
  if getv(from_object, ['routing_config']) is not None:
874
- raise ValueError('routing_config parameter is not supported in Google AI.')
876
+ raise ValueError('routing_config parameter is not supported in Gemini API.')
875
877
 
876
878
  if getv(from_object, ['safety_settings']) is not None:
877
879
  setv(
@@ -920,7 +922,7 @@ def _GenerateContentConfig_to_mldev(
920
922
 
921
923
  if getv(from_object, ['media_resolution']) is not None:
922
924
  raise ValueError(
923
- 'media_resolution parameter is not supported in Google AI.'
925
+ 'media_resolution parameter is not supported in Gemini API.'
924
926
  )
925
927
 
926
928
  if getv(from_object, ['speech_config']) is not None:
@@ -935,7 +937,9 @@ def _GenerateContentConfig_to_mldev(
935
937
  )
936
938
 
937
939
  if getv(from_object, ['audio_timestamp']) is not None:
938
- raise ValueError('audio_timestamp parameter is not supported in Google AI.')
940
+ raise ValueError(
941
+ 'audio_timestamp parameter is not supported in Gemini API.'
942
+ )
939
943
 
940
944
  if getv(from_object, ['thinking_config']) is not None:
941
945
  setv(
@@ -955,6 +959,7 @@ def _GenerateContentConfig_to_vertex(
955
959
  parent_object: dict = None,
956
960
  ) -> dict:
957
961
  to_object = {}
962
+
958
963
  if getv(from_object, ['system_instruction']) is not None:
959
964
  setv(
960
965
  parent_object,
@@ -1188,8 +1193,6 @@ def _EmbedContentConfig_to_mldev(
1188
1193
  parent_object: dict = None,
1189
1194
  ) -> dict:
1190
1195
  to_object = {}
1191
- if getv(from_object, ['http_options']) is not None:
1192
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1193
1196
 
1194
1197
  if getv(from_object, ['task_type']) is not None:
1195
1198
  setv(
@@ -1209,10 +1212,10 @@ def _EmbedContentConfig_to_mldev(
1209
1212
  )
1210
1213
 
1211
1214
  if getv(from_object, ['mime_type']) is not None:
1212
- raise ValueError('mime_type parameter is not supported in Google AI.')
1215
+ raise ValueError('mime_type parameter is not supported in Gemini API.')
1213
1216
 
1214
1217
  if getv(from_object, ['auto_truncate']) is not None:
1215
- raise ValueError('auto_truncate parameter is not supported in Google AI.')
1218
+ raise ValueError('auto_truncate parameter is not supported in Gemini API.')
1216
1219
 
1217
1220
  return to_object
1218
1221
 
@@ -1223,8 +1226,6 @@ def _EmbedContentConfig_to_vertex(
1223
1226
  parent_object: dict = None,
1224
1227
  ) -> dict:
1225
1228
  to_object = {}
1226
- if getv(from_object, ['http_options']) is not None:
1227
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1228
1229
 
1229
1230
  if getv(from_object, ['task_type']) is not None:
1230
1231
  setv(
@@ -1329,17 +1330,15 @@ def _EmbedContentParameters_to_vertex(
1329
1330
  return to_object
1330
1331
 
1331
1332
 
1332
- def _GenerateImageConfig_to_mldev(
1333
+ def _GenerateImagesConfig_to_mldev(
1333
1334
  api_client: ApiClient,
1334
1335
  from_object: Union[dict, object],
1335
1336
  parent_object: dict = None,
1336
1337
  ) -> dict:
1337
1338
  to_object = {}
1338
- if getv(from_object, ['http_options']) is not None:
1339
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1340
1339
 
1341
1340
  if getv(from_object, ['output_gcs_uri']) is not None:
1342
- 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.')
1343
1342
 
1344
1343
  if getv(from_object, ['negative_prompt']) is not None:
1345
1344
  setv(
@@ -1363,9 +1362,12 @@ def _GenerateImageConfig_to_mldev(
1363
1362
  )
1364
1363
 
1365
1364
  if getv(from_object, ['seed']) is not None:
1366
- raise ValueError('seed parameter is not supported in Google AI.')
1365
+ raise ValueError('seed parameter is not supported in Gemini API.')
1367
1366
 
1368
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
+ )
1369
1371
  setv(
1370
1372
  parent_object,
1371
1373
  ['parameters', 'safetySetting'],
@@ -1373,6 +1375,9 @@ def _GenerateImageConfig_to_mldev(
1373
1375
  )
1374
1376
 
1375
1377
  if getv(from_object, ['person_generation']) is not None:
1378
+ _PersonGeneration_to_mldev_enum_validate(
1379
+ getv(from_object, ['person_generation'])
1380
+ )
1376
1381
  setv(
1377
1382
  parent_object,
1378
1383
  ['parameters', 'personGeneration'],
@@ -1415,7 +1420,7 @@ def _GenerateImageConfig_to_mldev(
1415
1420
  )
1416
1421
 
1417
1422
  if getv(from_object, ['add_watermark']) is not None:
1418
- raise ValueError('add_watermark parameter is not supported in Google AI.')
1423
+ raise ValueError('add_watermark parameter is not supported in Gemini API.')
1419
1424
 
1420
1425
  if getv(from_object, ['aspect_ratio']) is not None:
1421
1426
  setv(
@@ -1424,17 +1429,22 @@ def _GenerateImageConfig_to_mldev(
1424
1429
  getv(from_object, ['aspect_ratio']),
1425
1430
  )
1426
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
+
1427
1439
  return to_object
1428
1440
 
1429
1441
 
1430
- def _GenerateImageConfig_to_vertex(
1442
+ def _GenerateImagesConfig_to_vertex(
1431
1443
  api_client: ApiClient,
1432
1444
  from_object: Union[dict, object],
1433
1445
  parent_object: dict = None,
1434
1446
  ) -> dict:
1435
1447
  to_object = {}
1436
- if getv(from_object, ['http_options']) is not None:
1437
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1438
1448
 
1439
1449
  if getv(from_object, ['output_gcs_uri']) is not None:
1440
1450
  setv(
@@ -1530,10 +1540,17 @@ def _GenerateImageConfig_to_vertex(
1530
1540
  getv(from_object, ['aspect_ratio']),
1531
1541
  )
1532
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
+
1533
1550
  return to_object
1534
1551
 
1535
1552
 
1536
- def _GenerateImageParameters_to_mldev(
1553
+ def _GenerateImagesParameters_to_mldev(
1537
1554
  api_client: ApiClient,
1538
1555
  from_object: Union[dict, object],
1539
1556
  parent_object: dict = None,
@@ -1553,7 +1570,7 @@ def _GenerateImageParameters_to_mldev(
1553
1570
  setv(
1554
1571
  to_object,
1555
1572
  ['config'],
1556
- _GenerateImageConfig_to_mldev(
1573
+ _GenerateImagesConfig_to_mldev(
1557
1574
  api_client, getv(from_object, ['config']), to_object
1558
1575
  ),
1559
1576
  )
@@ -1561,7 +1578,7 @@ def _GenerateImageParameters_to_mldev(
1561
1578
  return to_object
1562
1579
 
1563
1580
 
1564
- def _GenerateImageParameters_to_vertex(
1581
+ def _GenerateImagesParameters_to_vertex(
1565
1582
  api_client: ApiClient,
1566
1583
  from_object: Union[dict, object],
1567
1584
  parent_object: dict = None,
@@ -1581,7 +1598,7 @@ def _GenerateImageParameters_to_vertex(
1581
1598
  setv(
1582
1599
  to_object,
1583
1600
  ['config'],
1584
- _GenerateImageConfig_to_vertex(
1601
+ _GenerateImagesConfig_to_vertex(
1585
1602
  api_client, getv(from_object, ['config']), to_object
1586
1603
  ),
1587
1604
  )
@@ -1596,7 +1613,7 @@ def _Image_to_mldev(
1596
1613
  ) -> dict:
1597
1614
  to_object = {}
1598
1615
  if getv(from_object, ['gcs_uri']) is not None:
1599
- raise ValueError('gcs_uri parameter is not supported in Google AI.')
1616
+ raise ValueError('gcs_uri parameter is not supported in Gemini API.')
1600
1617
 
1601
1618
  if getv(from_object, ['image_bytes']) is not None:
1602
1619
  setv(
@@ -1605,6 +1622,9 @@ def _Image_to_mldev(
1605
1622
  t.t_bytes(api_client, getv(from_object, ['image_bytes'])),
1606
1623
  )
1607
1624
 
1625
+ if getv(from_object, ['mime_type']) is not None:
1626
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1627
+
1608
1628
  return to_object
1609
1629
 
1610
1630
 
@@ -1624,6 +1644,9 @@ def _Image_to_vertex(
1624
1644
  t.t_bytes(api_client, getv(from_object, ['image_bytes'])),
1625
1645
  )
1626
1646
 
1647
+ if getv(from_object, ['mime_type']) is not None:
1648
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1649
+
1627
1650
  return to_object
1628
1651
 
1629
1652
 
@@ -1634,15 +1657,15 @@ def _MaskReferenceConfig_to_mldev(
1634
1657
  ) -> dict:
1635
1658
  to_object = {}
1636
1659
  if getv(from_object, ['mask_mode']) is not None:
1637
- raise ValueError('mask_mode parameter is not supported in Google AI.')
1660
+ raise ValueError('mask_mode parameter is not supported in Gemini API.')
1638
1661
 
1639
1662
  if getv(from_object, ['segmentation_classes']) is not None:
1640
1663
  raise ValueError(
1641
- 'segmentation_classes parameter is not supported in Google AI.'
1664
+ 'segmentation_classes parameter is not supported in Gemini API.'
1642
1665
  )
1643
1666
 
1644
1667
  if getv(from_object, ['mask_dilation']) is not None:
1645
- raise ValueError('mask_dilation parameter is not supported in Google AI.')
1668
+ raise ValueError('mask_dilation parameter is not supported in Gemini API.')
1646
1669
 
1647
1670
  return to_object
1648
1671
 
@@ -1674,12 +1697,12 @@ def _ControlReferenceConfig_to_mldev(
1674
1697
  ) -> dict:
1675
1698
  to_object = {}
1676
1699
  if getv(from_object, ['control_type']) is not None:
1677
- raise ValueError('control_type parameter is not supported in Google AI.')
1700
+ raise ValueError('control_type parameter is not supported in Gemini API.')
1678
1701
 
1679
1702
  if getv(from_object, ['enable_control_image_computation']) is not None:
1680
1703
  raise ValueError(
1681
- 'enable_control_image_computation parameter is not supported in'
1682
- ' Google AI.'
1704
+ 'enable_control_image_computation parameter is not supported in Gemini'
1705
+ ' API.'
1683
1706
  )
1684
1707
 
1685
1708
  return to_object
@@ -1712,7 +1735,7 @@ def _StyleReferenceConfig_to_mldev(
1712
1735
  to_object = {}
1713
1736
  if getv(from_object, ['style_description']) is not None:
1714
1737
  raise ValueError(
1715
- 'style_description parameter is not supported in Google AI.'
1738
+ 'style_description parameter is not supported in Gemini API.'
1716
1739
  )
1717
1740
 
1718
1741
  return to_object
@@ -1741,11 +1764,11 @@ def _SubjectReferenceConfig_to_mldev(
1741
1764
  ) -> dict:
1742
1765
  to_object = {}
1743
1766
  if getv(from_object, ['subject_type']) is not None:
1744
- raise ValueError('subject_type parameter is not supported in Google AI.')
1767
+ raise ValueError('subject_type parameter is not supported in Gemini API.')
1745
1768
 
1746
1769
  if getv(from_object, ['subject_description']) is not None:
1747
1770
  raise ValueError(
1748
- 'subject_description parameter is not supported in Google AI.'
1771
+ 'subject_description parameter is not supported in Gemini API.'
1749
1772
  )
1750
1773
 
1751
1774
  return to_object
@@ -1777,32 +1800,34 @@ def _ReferenceImageAPI_to_mldev(
1777
1800
  ) -> dict:
1778
1801
  to_object = {}
1779
1802
  if getv(from_object, ['reference_image']) is not None:
1780
- 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
+ )
1781
1806
 
1782
1807
  if getv(from_object, ['reference_id']) is not None:
1783
- raise ValueError('reference_id parameter is not supported in Google AI.')
1808
+ raise ValueError('reference_id parameter is not supported in Gemini API.')
1784
1809
 
1785
1810
  if getv(from_object, ['reference_type']) is not None:
1786
- raise ValueError('reference_type parameter is not supported in Google AI.')
1811
+ raise ValueError('reference_type parameter is not supported in Gemini API.')
1787
1812
 
1788
1813
  if getv(from_object, ['mask_image_config']) is not None:
1789
1814
  raise ValueError(
1790
- 'mask_image_config parameter is not supported in Google AI.'
1815
+ 'mask_image_config parameter is not supported in Gemini API.'
1791
1816
  )
1792
1817
 
1793
1818
  if getv(from_object, ['control_image_config']) is not None:
1794
1819
  raise ValueError(
1795
- 'control_image_config parameter is not supported in Google AI.'
1820
+ 'control_image_config parameter is not supported in Gemini API.'
1796
1821
  )
1797
1822
 
1798
1823
  if getv(from_object, ['style_image_config']) is not None:
1799
1824
  raise ValueError(
1800
- 'style_image_config parameter is not supported in Google AI.'
1825
+ 'style_image_config parameter is not supported in Gemini API.'
1801
1826
  )
1802
1827
 
1803
1828
  if getv(from_object, ['subject_image_config']) is not None:
1804
1829
  raise ValueError(
1805
- 'subject_image_config parameter is not supported in Google AI.'
1830
+ 'subject_image_config parameter is not supported in Gemini API.'
1806
1831
  )
1807
1832
 
1808
1833
  return to_object
@@ -1874,11 +1899,9 @@ def _EditImageConfig_to_mldev(
1874
1899
  parent_object: dict = None,
1875
1900
  ) -> dict:
1876
1901
  to_object = {}
1877
- if getv(from_object, ['http_options']) is not None:
1878
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1879
1902
 
1880
1903
  if getv(from_object, ['output_gcs_uri']) is not None:
1881
- 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.')
1882
1905
 
1883
1906
  if getv(from_object, ['negative_prompt']) is not None:
1884
1907
  setv(
@@ -1902,9 +1925,12 @@ def _EditImageConfig_to_mldev(
1902
1925
  )
1903
1926
 
1904
1927
  if getv(from_object, ['seed']) is not None:
1905
- raise ValueError('seed parameter is not supported in Google AI.')
1928
+ raise ValueError('seed parameter is not supported in Gemini API.')
1906
1929
 
1907
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
+ )
1908
1934
  setv(
1909
1935
  parent_object,
1910
1936
  ['parameters', 'safetySetting'],
@@ -1912,6 +1938,9 @@ def _EditImageConfig_to_mldev(
1912
1938
  )
1913
1939
 
1914
1940
  if getv(from_object, ['person_generation']) is not None:
1941
+ _PersonGeneration_to_mldev_enum_validate(
1942
+ getv(from_object, ['person_generation'])
1943
+ )
1915
1944
  setv(
1916
1945
  parent_object,
1917
1946
  ['parameters', 'personGeneration'],
@@ -1954,6 +1983,7 @@ def _EditImageConfig_to_mldev(
1954
1983
  )
1955
1984
 
1956
1985
  if getv(from_object, ['edit_mode']) is not None:
1986
+ _EditMode_to_mldev_enum_validate(getv(from_object, ['edit_mode']))
1957
1987
  setv(
1958
1988
  parent_object,
1959
1989
  ['parameters', 'editMode'],
@@ -1969,8 +1999,6 @@ def _EditImageConfig_to_vertex(
1969
1999
  parent_object: dict = None,
1970
2000
  ) -> dict:
1971
2001
  to_object = {}
1972
- if getv(from_object, ['http_options']) is not None:
1973
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
1974
2002
 
1975
2003
  if getv(from_object, ['output_gcs_uri']) is not None:
1976
2004
  setv(
@@ -2144,8 +2172,6 @@ def _UpscaleImageAPIConfig_to_mldev(
2144
2172
  parent_object: dict = None,
2145
2173
  ) -> dict:
2146
2174
  to_object = {}
2147
- if getv(from_object, ['http_options']) is not None:
2148
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2149
2175
 
2150
2176
  if getv(from_object, ['include_rai_reason']) is not None:
2151
2177
  setv(
@@ -2187,8 +2213,6 @@ def _UpscaleImageAPIConfig_to_vertex(
2187
2213
  parent_object: dict = None,
2188
2214
  ) -> dict:
2189
2215
  to_object = {}
2190
- if getv(from_object, ['http_options']) is not None:
2191
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2192
2216
 
2193
2217
  if getv(from_object, ['include_rai_reason']) is not None:
2194
2218
  setv(
@@ -2315,6 +2339,9 @@ def _GetModelParameters_to_mldev(
2315
2339
  t.t_model(api_client, getv(from_object, ['model'])),
2316
2340
  )
2317
2341
 
2342
+ if getv(from_object, ['config']) is not None:
2343
+ setv(to_object, ['config'], getv(from_object, ['config']))
2344
+
2318
2345
  return to_object
2319
2346
 
2320
2347
 
@@ -2331,6 +2358,9 @@ def _GetModelParameters_to_vertex(
2331
2358
  t.t_model(api_client, getv(from_object, ['model'])),
2332
2359
  )
2333
2360
 
2361
+ if getv(from_object, ['config']) is not None:
2362
+ setv(to_object, ['config'], getv(from_object, ['config']))
2363
+
2334
2364
  return to_object
2335
2365
 
2336
2366
 
@@ -2340,8 +2370,6 @@ def _ListModelsConfig_to_mldev(
2340
2370
  parent_object: dict = None,
2341
2371
  ) -> dict:
2342
2372
  to_object = {}
2343
- if getv(from_object, ['http_options']) is not None:
2344
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2345
2373
 
2346
2374
  if getv(from_object, ['page_size']) is not None:
2347
2375
  setv(
@@ -2374,8 +2402,6 @@ def _ListModelsConfig_to_vertex(
2374
2402
  parent_object: dict = None,
2375
2403
  ) -> dict:
2376
2404
  to_object = {}
2377
- if getv(from_object, ['http_options']) is not None:
2378
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2379
2405
 
2380
2406
  if getv(from_object, ['page_size']) is not None:
2381
2407
  setv(
@@ -2444,6 +2470,7 @@ def _UpdateModelConfig_to_mldev(
2444
2470
  parent_object: dict = None,
2445
2471
  ) -> dict:
2446
2472
  to_object = {}
2473
+
2447
2474
  if getv(from_object, ['display_name']) is not None:
2448
2475
  setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
2449
2476
 
@@ -2459,6 +2486,7 @@ def _UpdateModelConfig_to_vertex(
2459
2486
  parent_object: dict = None,
2460
2487
  ) -> dict:
2461
2488
  to_object = {}
2489
+
2462
2490
  if getv(from_object, ['display_name']) is not None:
2463
2491
  setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
2464
2492
 
@@ -2531,6 +2559,9 @@ def _DeleteModelParameters_to_mldev(
2531
2559
  t.t_model(api_client, getv(from_object, ['model'])),
2532
2560
  )
2533
2561
 
2562
+ if getv(from_object, ['config']) is not None:
2563
+ setv(to_object, ['config'], getv(from_object, ['config']))
2564
+
2534
2565
  return to_object
2535
2566
 
2536
2567
 
@@ -2547,6 +2578,9 @@ def _DeleteModelParameters_to_vertex(
2547
2578
  t.t_model(api_client, getv(from_object, ['model'])),
2548
2579
  )
2549
2580
 
2581
+ if getv(from_object, ['config']) is not None:
2582
+ setv(to_object, ['config'], getv(from_object, ['config']))
2583
+
2550
2584
  return to_object
2551
2585
 
2552
2586
 
@@ -2556,8 +2590,6 @@ def _CountTokensConfig_to_mldev(
2556
2590
  parent_object: dict = None,
2557
2591
  ) -> dict:
2558
2592
  to_object = {}
2559
- if getv(from_object, ['http_options']) is not None:
2560
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2561
2593
 
2562
2594
  if getv(from_object, ['system_instruction']) is not None:
2563
2595
  setv(
@@ -2582,7 +2614,7 @@ def _CountTokensConfig_to_mldev(
2582
2614
 
2583
2615
  if getv(from_object, ['generation_config']) is not None:
2584
2616
  raise ValueError(
2585
- 'generation_config parameter is not supported in Google AI.'
2617
+ 'generation_config parameter is not supported in Gemini API.'
2586
2618
  )
2587
2619
 
2588
2620
  return to_object
@@ -2594,8 +2626,6 @@ def _CountTokensConfig_to_vertex(
2594
2626
  parent_object: dict = None,
2595
2627
  ) -> dict:
2596
2628
  to_object = {}
2597
- if getv(from_object, ['http_options']) is not None:
2598
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2599
2629
 
2600
2630
  if getv(from_object, ['system_instruction']) is not None:
2601
2631
  setv(
@@ -2702,30 +2732,6 @@ def _CountTokensParameters_to_vertex(
2702
2732
  return to_object
2703
2733
 
2704
2734
 
2705
- def _ComputeTokensConfig_to_mldev(
2706
- api_client: ApiClient,
2707
- from_object: Union[dict, object],
2708
- parent_object: dict = None,
2709
- ) -> dict:
2710
- to_object = {}
2711
- if getv(from_object, ['http_options']) is not None:
2712
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2713
-
2714
- return to_object
2715
-
2716
-
2717
- def _ComputeTokensConfig_to_vertex(
2718
- api_client: ApiClient,
2719
- from_object: Union[dict, object],
2720
- parent_object: dict = None,
2721
- ) -> dict:
2722
- to_object = {}
2723
- if getv(from_object, ['http_options']) is not None:
2724
- setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
2725
-
2726
- return to_object
2727
-
2728
-
2729
2735
  def _ComputeTokensParameters_to_mldev(
2730
2736
  api_client: ApiClient,
2731
2737
  from_object: Union[dict, object],
@@ -2740,16 +2746,10 @@ def _ComputeTokensParameters_to_mldev(
2740
2746
  )
2741
2747
 
2742
2748
  if getv(from_object, ['contents']) is not None:
2743
- raise ValueError('contents parameter is not supported in Google AI.')
2749
+ raise ValueError('contents parameter is not supported in Gemini API.')
2744
2750
 
2745
2751
  if getv(from_object, ['config']) is not None:
2746
- setv(
2747
- to_object,
2748
- ['config'],
2749
- _ComputeTokensConfig_to_mldev(
2750
- api_client, getv(from_object, ['config']), to_object
2751
- ),
2752
- )
2752
+ setv(to_object, ['config'], getv(from_object, ['config']))
2753
2753
 
2754
2754
  return to_object
2755
2755
 
@@ -2780,17 +2780,76 @@ def _ComputeTokensParameters_to_vertex(
2780
2780
  )
2781
2781
 
2782
2782
  if getv(from_object, ['config']) is not None:
2783
- setv(
2784
- to_object,
2785
- ['config'],
2786
- _ComputeTokensConfig_to_vertex(
2787
- api_client, getv(from_object, ['config']), to_object
2788
- ),
2789
- )
2783
+ setv(to_object, ['config'], getv(from_object, ['config']))
2790
2784
 
2791
2785
  return to_object
2792
2786
 
2793
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
+
2794
2853
  def _Part_from_mldev(
2795
2854
  api_client: ApiClient,
2796
2855
  from_object: Union[dict, object],
@@ -3259,6 +3318,9 @@ def _Image_from_mldev(
3259
3318
  t.t_bytes(api_client, getv(from_object, ['bytesBase64Encoded'])),
3260
3319
  )
3261
3320
 
3321
+ if getv(from_object, ['mimeType']) is not None:
3322
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3323
+
3262
3324
  return to_object
3263
3325
 
3264
3326
 
@@ -3278,6 +3340,9 @@ def _Image_from_vertex(
3278
3340
  t.t_bytes(api_client, getv(from_object, ['bytesBase64Encoded'])),
3279
3341
  )
3280
3342
 
3343
+ if getv(from_object, ['mimeType']) is not None:
3344
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3345
+
3281
3346
  return to_object
3282
3347
 
3283
3348
 
@@ -3301,6 +3366,9 @@ def _GeneratedImage_from_mldev(
3301
3366
  getv(from_object, ['raiFilteredReason']),
3302
3367
  )
3303
3368
 
3369
+ if getv(from_object, ['prompt']) is not None:
3370
+ setv(to_object, ['enhanced_prompt'], getv(from_object, ['prompt']))
3371
+
3304
3372
  return to_object
3305
3373
 
3306
3374
 
@@ -3324,10 +3392,13 @@ def _GeneratedImage_from_vertex(
3324
3392
  getv(from_object, ['raiFilteredReason']),
3325
3393
  )
3326
3394
 
3395
+ if getv(from_object, ['prompt']) is not None:
3396
+ setv(to_object, ['enhanced_prompt'], getv(from_object, ['prompt']))
3397
+
3327
3398
  return to_object
3328
3399
 
3329
3400
 
3330
- def _GenerateImageResponse_from_mldev(
3401
+ def _GenerateImagesResponse_from_mldev(
3331
3402
  api_client: ApiClient,
3332
3403
  from_object: Union[dict, object],
3333
3404
  parent_object: dict = None,
@@ -3346,7 +3417,7 @@ def _GenerateImageResponse_from_mldev(
3346
3417
  return to_object
3347
3418
 
3348
3419
 
3349
- def _GenerateImageResponse_from_vertex(
3420
+ def _GenerateImagesResponse_from_vertex(
3350
3421
  api_client: ApiClient,
3351
3422
  from_object: Union[dict, object],
3352
3423
  parent_object: dict = None,
@@ -3726,7 +3797,7 @@ def _ComputeTokensResponse_from_vertex(
3726
3797
  return to_object
3727
3798
 
3728
3799
 
3729
- class Models(_common.BaseModule):
3800
+ class Models(_api_module.BaseModule):
3730
3801
 
3731
3802
  def _generate_content(
3732
3803
  self,
@@ -3755,8 +3826,14 @@ class Models(_common.BaseModule):
3755
3826
  if query_params:
3756
3827
  path = f'{path}?{urlencode(query_params)}'
3757
3828
  # TODO: remove the hack that pops config.
3758
- config = request_dict.pop('config', None)
3759
- http_options = config.pop('httpOptions', None) if config else None
3829
+ request_dict.pop('config', None)
3830
+
3831
+ http_options = None
3832
+ if isinstance(config, dict):
3833
+ http_options = config.get('http_options', None)
3834
+ elif hasattr(config, 'http_options'):
3835
+ http_options = config.http_options
3836
+
3760
3837
  request_dict = _common.convert_to_dict(request_dict)
3761
3838
  request_dict = _common.encode_unserializable_types(request_dict)
3762
3839
 
@@ -3774,7 +3851,7 @@ class Models(_common.BaseModule):
3774
3851
  )
3775
3852
 
3776
3853
  return_value = types.GenerateContentResponse._from_response(
3777
- response_dict, parameter_model
3854
+ response=response_dict, kwargs=parameter_model
3778
3855
  )
3779
3856
  self._api_client._verify_response(return_value)
3780
3857
  return return_value
@@ -3810,8 +3887,14 @@ class Models(_common.BaseModule):
3810
3887
  if query_params:
3811
3888
  path = f'{path}?{urlencode(query_params)}'
3812
3889
  # TODO: remove the hack that pops config.
3813
- config = request_dict.pop('config', None)
3814
- http_options = config.pop('httpOptions', None) if config else None
3890
+ request_dict.pop('config', None)
3891
+
3892
+ http_options = None
3893
+ if isinstance(config, dict):
3894
+ http_options = config.get('http_options', None)
3895
+ elif hasattr(config, 'http_options'):
3896
+ http_options = config.http_options
3897
+
3815
3898
  request_dict = _common.convert_to_dict(request_dict)
3816
3899
  request_dict = _common.encode_unserializable_types(request_dict)
3817
3900
 
@@ -3829,7 +3912,7 @@ class Models(_common.BaseModule):
3829
3912
  )
3830
3913
 
3831
3914
  return_value = types.GenerateContentResponse._from_response(
3832
- response_dict, parameter_model
3915
+ response=response_dict, kwargs=parameter_model
3833
3916
  )
3834
3917
  self._api_client._verify_response(return_value)
3835
3918
  yield return_value
@@ -3884,8 +3967,14 @@ class Models(_common.BaseModule):
3884
3967
  if query_params:
3885
3968
  path = f'{path}?{urlencode(query_params)}'
3886
3969
  # TODO: remove the hack that pops config.
3887
- config = request_dict.pop('config', None)
3888
- http_options = config.pop('httpOptions', None) if config else None
3970
+ request_dict.pop('config', None)
3971
+
3972
+ http_options = None
3973
+ if isinstance(config, dict):
3974
+ http_options = config.get('http_options', None)
3975
+ elif hasattr(config, 'http_options'):
3976
+ http_options = config.http_options
3977
+
3889
3978
  request_dict = _common.convert_to_dict(request_dict)
3890
3979
  request_dict = _common.encode_unserializable_types(request_dict)
3891
3980
 
@@ -3903,33 +3992,33 @@ class Models(_common.BaseModule):
3903
3992
  )
3904
3993
 
3905
3994
  return_value = types.EmbedContentResponse._from_response(
3906
- response_dict, parameter_model
3995
+ response=response_dict, kwargs=parameter_model
3907
3996
  )
3908
3997
  self._api_client._verify_response(return_value)
3909
3998
  return return_value
3910
3999
 
3911
- def generate_image(
4000
+ def generate_images(
3912
4001
  self,
3913
4002
  *,
3914
4003
  model: str,
3915
4004
  prompt: str,
3916
- config: Optional[types.GenerateImageConfigOrDict] = None,
3917
- ) -> types.GenerateImageResponse:
3918
- """Generates an image based on a text description and configuration.
4005
+ config: Optional[types.GenerateImagesConfigOrDict] = None,
4006
+ ) -> types.GenerateImagesResponse:
4007
+ """Generates images based on a text description and configuration.
3919
4008
 
3920
4009
  Args:
3921
4010
  model (str): The model to use.
3922
- prompt (str): A text description of the image to generate.
3923
- config (GenerateImageConfig): Configuration for generation.
4011
+ prompt (str): A text description of the images to generate.
4012
+ config (GenerateImagesConfig): Configuration for generation.
3924
4013
 
3925
4014
  Usage:
3926
4015
 
3927
4016
  .. code-block:: python
3928
4017
 
3929
- response = client.models.generate_image(
4018
+ response = client.models.generate_images(
3930
4019
  model='imagen-3.0-generate-001',
3931
4020
  prompt='Man with a dog',
3932
- config=types.GenerateImageConfig(
4021
+ config=types.GenerateImagesConfig(
3933
4022
  number_of_images= 1,
3934
4023
  include_rai_reason= True,
3935
4024
  )
@@ -3938,19 +4027,19 @@ class Models(_common.BaseModule):
3938
4027
  # Shows a man with a dog.
3939
4028
  """
3940
4029
 
3941
- parameter_model = types._GenerateImageParameters(
4030
+ parameter_model = types._GenerateImagesParameters(
3942
4031
  model=model,
3943
4032
  prompt=prompt,
3944
4033
  config=config,
3945
4034
  )
3946
4035
 
3947
4036
  if self._api_client.vertexai:
3948
- request_dict = _GenerateImageParameters_to_vertex(
4037
+ request_dict = _GenerateImagesParameters_to_vertex(
3949
4038
  self._api_client, parameter_model
3950
4039
  )
3951
4040
  path = '{model}:predict'.format_map(request_dict.get('_url'))
3952
4041
  else:
3953
- request_dict = _GenerateImageParameters_to_mldev(
4042
+ request_dict = _GenerateImagesParameters_to_mldev(
3954
4043
  self._api_client, parameter_model
3955
4044
  )
3956
4045
  path = '{model}:predict'.format_map(request_dict.get('_url'))
@@ -3958,8 +4047,14 @@ class Models(_common.BaseModule):
3958
4047
  if query_params:
3959
4048
  path = f'{path}?{urlencode(query_params)}'
3960
4049
  # TODO: remove the hack that pops config.
3961
- config = request_dict.pop('config', None)
3962
- http_options = config.pop('httpOptions', None) if config else None
4050
+ request_dict.pop('config', None)
4051
+
4052
+ http_options = None
4053
+ if isinstance(config, dict):
4054
+ http_options = config.get('http_options', None)
4055
+ elif hasattr(config, 'http_options'):
4056
+ http_options = config.http_options
4057
+
3963
4058
  request_dict = _common.convert_to_dict(request_dict)
3964
4059
  request_dict = _common.encode_unserializable_types(request_dict)
3965
4060
 
@@ -3968,16 +4063,16 @@ class Models(_common.BaseModule):
3968
4063
  )
3969
4064
 
3970
4065
  if self._api_client.vertexai:
3971
- response_dict = _GenerateImageResponse_from_vertex(
4066
+ response_dict = _GenerateImagesResponse_from_vertex(
3972
4067
  self._api_client, response_dict
3973
4068
  )
3974
4069
  else:
3975
- response_dict = _GenerateImageResponse_from_mldev(
4070
+ response_dict = _GenerateImagesResponse_from_mldev(
3976
4071
  self._api_client, response_dict
3977
4072
  )
3978
4073
 
3979
- return_value = types.GenerateImageResponse._from_response(
3980
- response_dict, parameter_model
4074
+ return_value = types.GenerateImagesResponse._from_response(
4075
+ response=response_dict, kwargs=parameter_model
3981
4076
  )
3982
4077
  self._api_client._verify_response(return_value)
3983
4078
  return return_value
@@ -4051,8 +4146,14 @@ class Models(_common.BaseModule):
4051
4146
  if query_params:
4052
4147
  path = f'{path}?{urlencode(query_params)}'
4053
4148
  # TODO: remove the hack that pops config.
4054
- config = request_dict.pop('config', None)
4055
- http_options = config.pop('httpOptions', None) if config else None
4149
+ request_dict.pop('config', None)
4150
+
4151
+ http_options = None
4152
+ if isinstance(config, dict):
4153
+ http_options = config.get('http_options', None)
4154
+ elif hasattr(config, 'http_options'):
4155
+ http_options = config.http_options
4156
+
4056
4157
  request_dict = _common.convert_to_dict(request_dict)
4057
4158
  request_dict = _common.encode_unserializable_types(request_dict)
4058
4159
 
@@ -4070,7 +4171,7 @@ class Models(_common.BaseModule):
4070
4171
  )
4071
4172
 
4072
4173
  return_value = types.EditImageResponse._from_response(
4073
- response_dict, parameter_model
4174
+ response=response_dict, kwargs=parameter_model
4074
4175
  )
4075
4176
  self._api_client._verify_response(return_value)
4076
4177
  return return_value
@@ -4111,8 +4212,14 @@ class Models(_common.BaseModule):
4111
4212
  if query_params:
4112
4213
  path = f'{path}?{urlencode(query_params)}'
4113
4214
  # TODO: remove the hack that pops config.
4114
- config = request_dict.pop('config', None)
4115
- http_options = config.pop('httpOptions', None) if config else None
4215
+ request_dict.pop('config', None)
4216
+
4217
+ http_options = None
4218
+ if isinstance(config, dict):
4219
+ http_options = config.get('http_options', None)
4220
+ elif hasattr(config, 'http_options'):
4221
+ http_options = config.http_options
4222
+
4116
4223
  request_dict = _common.convert_to_dict(request_dict)
4117
4224
  request_dict = _common.encode_unserializable_types(request_dict)
4118
4225
 
@@ -4130,14 +4237,17 @@ class Models(_common.BaseModule):
4130
4237
  )
4131
4238
 
4132
4239
  return_value = types.UpscaleImageResponse._from_response(
4133
- response_dict, parameter_model
4240
+ response=response_dict, kwargs=parameter_model
4134
4241
  )
4135
4242
  self._api_client._verify_response(return_value)
4136
4243
  return return_value
4137
4244
 
4138
- def get(self, *, model: str) -> types.Model:
4245
+ def get(
4246
+ self, *, model: str, config: Optional[types.GetModelConfigOrDict] = None
4247
+ ) -> types.Model:
4139
4248
  parameter_model = types._GetModelParameters(
4140
4249
  model=model,
4250
+ config=config,
4141
4251
  )
4142
4252
 
4143
4253
  if self._api_client.vertexai:
@@ -4154,8 +4264,14 @@ class Models(_common.BaseModule):
4154
4264
  if query_params:
4155
4265
  path = f'{path}?{urlencode(query_params)}'
4156
4266
  # TODO: remove the hack that pops config.
4157
- config = request_dict.pop('config', None)
4158
- http_options = config.pop('httpOptions', None) if config else None
4267
+ request_dict.pop('config', None)
4268
+
4269
+ http_options = None
4270
+ if isinstance(config, dict):
4271
+ http_options = config.get('http_options', None)
4272
+ elif hasattr(config, 'http_options'):
4273
+ http_options = config.http_options
4274
+
4159
4275
  request_dict = _common.convert_to_dict(request_dict)
4160
4276
  request_dict = _common.encode_unserializable_types(request_dict)
4161
4277
 
@@ -4168,7 +4284,9 @@ class Models(_common.BaseModule):
4168
4284
  else:
4169
4285
  response_dict = _Model_from_mldev(self._api_client, response_dict)
4170
4286
 
4171
- return_value = types.Model._from_response(response_dict, parameter_model)
4287
+ return_value = types.Model._from_response(
4288
+ response=response_dict, kwargs=parameter_model
4289
+ )
4172
4290
  self._api_client._verify_response(return_value)
4173
4291
  return return_value
4174
4292
 
@@ -4193,8 +4311,14 @@ class Models(_common.BaseModule):
4193
4311
  if query_params:
4194
4312
  path = f'{path}?{urlencode(query_params)}'
4195
4313
  # TODO: remove the hack that pops config.
4196
- config = request_dict.pop('config', None)
4197
- http_options = config.pop('httpOptions', None) if config else None
4314
+ request_dict.pop('config', None)
4315
+
4316
+ http_options = None
4317
+ if isinstance(config, dict):
4318
+ http_options = config.get('http_options', None)
4319
+ elif hasattr(config, 'http_options'):
4320
+ http_options = config.http_options
4321
+
4198
4322
  request_dict = _common.convert_to_dict(request_dict)
4199
4323
  request_dict = _common.encode_unserializable_types(request_dict)
4200
4324
 
@@ -4212,7 +4336,7 @@ class Models(_common.BaseModule):
4212
4336
  )
4213
4337
 
4214
4338
  return_value = types.ListModelsResponse._from_response(
4215
- response_dict, parameter_model
4339
+ response=response_dict, kwargs=parameter_model
4216
4340
  )
4217
4341
  self._api_client._verify_response(return_value)
4218
4342
  return return_value
@@ -4242,8 +4366,14 @@ class Models(_common.BaseModule):
4242
4366
  if query_params:
4243
4367
  path = f'{path}?{urlencode(query_params)}'
4244
4368
  # TODO: remove the hack that pops config.
4245
- config = request_dict.pop('config', None)
4246
- http_options = config.pop('httpOptions', None) if config else None
4369
+ request_dict.pop('config', None)
4370
+
4371
+ http_options = None
4372
+ if isinstance(config, dict):
4373
+ http_options = config.get('http_options', None)
4374
+ elif hasattr(config, 'http_options'):
4375
+ http_options = config.http_options
4376
+
4247
4377
  request_dict = _common.convert_to_dict(request_dict)
4248
4378
  request_dict = _common.encode_unserializable_types(request_dict)
4249
4379
 
@@ -4256,13 +4386,21 @@ class Models(_common.BaseModule):
4256
4386
  else:
4257
4387
  response_dict = _Model_from_mldev(self._api_client, response_dict)
4258
4388
 
4259
- return_value = types.Model._from_response(response_dict, parameter_model)
4389
+ return_value = types.Model._from_response(
4390
+ response=response_dict, kwargs=parameter_model
4391
+ )
4260
4392
  self._api_client._verify_response(return_value)
4261
4393
  return return_value
4262
4394
 
4263
- def delete(self, *, model: str) -> types.DeleteModelResponse:
4395
+ def delete(
4396
+ self,
4397
+ *,
4398
+ model: str,
4399
+ config: Optional[types.DeleteModelConfigOrDict] = None,
4400
+ ) -> types.DeleteModelResponse:
4264
4401
  parameter_model = types._DeleteModelParameters(
4265
4402
  model=model,
4403
+ config=config,
4266
4404
  )
4267
4405
 
4268
4406
  if self._api_client.vertexai:
@@ -4279,8 +4417,14 @@ class Models(_common.BaseModule):
4279
4417
  if query_params:
4280
4418
  path = f'{path}?{urlencode(query_params)}'
4281
4419
  # TODO: remove the hack that pops config.
4282
- config = request_dict.pop('config', None)
4283
- http_options = config.pop('httpOptions', None) if config else None
4420
+ request_dict.pop('config', None)
4421
+
4422
+ http_options = None
4423
+ if isinstance(config, dict):
4424
+ http_options = config.get('http_options', None)
4425
+ elif hasattr(config, 'http_options'):
4426
+ http_options = config.http_options
4427
+
4284
4428
  request_dict = _common.convert_to_dict(request_dict)
4285
4429
  request_dict = _common.encode_unserializable_types(request_dict)
4286
4430
 
@@ -4298,7 +4442,7 @@ class Models(_common.BaseModule):
4298
4442
  )
4299
4443
 
4300
4444
  return_value = types.DeleteModelResponse._from_response(
4301
- response_dict, parameter_model
4445
+ response=response_dict, kwargs=parameter_model
4302
4446
  )
4303
4447
  self._api_client._verify_response(return_value)
4304
4448
  return return_value
@@ -4350,8 +4494,14 @@ class Models(_common.BaseModule):
4350
4494
  if query_params:
4351
4495
  path = f'{path}?{urlencode(query_params)}'
4352
4496
  # TODO: remove the hack that pops config.
4353
- config = request_dict.pop('config', None)
4354
- http_options = config.pop('httpOptions', None) if config else None
4497
+ request_dict.pop('config', None)
4498
+
4499
+ http_options = None
4500
+ if isinstance(config, dict):
4501
+ http_options = config.get('http_options', None)
4502
+ elif hasattr(config, 'http_options'):
4503
+ http_options = config.http_options
4504
+
4355
4505
  request_dict = _common.convert_to_dict(request_dict)
4356
4506
  request_dict = _common.encode_unserializable_types(request_dict)
4357
4507
 
@@ -4369,7 +4519,7 @@ class Models(_common.BaseModule):
4369
4519
  )
4370
4520
 
4371
4521
  return_value = types.CountTokensResponse._from_response(
4372
- response_dict, parameter_model
4522
+ response=response_dict, kwargs=parameter_model
4373
4523
  )
4374
4524
  self._api_client._verify_response(return_value)
4375
4525
  return return_value
@@ -4421,8 +4571,14 @@ class Models(_common.BaseModule):
4421
4571
  if query_params:
4422
4572
  path = f'{path}?{urlencode(query_params)}'
4423
4573
  # TODO: remove the hack that pops config.
4424
- config = request_dict.pop('config', None)
4425
- http_options = config.pop('httpOptions', None) if config else None
4574
+ request_dict.pop('config', None)
4575
+
4576
+ http_options = None
4577
+ if isinstance(config, dict):
4578
+ http_options = config.get('http_options', None)
4579
+ elif hasattr(config, 'http_options'):
4580
+ http_options = config.http_options
4581
+
4426
4582
  request_dict = _common.convert_to_dict(request_dict)
4427
4583
  request_dict = _common.encode_unserializable_types(request_dict)
4428
4584
 
@@ -4440,7 +4596,7 @@ class Models(_common.BaseModule):
4440
4596
  )
4441
4597
 
4442
4598
  return_value = types.ComputeTokensResponse._from_response(
4443
- response_dict, parameter_model
4599
+ response=response_dict, kwargs=parameter_model
4444
4600
  )
4445
4601
  self._api_client._verify_response(return_value)
4446
4602
  return return_value
@@ -4454,6 +4610,24 @@ class Models(_common.BaseModule):
4454
4610
  ) -> types.GenerateContentResponse:
4455
4611
  """Makes an API request to generate content using a model.
4456
4612
 
4613
+ For the `model` parameter, supported format for Vertex AI API includes:
4614
+ - the Gemini model ID, for example: 'gemini-1.5-flash-002'
4615
+ - the full resource name starts with 'projects/', for example:
4616
+ 'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-1.5-flash-002'
4617
+ - the partial resource name with 'publishers/', for example:
4618
+ 'publishers/google/models/gemini-1.5-flash-002' or
4619
+ 'publishers/meta/models/llama-3.1-405b-instruct-maas'
4620
+ - `/` separated publisher and model name, for example:
4621
+ 'google/gemini-1.5-flash-002' or 'meta/llama-3.1-405b-instruct-maas'
4622
+
4623
+ For the `model` parameter, supported format for Gemini API includes:
4624
+ - the Gemini model ID, for example: 'gemini-1.5-flash-002'
4625
+ - the model name starts with 'models/', for example:
4626
+ 'models/gemini-1.5-flash-002'
4627
+ - if you would like to use a tuned model, the model name starts with
4628
+ 'tunedModels/', for example:
4629
+ 'tunedModels/1234567890123456789'
4630
+
4457
4631
  Some models support multimodal input and output.
4458
4632
 
4459
4633
  Usage:
@@ -4626,13 +4800,7 @@ class Models(_common.BaseModule):
4626
4800
  )
4627
4801
  if self._api_client.vertexai:
4628
4802
  config = config.copy()
4629
- if config.query_base:
4630
- http_options = (
4631
- config.http_options if config.http_options else HttpOptionsDict()
4632
- )
4633
- http_options['skip_project_and_location_in_path'] = True
4634
- config.http_options = http_options
4635
- else:
4803
+ if not config.query_base:
4636
4804
  # Filter for tuning jobs artifacts by labels.
4637
4805
  filter_value = config.filter
4638
4806
  config.filter = (
@@ -4650,7 +4818,7 @@ class Models(_common.BaseModule):
4650
4818
  )
4651
4819
 
4652
4820
 
4653
- class AsyncModels(_common.BaseModule):
4821
+ class AsyncModels(_api_module.BaseModule):
4654
4822
 
4655
4823
  async def _generate_content(
4656
4824
  self,
@@ -4679,8 +4847,14 @@ class AsyncModels(_common.BaseModule):
4679
4847
  if query_params:
4680
4848
  path = f'{path}?{urlencode(query_params)}'
4681
4849
  # TODO: remove the hack that pops config.
4682
- config = request_dict.pop('config', None)
4683
- http_options = config.pop('httpOptions', None) if config else None
4850
+ request_dict.pop('config', None)
4851
+
4852
+ http_options = None
4853
+ if isinstance(config, dict):
4854
+ http_options = config.get('http_options', None)
4855
+ elif hasattr(config, 'http_options'):
4856
+ http_options = config.http_options
4857
+
4684
4858
  request_dict = _common.convert_to_dict(request_dict)
4685
4859
  request_dict = _common.encode_unserializable_types(request_dict)
4686
4860
 
@@ -4698,7 +4872,7 @@ class AsyncModels(_common.BaseModule):
4698
4872
  )
4699
4873
 
4700
4874
  return_value = types.GenerateContentResponse._from_response(
4701
- response_dict, parameter_model
4875
+ response=response_dict, kwargs=parameter_model
4702
4876
  )
4703
4877
  self._api_client._verify_response(return_value)
4704
4878
  return return_value
@@ -4709,7 +4883,7 @@ class AsyncModels(_common.BaseModule):
4709
4883
  model: str,
4710
4884
  contents: Union[types.ContentListUnion, types.ContentListUnionDict],
4711
4885
  config: Optional[types.GenerateContentConfigOrDict] = None,
4712
- ) -> AsyncIterator[types.GenerateContentResponse]:
4886
+ ) -> Awaitable[AsyncIterator[types.GenerateContentResponse]]:
4713
4887
  parameter_model = types._GenerateContentParameters(
4714
4888
  model=model,
4715
4889
  contents=contents,
@@ -4734,29 +4908,40 @@ class AsyncModels(_common.BaseModule):
4734
4908
  if query_params:
4735
4909
  path = f'{path}?{urlencode(query_params)}'
4736
4910
  # TODO: remove the hack that pops config.
4737
- config = request_dict.pop('config', None)
4738
- http_options = config.pop('httpOptions', None) if config else None
4911
+ request_dict.pop('config', None)
4912
+
4913
+ http_options = None
4914
+ if isinstance(config, dict):
4915
+ http_options = config.get('http_options', None)
4916
+ elif hasattr(config, 'http_options'):
4917
+ http_options = config.http_options
4918
+
4739
4919
  request_dict = _common.convert_to_dict(request_dict)
4740
4920
  request_dict = _common.encode_unserializable_types(request_dict)
4741
4921
 
4742
- async for response_dict in self._api_client.async_request_streamed(
4922
+ response_stream = await self._api_client.async_request_streamed(
4743
4923
  'post', path, request_dict, http_options
4744
- ):
4924
+ )
4745
4925
 
4746
- if self._api_client.vertexai:
4747
- response_dict = _GenerateContentResponse_from_vertex(
4748
- self._api_client, response_dict
4749
- )
4750
- else:
4751
- response_dict = _GenerateContentResponse_from_mldev(
4752
- self._api_client, response_dict
4926
+ async def async_generator():
4927
+ async for response_dict in response_stream:
4928
+
4929
+ if self._api_client.vertexai:
4930
+ response_dict = _GenerateContentResponse_from_vertex(
4931
+ self._api_client, response_dict
4932
+ )
4933
+ else:
4934
+ response_dict = _GenerateContentResponse_from_mldev(
4935
+ self._api_client, response_dict
4936
+ )
4937
+
4938
+ return_value = types.GenerateContentResponse._from_response(
4939
+ response=response_dict, kwargs=parameter_model
4753
4940
  )
4941
+ self._api_client._verify_response(return_value)
4942
+ yield return_value
4754
4943
 
4755
- return_value = types.GenerateContentResponse._from_response(
4756
- response_dict, parameter_model
4757
- )
4758
- self._api_client._verify_response(return_value)
4759
- yield return_value
4944
+ return async_generator()
4760
4945
 
4761
4946
  async def embed_content(
4762
4947
  self,
@@ -4808,8 +4993,14 @@ class AsyncModels(_common.BaseModule):
4808
4993
  if query_params:
4809
4994
  path = f'{path}?{urlencode(query_params)}'
4810
4995
  # TODO: remove the hack that pops config.
4811
- config = request_dict.pop('config', None)
4812
- http_options = config.pop('httpOptions', None) if config else None
4996
+ request_dict.pop('config', None)
4997
+
4998
+ http_options = None
4999
+ if isinstance(config, dict):
5000
+ http_options = config.get('http_options', None)
5001
+ elif hasattr(config, 'http_options'):
5002
+ http_options = config.http_options
5003
+
4813
5004
  request_dict = _common.convert_to_dict(request_dict)
4814
5005
  request_dict = _common.encode_unserializable_types(request_dict)
4815
5006
 
@@ -4827,33 +5018,33 @@ class AsyncModels(_common.BaseModule):
4827
5018
  )
4828
5019
 
4829
5020
  return_value = types.EmbedContentResponse._from_response(
4830
- response_dict, parameter_model
5021
+ response=response_dict, kwargs=parameter_model
4831
5022
  )
4832
5023
  self._api_client._verify_response(return_value)
4833
5024
  return return_value
4834
5025
 
4835
- async def generate_image(
5026
+ async def generate_images(
4836
5027
  self,
4837
5028
  *,
4838
5029
  model: str,
4839
5030
  prompt: str,
4840
- config: Optional[types.GenerateImageConfigOrDict] = None,
4841
- ) -> types.GenerateImageResponse:
4842
- """Generates an image based on a text description and configuration.
5031
+ config: Optional[types.GenerateImagesConfigOrDict] = None,
5032
+ ) -> types.GenerateImagesResponse:
5033
+ """Generates images based on a text description and configuration.
4843
5034
 
4844
5035
  Args:
4845
5036
  model (str): The model to use.
4846
- prompt (str): A text description of the image to generate.
4847
- config (GenerateImageConfig): Configuration for generation.
5037
+ prompt (str): A text description of the images to generate.
5038
+ config (GenerateImagesConfig): Configuration for generation.
4848
5039
 
4849
5040
  Usage:
4850
5041
 
4851
5042
  .. code-block:: python
4852
5043
 
4853
- response = client.models.generate_image(
5044
+ response = client.models.generate_images(
4854
5045
  model='imagen-3.0-generate-001',
4855
5046
  prompt='Man with a dog',
4856
- config=types.GenerateImageConfig(
5047
+ config=types.GenerateImagesConfig(
4857
5048
  number_of_images= 1,
4858
5049
  include_rai_reason= True,
4859
5050
  )
@@ -4862,19 +5053,19 @@ class AsyncModels(_common.BaseModule):
4862
5053
  # Shows a man with a dog.
4863
5054
  """
4864
5055
 
4865
- parameter_model = types._GenerateImageParameters(
5056
+ parameter_model = types._GenerateImagesParameters(
4866
5057
  model=model,
4867
5058
  prompt=prompt,
4868
5059
  config=config,
4869
5060
  )
4870
5061
 
4871
5062
  if self._api_client.vertexai:
4872
- request_dict = _GenerateImageParameters_to_vertex(
5063
+ request_dict = _GenerateImagesParameters_to_vertex(
4873
5064
  self._api_client, parameter_model
4874
5065
  )
4875
5066
  path = '{model}:predict'.format_map(request_dict.get('_url'))
4876
5067
  else:
4877
- request_dict = _GenerateImageParameters_to_mldev(
5068
+ request_dict = _GenerateImagesParameters_to_mldev(
4878
5069
  self._api_client, parameter_model
4879
5070
  )
4880
5071
  path = '{model}:predict'.format_map(request_dict.get('_url'))
@@ -4882,8 +5073,14 @@ class AsyncModels(_common.BaseModule):
4882
5073
  if query_params:
4883
5074
  path = f'{path}?{urlencode(query_params)}'
4884
5075
  # TODO: remove the hack that pops config.
4885
- config = request_dict.pop('config', None)
4886
- http_options = config.pop('httpOptions', None) if config else None
5076
+ request_dict.pop('config', None)
5077
+
5078
+ http_options = None
5079
+ if isinstance(config, dict):
5080
+ http_options = config.get('http_options', None)
5081
+ elif hasattr(config, 'http_options'):
5082
+ http_options = config.http_options
5083
+
4887
5084
  request_dict = _common.convert_to_dict(request_dict)
4888
5085
  request_dict = _common.encode_unserializable_types(request_dict)
4889
5086
 
@@ -4892,16 +5089,16 @@ class AsyncModels(_common.BaseModule):
4892
5089
  )
4893
5090
 
4894
5091
  if self._api_client.vertexai:
4895
- response_dict = _GenerateImageResponse_from_vertex(
5092
+ response_dict = _GenerateImagesResponse_from_vertex(
4896
5093
  self._api_client, response_dict
4897
5094
  )
4898
5095
  else:
4899
- response_dict = _GenerateImageResponse_from_mldev(
5096
+ response_dict = _GenerateImagesResponse_from_mldev(
4900
5097
  self._api_client, response_dict
4901
5098
  )
4902
5099
 
4903
- return_value = types.GenerateImageResponse._from_response(
4904
- response_dict, parameter_model
5100
+ return_value = types.GenerateImagesResponse._from_response(
5101
+ response=response_dict, kwargs=parameter_model
4905
5102
  )
4906
5103
  self._api_client._verify_response(return_value)
4907
5104
  return return_value
@@ -4975,8 +5172,14 @@ class AsyncModels(_common.BaseModule):
4975
5172
  if query_params:
4976
5173
  path = f'{path}?{urlencode(query_params)}'
4977
5174
  # TODO: remove the hack that pops config.
4978
- config = request_dict.pop('config', None)
4979
- http_options = config.pop('httpOptions', None) if config else None
5175
+ request_dict.pop('config', None)
5176
+
5177
+ http_options = None
5178
+ if isinstance(config, dict):
5179
+ http_options = config.get('http_options', None)
5180
+ elif hasattr(config, 'http_options'):
5181
+ http_options = config.http_options
5182
+
4980
5183
  request_dict = _common.convert_to_dict(request_dict)
4981
5184
  request_dict = _common.encode_unserializable_types(request_dict)
4982
5185
 
@@ -4994,7 +5197,7 @@ class AsyncModels(_common.BaseModule):
4994
5197
  )
4995
5198
 
4996
5199
  return_value = types.EditImageResponse._from_response(
4997
- response_dict, parameter_model
5200
+ response=response_dict, kwargs=parameter_model
4998
5201
  )
4999
5202
  self._api_client._verify_response(return_value)
5000
5203
  return return_value
@@ -5035,8 +5238,14 @@ class AsyncModels(_common.BaseModule):
5035
5238
  if query_params:
5036
5239
  path = f'{path}?{urlencode(query_params)}'
5037
5240
  # TODO: remove the hack that pops config.
5038
- config = request_dict.pop('config', None)
5039
- http_options = config.pop('httpOptions', None) if config else None
5241
+ request_dict.pop('config', None)
5242
+
5243
+ http_options = None
5244
+ if isinstance(config, dict):
5245
+ http_options = config.get('http_options', None)
5246
+ elif hasattr(config, 'http_options'):
5247
+ http_options = config.http_options
5248
+
5040
5249
  request_dict = _common.convert_to_dict(request_dict)
5041
5250
  request_dict = _common.encode_unserializable_types(request_dict)
5042
5251
 
@@ -5054,14 +5263,17 @@ class AsyncModels(_common.BaseModule):
5054
5263
  )
5055
5264
 
5056
5265
  return_value = types.UpscaleImageResponse._from_response(
5057
- response_dict, parameter_model
5266
+ response=response_dict, kwargs=parameter_model
5058
5267
  )
5059
5268
  self._api_client._verify_response(return_value)
5060
5269
  return return_value
5061
5270
 
5062
- async def get(self, *, model: str) -> types.Model:
5271
+ async def get(
5272
+ self, *, model: str, config: Optional[types.GetModelConfigOrDict] = None
5273
+ ) -> types.Model:
5063
5274
  parameter_model = types._GetModelParameters(
5064
5275
  model=model,
5276
+ config=config,
5065
5277
  )
5066
5278
 
5067
5279
  if self._api_client.vertexai:
@@ -5078,8 +5290,14 @@ class AsyncModels(_common.BaseModule):
5078
5290
  if query_params:
5079
5291
  path = f'{path}?{urlencode(query_params)}'
5080
5292
  # TODO: remove the hack that pops config.
5081
- config = request_dict.pop('config', None)
5082
- http_options = config.pop('httpOptions', None) if config else None
5293
+ request_dict.pop('config', None)
5294
+
5295
+ http_options = None
5296
+ if isinstance(config, dict):
5297
+ http_options = config.get('http_options', None)
5298
+ elif hasattr(config, 'http_options'):
5299
+ http_options = config.http_options
5300
+
5083
5301
  request_dict = _common.convert_to_dict(request_dict)
5084
5302
  request_dict = _common.encode_unserializable_types(request_dict)
5085
5303
 
@@ -5092,7 +5310,9 @@ class AsyncModels(_common.BaseModule):
5092
5310
  else:
5093
5311
  response_dict = _Model_from_mldev(self._api_client, response_dict)
5094
5312
 
5095
- return_value = types.Model._from_response(response_dict, parameter_model)
5313
+ return_value = types.Model._from_response(
5314
+ response=response_dict, kwargs=parameter_model
5315
+ )
5096
5316
  self._api_client._verify_response(return_value)
5097
5317
  return return_value
5098
5318
 
@@ -5117,8 +5337,14 @@ class AsyncModels(_common.BaseModule):
5117
5337
  if query_params:
5118
5338
  path = f'{path}?{urlencode(query_params)}'
5119
5339
  # TODO: remove the hack that pops config.
5120
- config = request_dict.pop('config', None)
5121
- http_options = config.pop('httpOptions', None) if config else None
5340
+ request_dict.pop('config', None)
5341
+
5342
+ http_options = None
5343
+ if isinstance(config, dict):
5344
+ http_options = config.get('http_options', None)
5345
+ elif hasattr(config, 'http_options'):
5346
+ http_options = config.http_options
5347
+
5122
5348
  request_dict = _common.convert_to_dict(request_dict)
5123
5349
  request_dict = _common.encode_unserializable_types(request_dict)
5124
5350
 
@@ -5136,7 +5362,7 @@ class AsyncModels(_common.BaseModule):
5136
5362
  )
5137
5363
 
5138
5364
  return_value = types.ListModelsResponse._from_response(
5139
- response_dict, parameter_model
5365
+ response=response_dict, kwargs=parameter_model
5140
5366
  )
5141
5367
  self._api_client._verify_response(return_value)
5142
5368
  return return_value
@@ -5166,8 +5392,14 @@ class AsyncModels(_common.BaseModule):
5166
5392
  if query_params:
5167
5393
  path = f'{path}?{urlencode(query_params)}'
5168
5394
  # TODO: remove the hack that pops config.
5169
- config = request_dict.pop('config', None)
5170
- http_options = config.pop('httpOptions', None) if config else None
5395
+ request_dict.pop('config', None)
5396
+
5397
+ http_options = None
5398
+ if isinstance(config, dict):
5399
+ http_options = config.get('http_options', None)
5400
+ elif hasattr(config, 'http_options'):
5401
+ http_options = config.http_options
5402
+
5171
5403
  request_dict = _common.convert_to_dict(request_dict)
5172
5404
  request_dict = _common.encode_unserializable_types(request_dict)
5173
5405
 
@@ -5180,13 +5412,21 @@ class AsyncModels(_common.BaseModule):
5180
5412
  else:
5181
5413
  response_dict = _Model_from_mldev(self._api_client, response_dict)
5182
5414
 
5183
- return_value = types.Model._from_response(response_dict, parameter_model)
5415
+ return_value = types.Model._from_response(
5416
+ response=response_dict, kwargs=parameter_model
5417
+ )
5184
5418
  self._api_client._verify_response(return_value)
5185
5419
  return return_value
5186
5420
 
5187
- async def delete(self, *, model: str) -> types.DeleteModelResponse:
5421
+ async def delete(
5422
+ self,
5423
+ *,
5424
+ model: str,
5425
+ config: Optional[types.DeleteModelConfigOrDict] = None,
5426
+ ) -> types.DeleteModelResponse:
5188
5427
  parameter_model = types._DeleteModelParameters(
5189
5428
  model=model,
5429
+ config=config,
5190
5430
  )
5191
5431
 
5192
5432
  if self._api_client.vertexai:
@@ -5203,8 +5443,14 @@ class AsyncModels(_common.BaseModule):
5203
5443
  if query_params:
5204
5444
  path = f'{path}?{urlencode(query_params)}'
5205
5445
  # TODO: remove the hack that pops config.
5206
- config = request_dict.pop('config', None)
5207
- http_options = config.pop('httpOptions', None) if config else None
5446
+ request_dict.pop('config', None)
5447
+
5448
+ http_options = None
5449
+ if isinstance(config, dict):
5450
+ http_options = config.get('http_options', None)
5451
+ elif hasattr(config, 'http_options'):
5452
+ http_options = config.http_options
5453
+
5208
5454
  request_dict = _common.convert_to_dict(request_dict)
5209
5455
  request_dict = _common.encode_unserializable_types(request_dict)
5210
5456
 
@@ -5222,7 +5468,7 @@ class AsyncModels(_common.BaseModule):
5222
5468
  )
5223
5469
 
5224
5470
  return_value = types.DeleteModelResponse._from_response(
5225
- response_dict, parameter_model
5471
+ response=response_dict, kwargs=parameter_model
5226
5472
  )
5227
5473
  self._api_client._verify_response(return_value)
5228
5474
  return return_value
@@ -5274,8 +5520,14 @@ class AsyncModels(_common.BaseModule):
5274
5520
  if query_params:
5275
5521
  path = f'{path}?{urlencode(query_params)}'
5276
5522
  # TODO: remove the hack that pops config.
5277
- config = request_dict.pop('config', None)
5278
- http_options = config.pop('httpOptions', None) if config else None
5523
+ request_dict.pop('config', None)
5524
+
5525
+ http_options = None
5526
+ if isinstance(config, dict):
5527
+ http_options = config.get('http_options', None)
5528
+ elif hasattr(config, 'http_options'):
5529
+ http_options = config.http_options
5530
+
5279
5531
  request_dict = _common.convert_to_dict(request_dict)
5280
5532
  request_dict = _common.encode_unserializable_types(request_dict)
5281
5533
 
@@ -5293,7 +5545,7 @@ class AsyncModels(_common.BaseModule):
5293
5545
  )
5294
5546
 
5295
5547
  return_value = types.CountTokensResponse._from_response(
5296
- response_dict, parameter_model
5548
+ response=response_dict, kwargs=parameter_model
5297
5549
  )
5298
5550
  self._api_client._verify_response(return_value)
5299
5551
  return return_value
@@ -5345,8 +5597,14 @@ class AsyncModels(_common.BaseModule):
5345
5597
  if query_params:
5346
5598
  path = f'{path}?{urlencode(query_params)}'
5347
5599
  # TODO: remove the hack that pops config.
5348
- config = request_dict.pop('config', None)
5349
- http_options = config.pop('httpOptions', None) if config else None
5600
+ request_dict.pop('config', None)
5601
+
5602
+ http_options = None
5603
+ if isinstance(config, dict):
5604
+ http_options = config.get('http_options', None)
5605
+ elif hasattr(config, 'http_options'):
5606
+ http_options = config.http_options
5607
+
5350
5608
  request_dict = _common.convert_to_dict(request_dict)
5351
5609
  request_dict = _common.encode_unserializable_types(request_dict)
5352
5610
 
@@ -5364,7 +5622,7 @@ class AsyncModels(_common.BaseModule):
5364
5622
  )
5365
5623
 
5366
5624
  return_value = types.ComputeTokensResponse._from_response(
5367
- response_dict, parameter_model
5625
+ response=response_dict, kwargs=parameter_model
5368
5626
  )
5369
5627
  self._api_client._verify_response(return_value)
5370
5628
  return return_value
@@ -5487,13 +5745,7 @@ class AsyncModels(_common.BaseModule):
5487
5745
  )
5488
5746
  if self._api_client.vertexai:
5489
5747
  config = config.copy()
5490
- if config.query_base:
5491
- http_options = (
5492
- config.http_options if config.http_options else HttpOptionsDict()
5493
- )
5494
- http_options['skip_project_and_location_in_path'] = True
5495
- config.http_options = http_options
5496
- else:
5748
+ if not config.query_base:
5497
5749
  # Filter for tuning jobs artifacts by labels.
5498
5750
  filter_value = config.filter
5499
5751
  config.filter = (