orq-ai-sdk 4.2.0rc28__py3-none-any.whl → 4.2.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. orq_ai_sdk/_hooks/globalhook.py +0 -1
  2. orq_ai_sdk/_version.py +3 -3
  3. orq_ai_sdk/audio.py +30 -0
  4. orq_ai_sdk/basesdk.py +20 -6
  5. orq_ai_sdk/chat.py +22 -0
  6. orq_ai_sdk/completions.py +332 -0
  7. orq_ai_sdk/contacts.py +43 -855
  8. orq_ai_sdk/deployments.py +61 -0
  9. orq_ai_sdk/edits.py +258 -0
  10. orq_ai_sdk/embeddings.py +238 -0
  11. orq_ai_sdk/generations.py +272 -0
  12. orq_ai_sdk/identities.py +1037 -0
  13. orq_ai_sdk/images.py +28 -0
  14. orq_ai_sdk/models/__init__.py +5341 -737
  15. orq_ai_sdk/models/actionreviewedstreamingevent.py +18 -1
  16. orq_ai_sdk/models/actionreviewrequestedstreamingevent.py +44 -1
  17. orq_ai_sdk/models/agenterroredstreamingevent.py +18 -1
  18. orq_ai_sdk/models/agentinactivestreamingevent.py +168 -70
  19. orq_ai_sdk/models/agentmessagecreatedstreamingevent.py +18 -2
  20. orq_ai_sdk/models/agentresponsemessage.py +18 -2
  21. orq_ai_sdk/models/agentstartedstreamingevent.py +127 -2
  22. orq_ai_sdk/models/agentthoughtstreamingevent.py +178 -211
  23. orq_ai_sdk/models/conversationresponse.py +31 -20
  24. orq_ai_sdk/models/conversationwithmessagesresponse.py +31 -20
  25. orq_ai_sdk/models/createagentrequestop.py +1922 -384
  26. orq_ai_sdk/models/createagentresponse.py +147 -91
  27. orq_ai_sdk/models/createagentresponserequestop.py +111 -2
  28. orq_ai_sdk/models/createchatcompletionop.py +1375 -861
  29. orq_ai_sdk/models/createchunkop.py +46 -19
  30. orq_ai_sdk/models/createcompletionop.py +1890 -0
  31. orq_ai_sdk/models/createcontactop.py +45 -56
  32. orq_ai_sdk/models/createconversationop.py +61 -39
  33. orq_ai_sdk/models/createconversationresponseop.py +68 -4
  34. orq_ai_sdk/models/createdatasetitemop.py +424 -80
  35. orq_ai_sdk/models/createdatasetop.py +19 -2
  36. orq_ai_sdk/models/createdatasourceop.py +92 -26
  37. orq_ai_sdk/models/createembeddingop.py +384 -0
  38. orq_ai_sdk/models/createevalop.py +552 -24
  39. orq_ai_sdk/models/createidentityop.py +176 -0
  40. orq_ai_sdk/models/createimageeditop.py +504 -0
  41. orq_ai_sdk/models/createimageop.py +208 -117
  42. orq_ai_sdk/models/createimagevariationop.py +486 -0
  43. orq_ai_sdk/models/createknowledgeop.py +186 -121
  44. orq_ai_sdk/models/creatememorydocumentop.py +50 -1
  45. orq_ai_sdk/models/creatememoryop.py +34 -21
  46. orq_ai_sdk/models/creatememorystoreop.py +34 -1
  47. orq_ai_sdk/models/createmoderationop.py +521 -0
  48. orq_ai_sdk/models/createpromptop.py +2748 -1252
  49. orq_ai_sdk/models/creatererankop.py +416 -0
  50. orq_ai_sdk/models/createresponseop.py +2567 -0
  51. orq_ai_sdk/models/createspeechop.py +316 -0
  52. orq_ai_sdk/models/createtoolop.py +537 -12
  53. orq_ai_sdk/models/createtranscriptionop.py +562 -0
  54. orq_ai_sdk/models/createtranslationop.py +540 -0
  55. orq_ai_sdk/models/datapart.py +18 -1
  56. orq_ai_sdk/models/deletechunksop.py +34 -1
  57. orq_ai_sdk/models/{deletecontactop.py → deleteidentityop.py} +9 -9
  58. orq_ai_sdk/models/deletepromptop.py +26 -0
  59. orq_ai_sdk/models/deploymentcreatemetricop.py +362 -76
  60. orq_ai_sdk/models/deploymentgetconfigop.py +635 -194
  61. orq_ai_sdk/models/deploymentinvokeop.py +168 -173
  62. orq_ai_sdk/models/deploymentsop.py +195 -58
  63. orq_ai_sdk/models/deploymentstreamop.py +652 -304
  64. orq_ai_sdk/models/errorpart.py +18 -1
  65. orq_ai_sdk/models/filecontentpartschema.py +18 -1
  66. orq_ai_sdk/models/filegetop.py +19 -2
  67. orq_ai_sdk/models/filelistop.py +35 -2
  68. orq_ai_sdk/models/filepart.py +50 -1
  69. orq_ai_sdk/models/fileuploadop.py +51 -2
  70. orq_ai_sdk/models/generateconversationnameop.py +31 -20
  71. orq_ai_sdk/models/get_v2_evaluators_id_versionsop.py +34 -1
  72. orq_ai_sdk/models/get_v2_tools_tool_id_versions_version_id_op.py +18 -1
  73. orq_ai_sdk/models/get_v2_tools_tool_id_versionsop.py +34 -1
  74. orq_ai_sdk/models/getallmemoriesop.py +34 -21
  75. orq_ai_sdk/models/getallmemorydocumentsop.py +42 -1
  76. orq_ai_sdk/models/getallmemorystoresop.py +34 -1
  77. orq_ai_sdk/models/getallpromptsop.py +1690 -230
  78. orq_ai_sdk/models/getalltoolsop.py +325 -8
  79. orq_ai_sdk/models/getchunkscountop.py +34 -1
  80. orq_ai_sdk/models/getevalsop.py +395 -43
  81. orq_ai_sdk/models/getonechunkop.py +14 -19
  82. orq_ai_sdk/models/getoneknowledgeop.py +116 -96
  83. orq_ai_sdk/models/getonepromptop.py +1673 -230
  84. orq_ai_sdk/models/getpromptversionop.py +1670 -216
  85. orq_ai_sdk/models/imagecontentpartschema.py +50 -1
  86. orq_ai_sdk/models/internal/globals.py +18 -1
  87. orq_ai_sdk/models/invokeagentop.py +140 -2
  88. orq_ai_sdk/models/invokedeploymentrequest.py +418 -80
  89. orq_ai_sdk/models/invokeevalop.py +160 -131
  90. orq_ai_sdk/models/listagentsop.py +793 -166
  91. orq_ai_sdk/models/listchunksop.py +32 -19
  92. orq_ai_sdk/models/listchunkspaginatedop.py +46 -19
  93. orq_ai_sdk/models/listconversationsop.py +18 -1
  94. orq_ai_sdk/models/listdatasetdatapointsop.py +252 -42
  95. orq_ai_sdk/models/listdatasetsop.py +35 -2
  96. orq_ai_sdk/models/listdatasourcesop.py +35 -26
  97. orq_ai_sdk/models/{listcontactsop.py → listidentitiesop.py} +89 -79
  98. orq_ai_sdk/models/listknowledgebasesop.py +132 -96
  99. orq_ai_sdk/models/listmodelsop.py +1 -0
  100. orq_ai_sdk/models/listpromptversionsop.py +1684 -216
  101. orq_ai_sdk/models/parseop.py +161 -17
  102. orq_ai_sdk/models/partdoneevent.py +19 -2
  103. orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
  104. orq_ai_sdk/models/publiccontact.py +27 -4
  105. orq_ai_sdk/models/publicidentity.py +62 -0
  106. orq_ai_sdk/models/reasoningpart.py +19 -2
  107. orq_ai_sdk/models/refusalpartschema.py +18 -1
  108. orq_ai_sdk/models/remoteconfigsgetconfigop.py +34 -1
  109. orq_ai_sdk/models/responsedoneevent.py +114 -84
  110. orq_ai_sdk/models/responsestartedevent.py +18 -1
  111. orq_ai_sdk/models/retrieveagentrequestop.py +787 -166
  112. orq_ai_sdk/models/retrievedatapointop.py +236 -42
  113. orq_ai_sdk/models/retrievedatasetop.py +19 -2
  114. orq_ai_sdk/models/retrievedatasourceop.py +17 -26
  115. orq_ai_sdk/models/{retrievecontactop.py → retrieveidentityop.py} +38 -41
  116. orq_ai_sdk/models/retrievememorydocumentop.py +18 -1
  117. orq_ai_sdk/models/retrievememoryop.py +18 -21
  118. orq_ai_sdk/models/retrievememorystoreop.py +18 -1
  119. orq_ai_sdk/models/retrievetoolop.py +309 -8
  120. orq_ai_sdk/models/runagentop.py +1451 -197
  121. orq_ai_sdk/models/searchknowledgeop.py +108 -1
  122. orq_ai_sdk/models/security.py +18 -1
  123. orq_ai_sdk/models/streamagentop.py +93 -2
  124. orq_ai_sdk/models/streamrunagentop.py +1428 -195
  125. orq_ai_sdk/models/textcontentpartschema.py +34 -1
  126. orq_ai_sdk/models/thinkingconfigenabledschema.py +18 -1
  127. orq_ai_sdk/models/toolcallpart.py +18 -1
  128. orq_ai_sdk/models/tooldoneevent.py +18 -1
  129. orq_ai_sdk/models/toolexecutionfailedstreamingevent.py +50 -1
  130. orq_ai_sdk/models/toolexecutionfinishedstreamingevent.py +34 -1
  131. orq_ai_sdk/models/toolexecutionstartedstreamingevent.py +34 -1
  132. orq_ai_sdk/models/toolresultpart.py +18 -1
  133. orq_ai_sdk/models/toolreviewrequestedevent.py +18 -1
  134. orq_ai_sdk/models/toolstartedevent.py +18 -1
  135. orq_ai_sdk/models/updateagentop.py +1951 -404
  136. orq_ai_sdk/models/updatechunkop.py +46 -19
  137. orq_ai_sdk/models/updateconversationop.py +61 -39
  138. orq_ai_sdk/models/updatedatapointop.py +424 -80
  139. orq_ai_sdk/models/updatedatasetop.py +51 -2
  140. orq_ai_sdk/models/updatedatasourceop.py +17 -26
  141. orq_ai_sdk/models/updateevalop.py +577 -16
  142. orq_ai_sdk/models/{updatecontactop.py → updateidentityop.py} +78 -68
  143. orq_ai_sdk/models/updateknowledgeop.py +234 -190
  144. orq_ai_sdk/models/updatememorydocumentop.py +50 -1
  145. orq_ai_sdk/models/updatememoryop.py +50 -21
  146. orq_ai_sdk/models/updatememorystoreop.py +66 -1
  147. orq_ai_sdk/models/updatepromptop.py +2844 -1450
  148. orq_ai_sdk/models/updatetoolop.py +592 -9
  149. orq_ai_sdk/models/usermessagerequest.py +18 -2
  150. orq_ai_sdk/moderations.py +218 -0
  151. orq_ai_sdk/orq_completions.py +660 -0
  152. orq_ai_sdk/orq_responses.py +398 -0
  153. orq_ai_sdk/prompts.py +28 -36
  154. orq_ai_sdk/rerank.py +232 -0
  155. orq_ai_sdk/router.py +89 -641
  156. orq_ai_sdk/sdk.py +3 -0
  157. orq_ai_sdk/speech.py +251 -0
  158. orq_ai_sdk/transcriptions.py +326 -0
  159. orq_ai_sdk/translations.py +298 -0
  160. orq_ai_sdk/utils/__init__.py +13 -1
  161. orq_ai_sdk/variations.py +254 -0
  162. orq_ai_sdk-4.2.6.dist-info/METADATA +888 -0
  163. orq_ai_sdk-4.2.6.dist-info/RECORD +263 -0
  164. {orq_ai_sdk-4.2.0rc28.dist-info → orq_ai_sdk-4.2.6.dist-info}/WHEEL +2 -1
  165. orq_ai_sdk-4.2.6.dist-info/top_level.txt +1 -0
  166. orq_ai_sdk-4.2.0rc28.dist-info/METADATA +0 -867
  167. orq_ai_sdk-4.2.0rc28.dist-info/RECORD +0 -233
@@ -90,6 +90,22 @@ class ResponseFormatJSONSchema(BaseModel):
90
90
  strict: Optional[bool] = False
91
91
  r"""Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true."""
92
92
 
93
+ @model_serializer(mode="wrap")
94
+ def serialize_model(self, handler):
95
+ optional_fields = set(["description", "schema", "strict"])
96
+ serialized = handler(self)
97
+ m = {}
98
+
99
+ for n, f in type(self).model_fields.items():
100
+ k = f.alias or n
101
+ val = serialized.get(k)
102
+
103
+ if val != UNSET_SENTINEL:
104
+ if val is not None or k not in optional_fields:
105
+ m[k] = val
106
+
107
+ return m
108
+
93
109
 
94
110
  class JSONSchemaTypedDict(TypedDict):
95
111
  r"""
@@ -212,6 +228,22 @@ class StreamOptions(BaseModel):
212
228
  include_usage: Optional[bool] = None
213
229
  r"""If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value."""
214
230
 
231
+ @model_serializer(mode="wrap")
232
+ def serialize_model(self, handler):
233
+ optional_fields = set(["include_usage"])
234
+ serialized = handler(self)
235
+ m = {}
236
+
237
+ for n, f in type(self).model_fields.items():
238
+ k = f.alias or n
239
+ val = serialized.get(k)
240
+
241
+ if val != UNSET_SENTINEL:
242
+ if val is not None or k not in optional_fields:
243
+ m[k] = val
244
+
245
+ return m
246
+
215
247
 
216
248
  ThinkingTypedDict = TypeAliasType(
217
249
  "ThinkingTypedDict",
@@ -254,6 +286,22 @@ class ToolChoice2(BaseModel):
254
286
  type: Optional[ToolChoiceType] = None
255
287
  r"""The type of the tool. Currently, only function is supported."""
256
288
 
289
+ @model_serializer(mode="wrap")
290
+ def serialize_model(self, handler):
291
+ optional_fields = set(["type"])
292
+ serialized = handler(self)
293
+ m = {}
294
+
295
+ for n, f in type(self).model_fields.items():
296
+ k = f.alias or n
297
+ val = serialized.get(k)
298
+
299
+ if val != UNSET_SENTINEL:
300
+ if val is not None or k not in optional_fields:
301
+ m[k] = val
302
+
303
+ return m
304
+
257
305
 
258
306
  ToolChoice1 = Literal[
259
307
  "none",
@@ -312,6 +360,154 @@ class CreateAgentRequestModelConfigurationGuardrails(BaseModel):
312
360
  r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
313
361
 
314
362
 
363
+ class FallbacksTypedDict(TypedDict):
364
+ model: str
365
+ r"""Fallback model identifier"""
366
+
367
+
368
+ class Fallbacks(BaseModel):
369
+ model: str
370
+ r"""Fallback model identifier"""
371
+
372
+
373
+ class RetryTypedDict(TypedDict):
374
+ r"""Retry configuration for the request"""
375
+
376
+ count: NotRequired[float]
377
+ r"""Number of retry attempts (1-5)"""
378
+ on_codes: NotRequired[List[float]]
379
+ r"""HTTP status codes that trigger retry logic"""
380
+
381
+
382
+ class Retry(BaseModel):
383
+ r"""Retry configuration for the request"""
384
+
385
+ count: Optional[float] = 3
386
+ r"""Number of retry attempts (1-5)"""
387
+
388
+ on_codes: Optional[List[float]] = None
389
+ r"""HTTP status codes that trigger retry logic"""
390
+
391
+ @model_serializer(mode="wrap")
392
+ def serialize_model(self, handler):
393
+ optional_fields = set(["count", "on_codes"])
394
+ serialized = handler(self)
395
+ m = {}
396
+
397
+ for n, f in type(self).model_fields.items():
398
+ k = f.alias or n
399
+ val = serialized.get(k)
400
+
401
+ if val != UNSET_SENTINEL:
402
+ if val is not None or k not in optional_fields:
403
+ m[k] = val
404
+
405
+ return m
406
+
407
+
408
+ ModelConfigurationType = Literal["exact_match",]
409
+
410
+
411
+ class CacheTypedDict(TypedDict):
412
+ r"""Cache configuration for the request."""
413
+
414
+ type: ModelConfigurationType
415
+ ttl: NotRequired[float]
416
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
417
+
418
+
419
+ class Cache(BaseModel):
420
+ r"""Cache configuration for the request."""
421
+
422
+ type: ModelConfigurationType
423
+
424
+ ttl: Optional[float] = 1800
425
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
426
+
427
+ @model_serializer(mode="wrap")
428
+ def serialize_model(self, handler):
429
+ optional_fields = set(["ttl"])
430
+ serialized = handler(self)
431
+ m = {}
432
+
433
+ for n, f in type(self).model_fields.items():
434
+ k = f.alias or n
435
+ val = serialized.get(k)
436
+
437
+ if val != UNSET_SENTINEL:
438
+ if val is not None or k not in optional_fields:
439
+ m[k] = val
440
+
441
+ return m
442
+
443
+
444
+ LoadBalancerType = Literal["weight_based",]
445
+
446
+
447
+ class CreateAgentRequestLoadBalancerModelsTypedDict(TypedDict):
448
+ model: str
449
+ r"""Model identifier for load balancing"""
450
+ weight: NotRequired[float]
451
+ r"""Weight assigned to this model for load balancing"""
452
+
453
+
454
+ class CreateAgentRequestLoadBalancerModels(BaseModel):
455
+ model: str
456
+ r"""Model identifier for load balancing"""
457
+
458
+ weight: Optional[float] = 0.5
459
+ r"""Weight assigned to this model for load balancing"""
460
+
461
+ @model_serializer(mode="wrap")
462
+ def serialize_model(self, handler):
463
+ optional_fields = set(["weight"])
464
+ serialized = handler(self)
465
+ m = {}
466
+
467
+ for n, f in type(self).model_fields.items():
468
+ k = f.alias or n
469
+ val = serialized.get(k)
470
+
471
+ if val != UNSET_SENTINEL:
472
+ if val is not None or k not in optional_fields:
473
+ m[k] = val
474
+
475
+ return m
476
+
477
+
478
+ class LoadBalancer1TypedDict(TypedDict):
479
+ type: LoadBalancerType
480
+ models: List[CreateAgentRequestLoadBalancerModelsTypedDict]
481
+
482
+
483
+ class LoadBalancer1(BaseModel):
484
+ type: LoadBalancerType
485
+
486
+ models: List[CreateAgentRequestLoadBalancerModels]
487
+
488
+
489
+ LoadBalancerTypedDict = LoadBalancer1TypedDict
490
+ r"""Load balancer configuration for the request."""
491
+
492
+
493
+ LoadBalancer = LoadBalancer1
494
+ r"""Load balancer configuration for the request."""
495
+
496
+
497
+ class TimeoutTypedDict(TypedDict):
498
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
499
+
500
+ call_timeout: float
501
+ r"""Timeout value in milliseconds"""
502
+
503
+
504
+ class Timeout(BaseModel):
505
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
506
+
507
+ call_timeout: float
508
+ r"""Timeout value in milliseconds"""
509
+
510
+
315
511
  class ParametersTypedDict(TypedDict):
316
512
  r"""Model behavior parameters that control how the model generates responses. Common parameters: `temperature` (0-1, randomness), `max_completion_tokens` (max output length), `top_p` (sampling diversity). Advanced: `frequency_penalty`, `presence_penalty`, `response_format` (JSON/structured), `reasoning_effort`, `seed` (reproducibility). Support varies by model - consult AI Gateway documentation."""
317
513
 
@@ -371,6 +567,16 @@ class ParametersTypedDict(TypedDict):
371
567
  List[CreateAgentRequestModelConfigurationGuardrailsTypedDict]
372
568
  ]
373
569
  r"""A list of guardrails to apply to the request."""
570
+ fallbacks: NotRequired[List[FallbacksTypedDict]]
571
+ r"""Array of fallback models to use if primary model fails"""
572
+ retry: NotRequired[RetryTypedDict]
573
+ r"""Retry configuration for the request"""
574
+ cache: NotRequired[CacheTypedDict]
575
+ r"""Cache configuration for the request."""
576
+ load_balancer: NotRequired[LoadBalancerTypedDict]
577
+ r"""Load balancer configuration for the request."""
578
+ timeout: NotRequired[TimeoutTypedDict]
579
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
374
580
 
375
581
 
376
582
  class Parameters(BaseModel):
@@ -452,77 +658,96 @@ class Parameters(BaseModel):
452
658
  guardrails: Optional[List[CreateAgentRequestModelConfigurationGuardrails]] = None
453
659
  r"""A list of guardrails to apply to the request."""
454
660
 
661
+ fallbacks: Optional[List[Fallbacks]] = None
662
+ r"""Array of fallback models to use if primary model fails"""
663
+
664
+ retry: Optional[Retry] = None
665
+ r"""Retry configuration for the request"""
666
+
667
+ cache: Optional[Cache] = None
668
+ r"""Cache configuration for the request."""
669
+
670
+ load_balancer: Optional[LoadBalancer] = None
671
+ r"""Load balancer configuration for the request."""
672
+
673
+ timeout: Optional[Timeout] = None
674
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
675
+
455
676
  @model_serializer(mode="wrap")
456
677
  def serialize_model(self, handler):
457
- optional_fields = [
458
- "audio",
459
- "frequency_penalty",
460
- "max_tokens",
461
- "max_completion_tokens",
462
- "logprobs",
463
- "top_logprobs",
464
- "n",
465
- "presence_penalty",
466
- "response_format",
467
- "reasoning_effort",
468
- "verbosity",
469
- "seed",
470
- "stop",
471
- "stream_options",
472
- "thinking",
473
- "temperature",
474
- "top_p",
475
- "top_k",
476
- "tool_choice",
477
- "parallel_tool_calls",
478
- "modalities",
479
- "guardrails",
480
- ]
481
- nullable_fields = [
482
- "audio",
483
- "frequency_penalty",
484
- "max_tokens",
485
- "max_completion_tokens",
486
- "logprobs",
487
- "top_logprobs",
488
- "n",
489
- "presence_penalty",
490
- "seed",
491
- "stop",
492
- "stream_options",
493
- "temperature",
494
- "top_p",
495
- "top_k",
496
- "modalities",
497
- ]
498
- null_default_fields = []
499
-
678
+ optional_fields = set(
679
+ [
680
+ "audio",
681
+ "frequency_penalty",
682
+ "max_tokens",
683
+ "max_completion_tokens",
684
+ "logprobs",
685
+ "top_logprobs",
686
+ "n",
687
+ "presence_penalty",
688
+ "response_format",
689
+ "reasoning_effort",
690
+ "verbosity",
691
+ "seed",
692
+ "stop",
693
+ "stream_options",
694
+ "thinking",
695
+ "temperature",
696
+ "top_p",
697
+ "top_k",
698
+ "tool_choice",
699
+ "parallel_tool_calls",
700
+ "modalities",
701
+ "guardrails",
702
+ "fallbacks",
703
+ "retry",
704
+ "cache",
705
+ "load_balancer",
706
+ "timeout",
707
+ ]
708
+ )
709
+ nullable_fields = set(
710
+ [
711
+ "audio",
712
+ "frequency_penalty",
713
+ "max_tokens",
714
+ "max_completion_tokens",
715
+ "logprobs",
716
+ "top_logprobs",
717
+ "n",
718
+ "presence_penalty",
719
+ "seed",
720
+ "stop",
721
+ "stream_options",
722
+ "temperature",
723
+ "top_p",
724
+ "top_k",
725
+ "modalities",
726
+ ]
727
+ )
500
728
  serialized = handler(self)
501
-
502
729
  m = {}
503
730
 
504
731
  for n, f in type(self).model_fields.items():
505
732
  k = f.alias or n
506
733
  val = serialized.get(k)
507
- serialized.pop(k, None)
508
-
509
- optional_nullable = k in optional_fields and k in nullable_fields
510
- is_set = (
511
- self.__pydantic_fields_set__.intersection({n})
512
- or k in null_default_fields
513
- ) # pylint: disable=no-member
514
-
515
- if val is not None and val != UNSET_SENTINEL:
516
- m[k] = val
517
- elif val != UNSET_SENTINEL and (
518
- not k in optional_fields or (optional_nullable and is_set)
519
- ):
520
- m[k] = val
734
+ is_nullable_and_explicitly_set = (
735
+ k in nullable_fields
736
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
737
+ )
738
+
739
+ if val != UNSET_SENTINEL:
740
+ if (
741
+ val is not None
742
+ or k not in optional_fields
743
+ or is_nullable_and_explicitly_set
744
+ ):
745
+ m[k] = val
521
746
 
522
747
  return m
523
748
 
524
749
 
525
- class RetryTypedDict(TypedDict):
750
+ class ModelConfigurationRetryTypedDict(TypedDict):
526
751
  r"""Retry configuration for model requests. Retries are triggered for specific HTTP status codes (e.g., 500, 429, 502, 503, 504). Supports configurable retry count (1-5) and custom status codes."""
527
752
 
528
753
  count: NotRequired[float]
@@ -531,7 +756,7 @@ class RetryTypedDict(TypedDict):
531
756
  r"""HTTP status codes that trigger retry logic"""
532
757
 
533
758
 
534
- class Retry(BaseModel):
759
+ class ModelConfigurationRetry(BaseModel):
535
760
  r"""Retry configuration for model requests. Retries are triggered for specific HTTP status codes (e.g., 500, 429, 502, 503, 504). Supports configurable retry count (1-5) and custom status codes."""
536
761
 
537
762
  count: Optional[float] = 3
@@ -540,6 +765,22 @@ class Retry(BaseModel):
540
765
  on_codes: Optional[List[float]] = None
541
766
  r"""HTTP status codes that trigger retry logic"""
542
767
 
768
+ @model_serializer(mode="wrap")
769
+ def serialize_model(self, handler):
770
+ optional_fields = set(["count", "on_codes"])
771
+ serialized = handler(self)
772
+ m = {}
773
+
774
+ for n, f in type(self).model_fields.items():
775
+ k = f.alias or n
776
+ val = serialized.get(k)
777
+
778
+ if val != UNSET_SENTINEL:
779
+ if val is not None or k not in optional_fields:
780
+ m[k] = val
781
+
782
+ return m
783
+
543
784
 
544
785
  class ModelConfiguration2TypedDict(TypedDict):
545
786
  r"""
@@ -551,7 +792,7 @@ class ModelConfiguration2TypedDict(TypedDict):
551
792
  r"""A model ID string (e.g., `openai/gpt-4o` or `anthropic/claude-haiku-4-5-20251001`). Only models that support tool calling can be used with agents."""
552
793
  parameters: NotRequired[ParametersTypedDict]
553
794
  r"""Model behavior parameters that control how the model generates responses. Common parameters: `temperature` (0-1, randomness), `max_completion_tokens` (max output length), `top_p` (sampling diversity). Advanced: `frequency_penalty`, `presence_penalty`, `response_format` (JSON/structured), `reasoning_effort`, `seed` (reproducibility). Support varies by model - consult AI Gateway documentation."""
554
- retry: NotRequired[RetryTypedDict]
795
+ retry: NotRequired[ModelConfigurationRetryTypedDict]
555
796
  r"""Retry configuration for model requests. Retries are triggered for specific HTTP status codes (e.g., 500, 429, 502, 503, 504). Supports configurable retry count (1-5) and custom status codes."""
556
797
 
557
798
 
@@ -567,9 +808,25 @@ class ModelConfiguration2(BaseModel):
567
808
  parameters: Optional[Parameters] = None
568
809
  r"""Model behavior parameters that control how the model generates responses. Common parameters: `temperature` (0-1, randomness), `max_completion_tokens` (max output length), `top_p` (sampling diversity). Advanced: `frequency_penalty`, `presence_penalty`, `response_format` (JSON/structured), `reasoning_effort`, `seed` (reproducibility). Support varies by model - consult AI Gateway documentation."""
569
810
 
570
- retry: Optional[Retry] = None
811
+ retry: Optional[ModelConfigurationRetry] = None
571
812
  r"""Retry configuration for model requests. Retries are triggered for specific HTTP status codes (e.g., 500, 429, 502, 503, 504). Supports configurable retry count (1-5) and custom status codes."""
572
813
 
814
+ @model_serializer(mode="wrap")
815
+ def serialize_model(self, handler):
816
+ optional_fields = set(["parameters", "retry"])
817
+ serialized = handler(self)
818
+ m = {}
819
+
820
+ for n, f in type(self).model_fields.items():
821
+ k = f.alias or n
822
+ val = serialized.get(k)
823
+
824
+ if val != UNSET_SENTINEL:
825
+ if val is not None or k not in optional_fields:
826
+ m[k] = val
827
+
828
+ return m
829
+
573
830
 
574
831
  ModelConfigurationTypedDict = TypeAliasType(
575
832
  "ModelConfigurationTypedDict", Union[ModelConfiguration2TypedDict, str]
@@ -652,6 +909,22 @@ class CreateAgentRequestResponseFormatAgentsJSONSchema(BaseModel):
652
909
  strict: Optional[bool] = False
653
910
  r"""Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true."""
654
911
 
912
+ @model_serializer(mode="wrap")
913
+ def serialize_model(self, handler):
914
+ optional_fields = set(["description", "schema", "strict"])
915
+ serialized = handler(self)
916
+ m = {}
917
+
918
+ for n, f in type(self).model_fields.items():
919
+ k = f.alias or n
920
+ val = serialized.get(k)
921
+
922
+ if val != UNSET_SENTINEL:
923
+ if val is not None or k not in optional_fields:
924
+ m[k] = val
925
+
926
+ return m
927
+
655
928
 
656
929
  class CreateAgentRequestResponseFormatJSONSchemaTypedDict(TypedDict):
657
930
  r"""
@@ -782,6 +1055,22 @@ class FallbackModelConfigurationStreamOptions(BaseModel):
782
1055
  include_usage: Optional[bool] = None
783
1056
  r"""If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value."""
784
1057
 
1058
+ @model_serializer(mode="wrap")
1059
+ def serialize_model(self, handler):
1060
+ optional_fields = set(["include_usage"])
1061
+ serialized = handler(self)
1062
+ m = {}
1063
+
1064
+ for n, f in type(self).model_fields.items():
1065
+ k = f.alias or n
1066
+ val = serialized.get(k)
1067
+
1068
+ if val != UNSET_SENTINEL:
1069
+ if val is not None or k not in optional_fields:
1070
+ m[k] = val
1071
+
1072
+ return m
1073
+
785
1074
 
786
1075
  FallbackModelConfigurationThinkingTypedDict = TypeAliasType(
787
1076
  "FallbackModelConfigurationThinkingTypedDict",
@@ -824,6 +1113,22 @@ class CreateAgentRequestToolChoice2(BaseModel):
824
1113
  type: Optional[CreateAgentRequestToolChoiceType] = None
825
1114
  r"""The type of the tool. Currently, only function is supported."""
826
1115
 
1116
+ @model_serializer(mode="wrap")
1117
+ def serialize_model(self, handler):
1118
+ optional_fields = set(["type"])
1119
+ serialized = handler(self)
1120
+ m = {}
1121
+
1122
+ for n, f in type(self).model_fields.items():
1123
+ k = f.alias or n
1124
+ val = serialized.get(k)
1125
+
1126
+ if val != UNSET_SENTINEL:
1127
+ if val is not None or k not in optional_fields:
1128
+ m[k] = val
1129
+
1130
+ return m
1131
+
827
1132
 
828
1133
  CreateAgentRequestToolChoice1 = Literal[
829
1134
  "none",
@@ -890,65 +1195,225 @@ class FallbackModelConfigurationGuardrails(BaseModel):
890
1195
  r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
891
1196
 
892
1197
 
893
- class FallbackModelConfigurationParametersTypedDict(TypedDict):
894
- r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
895
-
896
- audio: NotRequired[Nullable[FallbackModelConfigurationAudioTypedDict]]
897
- r"""Parameters for audio output. Required when audio output is requested with modalities: [\"audio\"]. Learn more."""
898
- frequency_penalty: NotRequired[Nullable[float]]
899
- r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."""
900
- max_tokens: NotRequired[Nullable[int]]
901
- r"""`[Deprecated]`. The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
1198
+ class FallbackModelConfigurationFallbacksTypedDict(TypedDict):
1199
+ model: str
1200
+ r"""Fallback model identifier"""
902
1201
 
903
- This value is now `deprecated` in favor of `max_completion_tokens`, and is not compatible with o1 series models.
904
- """
905
- max_completion_tokens: NotRequired[Nullable[int]]
906
- r"""An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens"""
907
- logprobs: NotRequired[Nullable[bool]]
908
- r"""Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message."""
909
- top_logprobs: NotRequired[Nullable[int]]
910
- r"""An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used."""
911
- n: NotRequired[Nullable[int]]
912
- r"""How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."""
913
- presence_penalty: NotRequired[Nullable[float]]
914
- r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics."""
915
- response_format: NotRequired[FallbackModelConfigurationResponseFormatTypedDict]
916
- r"""An object specifying the format that the model must output"""
917
- reasoning_effort: NotRequired[FallbackModelConfigurationReasoningEffort]
918
- r"""Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
919
1202
 
920
- - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1.
921
- - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
922
- - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
923
- - `xhigh` is currently only supported for `gpt-5.1-codex-max`.
1203
+ class FallbackModelConfigurationFallbacks(BaseModel):
1204
+ model: str
1205
+ r"""Fallback model identifier"""
924
1206
 
925
- Any of \"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\".
926
- """
927
- verbosity: NotRequired[str]
928
- r"""Adjusts response verbosity. Lower levels yield shorter answers."""
929
- seed: NotRequired[Nullable[float]]
930
- r"""If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."""
931
- stop: NotRequired[Nullable[FallbackModelConfigurationStopTypedDict]]
932
- r"""Up to 4 sequences where the API will stop generating further tokens."""
933
- stream_options: NotRequired[
934
- Nullable[FallbackModelConfigurationStreamOptionsTypedDict]
935
- ]
936
- r"""Options for streaming response. Only set this when you set stream: true."""
937
- thinking: NotRequired[FallbackModelConfigurationThinkingTypedDict]
938
- temperature: NotRequired[Nullable[float]]
939
- r"""What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic."""
940
- top_p: NotRequired[Nullable[float]]
941
- r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass."""
942
- top_k: NotRequired[Nullable[float]]
943
- r"""Limits the model to consider only the top k most likely tokens at each step."""
944
- tool_choice: NotRequired[FallbackModelConfigurationToolChoiceTypedDict]
945
- r"""Controls which (if any) tool is called by the model."""
946
- parallel_tool_calls: NotRequired[bool]
947
- r"""Whether to enable parallel function calling during tool use."""
948
- modalities: NotRequired[Nullable[List[FallbackModelConfigurationModalities]]]
949
- r"""Output types that you would like the model to generate. Most models are capable of generating text, which is the default: [\"text\"]. The gpt-4o-audio-preview model can also be used to generate audio. To request that this model generate both text and audio responses, you can use: [\"text\", \"audio\"]."""
950
- guardrails: NotRequired[List[FallbackModelConfigurationGuardrailsTypedDict]]
951
- r"""A list of guardrails to apply to the request."""
1207
+
1208
+ class FallbackModelConfigurationRetryTypedDict(TypedDict):
1209
+ r"""Retry configuration for the request"""
1210
+
1211
+ count: NotRequired[float]
1212
+ r"""Number of retry attempts (1-5)"""
1213
+ on_codes: NotRequired[List[float]]
1214
+ r"""HTTP status codes that trigger retry logic"""
1215
+
1216
+
1217
+ class FallbackModelConfigurationRetry(BaseModel):
1218
+ r"""Retry configuration for the request"""
1219
+
1220
+ count: Optional[float] = 3
1221
+ r"""Number of retry attempts (1-5)"""
1222
+
1223
+ on_codes: Optional[List[float]] = None
1224
+ r"""HTTP status codes that trigger retry logic"""
1225
+
1226
+ @model_serializer(mode="wrap")
1227
+ def serialize_model(self, handler):
1228
+ optional_fields = set(["count", "on_codes"])
1229
+ serialized = handler(self)
1230
+ m = {}
1231
+
1232
+ for n, f in type(self).model_fields.items():
1233
+ k = f.alias or n
1234
+ val = serialized.get(k)
1235
+
1236
+ if val != UNSET_SENTINEL:
1237
+ if val is not None or k not in optional_fields:
1238
+ m[k] = val
1239
+
1240
+ return m
1241
+
1242
+
1243
+ FallbackModelConfigurationType = Literal["exact_match",]
1244
+
1245
+
1246
+ class FallbackModelConfigurationCacheTypedDict(TypedDict):
1247
+ r"""Cache configuration for the request."""
1248
+
1249
+ type: FallbackModelConfigurationType
1250
+ ttl: NotRequired[float]
1251
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
1252
+
1253
+
1254
+ class FallbackModelConfigurationCache(BaseModel):
1255
+ r"""Cache configuration for the request."""
1256
+
1257
+ type: FallbackModelConfigurationType
1258
+
1259
+ ttl: Optional[float] = 1800
1260
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
1261
+
1262
+ @model_serializer(mode="wrap")
1263
+ def serialize_model(self, handler):
1264
+ optional_fields = set(["ttl"])
1265
+ serialized = handler(self)
1266
+ m = {}
1267
+
1268
+ for n, f in type(self).model_fields.items():
1269
+ k = f.alias or n
1270
+ val = serialized.get(k)
1271
+
1272
+ if val != UNSET_SENTINEL:
1273
+ if val is not None or k not in optional_fields:
1274
+ m[k] = val
1275
+
1276
+ return m
1277
+
1278
+
1279
+ CreateAgentRequestLoadBalancerType = Literal["weight_based",]
1280
+
1281
+
1282
+ class LoadBalancerModelsTypedDict(TypedDict):
1283
+ model: str
1284
+ r"""Model identifier for load balancing"""
1285
+ weight: NotRequired[float]
1286
+ r"""Weight assigned to this model for load balancing"""
1287
+
1288
+
1289
+ class LoadBalancerModels(BaseModel):
1290
+ model: str
1291
+ r"""Model identifier for load balancing"""
1292
+
1293
+ weight: Optional[float] = 0.5
1294
+ r"""Weight assigned to this model for load balancing"""
1295
+
1296
+ @model_serializer(mode="wrap")
1297
+ def serialize_model(self, handler):
1298
+ optional_fields = set(["weight"])
1299
+ serialized = handler(self)
1300
+ m = {}
1301
+
1302
+ for n, f in type(self).model_fields.items():
1303
+ k = f.alias or n
1304
+ val = serialized.get(k)
1305
+
1306
+ if val != UNSET_SENTINEL:
1307
+ if val is not None or k not in optional_fields:
1308
+ m[k] = val
1309
+
1310
+ return m
1311
+
1312
+
1313
+ class CreateAgentRequestLoadBalancer1TypedDict(TypedDict):
1314
+ type: CreateAgentRequestLoadBalancerType
1315
+ models: List[LoadBalancerModelsTypedDict]
1316
+
1317
+
1318
+ class CreateAgentRequestLoadBalancer1(BaseModel):
1319
+ type: CreateAgentRequestLoadBalancerType
1320
+
1321
+ models: List[LoadBalancerModels]
1322
+
1323
+
1324
+ FallbackModelConfigurationLoadBalancerTypedDict = (
1325
+ CreateAgentRequestLoadBalancer1TypedDict
1326
+ )
1327
+ r"""Load balancer configuration for the request."""
1328
+
1329
+
1330
+ FallbackModelConfigurationLoadBalancer = CreateAgentRequestLoadBalancer1
1331
+ r"""Load balancer configuration for the request."""
1332
+
1333
+
1334
+ class FallbackModelConfigurationTimeoutTypedDict(TypedDict):
1335
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
1336
+
1337
+ call_timeout: float
1338
+ r"""Timeout value in milliseconds"""
1339
+
1340
+
1341
+ class FallbackModelConfigurationTimeout(BaseModel):
1342
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
1343
+
1344
+ call_timeout: float
1345
+ r"""Timeout value in milliseconds"""
1346
+
1347
+
1348
+ class FallbackModelConfigurationParametersTypedDict(TypedDict):
1349
+ r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1350
+
1351
+ audio: NotRequired[Nullable[FallbackModelConfigurationAudioTypedDict]]
1352
+ r"""Parameters for audio output. Required when audio output is requested with modalities: [\"audio\"]. Learn more."""
1353
+ frequency_penalty: NotRequired[Nullable[float]]
1354
+ r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."""
1355
+ max_tokens: NotRequired[Nullable[int]]
1356
+ r"""`[Deprecated]`. The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
1357
+
1358
+ This value is now `deprecated` in favor of `max_completion_tokens`, and is not compatible with o1 series models.
1359
+ """
1360
+ max_completion_tokens: NotRequired[Nullable[int]]
1361
+ r"""An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens"""
1362
+ logprobs: NotRequired[Nullable[bool]]
1363
+ r"""Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message."""
1364
+ top_logprobs: NotRequired[Nullable[int]]
1365
+ r"""An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used."""
1366
+ n: NotRequired[Nullable[int]]
1367
+ r"""How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."""
1368
+ presence_penalty: NotRequired[Nullable[float]]
1369
+ r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics."""
1370
+ response_format: NotRequired[FallbackModelConfigurationResponseFormatTypedDict]
1371
+ r"""An object specifying the format that the model must output"""
1372
+ reasoning_effort: NotRequired[FallbackModelConfigurationReasoningEffort]
1373
+ r"""Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
1374
+
1375
+ - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1.
1376
+ - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
1377
+ - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
1378
+ - `xhigh` is currently only supported for `gpt-5.1-codex-max`.
1379
+
1380
+ Any of \"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\".
1381
+ """
1382
+ verbosity: NotRequired[str]
1383
+ r"""Adjusts response verbosity. Lower levels yield shorter answers."""
1384
+ seed: NotRequired[Nullable[float]]
1385
+ r"""If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."""
1386
+ stop: NotRequired[Nullable[FallbackModelConfigurationStopTypedDict]]
1387
+ r"""Up to 4 sequences where the API will stop generating further tokens."""
1388
+ stream_options: NotRequired[
1389
+ Nullable[FallbackModelConfigurationStreamOptionsTypedDict]
1390
+ ]
1391
+ r"""Options for streaming response. Only set this when you set stream: true."""
1392
+ thinking: NotRequired[FallbackModelConfigurationThinkingTypedDict]
1393
+ temperature: NotRequired[Nullable[float]]
1394
+ r"""What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic."""
1395
+ top_p: NotRequired[Nullable[float]]
1396
+ r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass."""
1397
+ top_k: NotRequired[Nullable[float]]
1398
+ r"""Limits the model to consider only the top k most likely tokens at each step."""
1399
+ tool_choice: NotRequired[FallbackModelConfigurationToolChoiceTypedDict]
1400
+ r"""Controls which (if any) tool is called by the model."""
1401
+ parallel_tool_calls: NotRequired[bool]
1402
+ r"""Whether to enable parallel function calling during tool use."""
1403
+ modalities: NotRequired[Nullable[List[FallbackModelConfigurationModalities]]]
1404
+ r"""Output types that you would like the model to generate. Most models are capable of generating text, which is the default: [\"text\"]. The gpt-4o-audio-preview model can also be used to generate audio. To request that this model generate both text and audio responses, you can use: [\"text\", \"audio\"]."""
1405
+ guardrails: NotRequired[List[FallbackModelConfigurationGuardrailsTypedDict]]
1406
+ r"""A list of guardrails to apply to the request."""
1407
+ fallbacks: NotRequired[List[FallbackModelConfigurationFallbacksTypedDict]]
1408
+ r"""Array of fallback models to use if primary model fails"""
1409
+ retry: NotRequired[FallbackModelConfigurationRetryTypedDict]
1410
+ r"""Retry configuration for the request"""
1411
+ cache: NotRequired[FallbackModelConfigurationCacheTypedDict]
1412
+ r"""Cache configuration for the request."""
1413
+ load_balancer: NotRequired[FallbackModelConfigurationLoadBalancerTypedDict]
1414
+ r"""Load balancer configuration for the request."""
1415
+ timeout: NotRequired[FallbackModelConfigurationTimeoutTypedDict]
1416
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
952
1417
 
953
1418
 
954
1419
  class FallbackModelConfigurationParameters(BaseModel):
@@ -1030,77 +1495,96 @@ class FallbackModelConfigurationParameters(BaseModel):
1030
1495
  guardrails: Optional[List[FallbackModelConfigurationGuardrails]] = None
1031
1496
  r"""A list of guardrails to apply to the request."""
1032
1497
 
1498
+ fallbacks: Optional[List[FallbackModelConfigurationFallbacks]] = None
1499
+ r"""Array of fallback models to use if primary model fails"""
1500
+
1501
+ retry: Optional[FallbackModelConfigurationRetry] = None
1502
+ r"""Retry configuration for the request"""
1503
+
1504
+ cache: Optional[FallbackModelConfigurationCache] = None
1505
+ r"""Cache configuration for the request."""
1506
+
1507
+ load_balancer: Optional[FallbackModelConfigurationLoadBalancer] = None
1508
+ r"""Load balancer configuration for the request."""
1509
+
1510
+ timeout: Optional[FallbackModelConfigurationTimeout] = None
1511
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
1512
+
1033
1513
  @model_serializer(mode="wrap")
1034
1514
  def serialize_model(self, handler):
1035
- optional_fields = [
1036
- "audio",
1037
- "frequency_penalty",
1038
- "max_tokens",
1039
- "max_completion_tokens",
1040
- "logprobs",
1041
- "top_logprobs",
1042
- "n",
1043
- "presence_penalty",
1044
- "response_format",
1045
- "reasoning_effort",
1046
- "verbosity",
1047
- "seed",
1048
- "stop",
1049
- "stream_options",
1050
- "thinking",
1051
- "temperature",
1052
- "top_p",
1053
- "top_k",
1054
- "tool_choice",
1055
- "parallel_tool_calls",
1056
- "modalities",
1057
- "guardrails",
1058
- ]
1059
- nullable_fields = [
1060
- "audio",
1061
- "frequency_penalty",
1062
- "max_tokens",
1063
- "max_completion_tokens",
1064
- "logprobs",
1065
- "top_logprobs",
1066
- "n",
1067
- "presence_penalty",
1068
- "seed",
1069
- "stop",
1070
- "stream_options",
1071
- "temperature",
1072
- "top_p",
1073
- "top_k",
1074
- "modalities",
1075
- ]
1076
- null_default_fields = []
1077
-
1515
+ optional_fields = set(
1516
+ [
1517
+ "audio",
1518
+ "frequency_penalty",
1519
+ "max_tokens",
1520
+ "max_completion_tokens",
1521
+ "logprobs",
1522
+ "top_logprobs",
1523
+ "n",
1524
+ "presence_penalty",
1525
+ "response_format",
1526
+ "reasoning_effort",
1527
+ "verbosity",
1528
+ "seed",
1529
+ "stop",
1530
+ "stream_options",
1531
+ "thinking",
1532
+ "temperature",
1533
+ "top_p",
1534
+ "top_k",
1535
+ "tool_choice",
1536
+ "parallel_tool_calls",
1537
+ "modalities",
1538
+ "guardrails",
1539
+ "fallbacks",
1540
+ "retry",
1541
+ "cache",
1542
+ "load_balancer",
1543
+ "timeout",
1544
+ ]
1545
+ )
1546
+ nullable_fields = set(
1547
+ [
1548
+ "audio",
1549
+ "frequency_penalty",
1550
+ "max_tokens",
1551
+ "max_completion_tokens",
1552
+ "logprobs",
1553
+ "top_logprobs",
1554
+ "n",
1555
+ "presence_penalty",
1556
+ "seed",
1557
+ "stop",
1558
+ "stream_options",
1559
+ "temperature",
1560
+ "top_p",
1561
+ "top_k",
1562
+ "modalities",
1563
+ ]
1564
+ )
1078
1565
  serialized = handler(self)
1079
-
1080
1566
  m = {}
1081
1567
 
1082
1568
  for n, f in type(self).model_fields.items():
1083
1569
  k = f.alias or n
1084
1570
  val = serialized.get(k)
1085
- serialized.pop(k, None)
1086
-
1087
- optional_nullable = k in optional_fields and k in nullable_fields
1088
- is_set = (
1089
- self.__pydantic_fields_set__.intersection({n})
1090
- or k in null_default_fields
1091
- ) # pylint: disable=no-member
1092
-
1093
- if val is not None and val != UNSET_SENTINEL:
1094
- m[k] = val
1095
- elif val != UNSET_SENTINEL and (
1096
- not k in optional_fields or (optional_nullable and is_set)
1097
- ):
1098
- m[k] = val
1571
+ is_nullable_and_explicitly_set = (
1572
+ k in nullable_fields
1573
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1574
+ )
1575
+
1576
+ if val != UNSET_SENTINEL:
1577
+ if (
1578
+ val is not None
1579
+ or k not in optional_fields
1580
+ or is_nullable_and_explicitly_set
1581
+ ):
1582
+ m[k] = val
1099
1583
 
1100
1584
  return m
1101
1585
 
1102
1586
 
1103
- class FallbackModelConfigurationRetryTypedDict(TypedDict):
1587
+ class CreateAgentRequestFallbackModelConfigurationRetryTypedDict(TypedDict):
1104
1588
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1105
1589
 
1106
1590
  count: NotRequired[float]
@@ -1109,7 +1593,7 @@ class FallbackModelConfigurationRetryTypedDict(TypedDict):
1109
1593
  r"""HTTP status codes that trigger retry logic"""
1110
1594
 
1111
1595
 
1112
- class FallbackModelConfigurationRetry(BaseModel):
1596
+ class CreateAgentRequestFallbackModelConfigurationRetry(BaseModel):
1113
1597
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1114
1598
 
1115
1599
  count: Optional[float] = 3
@@ -1118,6 +1602,22 @@ class FallbackModelConfigurationRetry(BaseModel):
1118
1602
  on_codes: Optional[List[float]] = None
1119
1603
  r"""HTTP status codes that trigger retry logic"""
1120
1604
 
1605
+ @model_serializer(mode="wrap")
1606
+ def serialize_model(self, handler):
1607
+ optional_fields = set(["count", "on_codes"])
1608
+ serialized = handler(self)
1609
+ m = {}
1610
+
1611
+ for n, f in type(self).model_fields.items():
1612
+ k = f.alias or n
1613
+ val = serialized.get(k)
1614
+
1615
+ if val != UNSET_SENTINEL:
1616
+ if val is not None or k not in optional_fields:
1617
+ m[k] = val
1618
+
1619
+ return m
1620
+
1121
1621
 
1122
1622
  class FallbackModelConfiguration2TypedDict(TypedDict):
1123
1623
  r"""Fallback model configuration with optional parameters and retry settings."""
@@ -1126,7 +1626,7 @@ class FallbackModelConfiguration2TypedDict(TypedDict):
1126
1626
  r"""A fallback model ID string. Must support tool calling."""
1127
1627
  parameters: NotRequired[FallbackModelConfigurationParametersTypedDict]
1128
1628
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1129
- retry: NotRequired[FallbackModelConfigurationRetryTypedDict]
1629
+ retry: NotRequired[CreateAgentRequestFallbackModelConfigurationRetryTypedDict]
1130
1630
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1131
1631
 
1132
1632
 
@@ -1139,9 +1639,25 @@ class FallbackModelConfiguration2(BaseModel):
1139
1639
  parameters: Optional[FallbackModelConfigurationParameters] = None
1140
1640
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1141
1641
 
1142
- retry: Optional[FallbackModelConfigurationRetry] = None
1642
+ retry: Optional[CreateAgentRequestFallbackModelConfigurationRetry] = None
1143
1643
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1144
1644
 
1645
+ @model_serializer(mode="wrap")
1646
+ def serialize_model(self, handler):
1647
+ optional_fields = set(["parameters", "retry"])
1648
+ serialized = handler(self)
1649
+ m = {}
1650
+
1651
+ for n, f in type(self).model_fields.items():
1652
+ k = f.alias or n
1653
+ val = serialized.get(k)
1654
+
1655
+ if val != UNSET_SENTINEL:
1656
+ if val is not None or k not in optional_fields:
1657
+ m[k] = val
1658
+
1659
+ return m
1660
+
1145
1661
 
1146
1662
  FallbackModelConfigurationTypedDict = TypeAliasType(
1147
1663
  "FallbackModelConfigurationTypedDict",
@@ -1164,7 +1680,7 @@ CreateAgentRequestToolApprovalRequired = Literal[
1164
1680
  r"""If all, the agent will require approval for all tools. If respect_tool, the agent will require approval for tools that have the requires_approval flag set to true. If none, the agent will not require approval for any tools."""
1165
1681
 
1166
1682
 
1167
- CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type = (
1683
+ CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools16Type = (
1168
1684
  Literal["mcp",]
1169
1685
  )
1170
1686
  r"""MCP tool type"""
@@ -1176,7 +1692,7 @@ class MCPToolTypedDict(TypedDict):
1176
1692
  tool_id: str
1177
1693
  r"""The ID of the specific nested tool within the MCP server"""
1178
1694
  type: NotRequired[
1179
- CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1695
+ CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools16Type
1180
1696
  ]
1181
1697
  r"""MCP tool type"""
1182
1698
  key: NotRequired[str]
@@ -1194,7 +1710,7 @@ class MCPTool(BaseModel):
1194
1710
  r"""The ID of the specific nested tool within the MCP server"""
1195
1711
 
1196
1712
  type: Optional[
1197
- CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1713
+ CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools16Type
1198
1714
  ] = "mcp"
1199
1715
  r"""MCP tool type"""
1200
1716
 
@@ -1207,6 +1723,77 @@ class MCPTool(BaseModel):
1207
1723
  requires_approval: Optional[bool] = False
1208
1724
  r"""Whether this tool requires approval before execution"""
1209
1725
 
1726
+ @model_serializer(mode="wrap")
1727
+ def serialize_model(self, handler):
1728
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1729
+ serialized = handler(self)
1730
+ m = {}
1731
+
1732
+ for n, f in type(self).model_fields.items():
1733
+ k = f.alias or n
1734
+ val = serialized.get(k)
1735
+
1736
+ if val != UNSET_SENTINEL:
1737
+ if val is not None or k not in optional_fields:
1738
+ m[k] = val
1739
+
1740
+ return m
1741
+
1742
+
1743
+ CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type = (
1744
+ Literal["json_schema",]
1745
+ )
1746
+ r"""JSON Schema tool type"""
1747
+
1748
+
1749
+ class JSONSchemaToolTypedDict(TypedDict):
1750
+ r"""Enforces structured output format using JSON Schema. Must reference a pre-created JSON Schema tool by key or id."""
1751
+
1752
+ type: NotRequired[
1753
+ CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1754
+ ]
1755
+ r"""JSON Schema tool type"""
1756
+ key: NotRequired[str]
1757
+ r"""The key of the pre-created JSON Schema tool"""
1758
+ id: NotRequired[str]
1759
+ r"""The ID of the pre-created JSON Schema tool"""
1760
+ requires_approval: NotRequired[bool]
1761
+ r"""Whether this tool requires approval before execution"""
1762
+
1763
+
1764
+ class JSONSchemaTool(BaseModel):
1765
+ r"""Enforces structured output format using JSON Schema. Must reference a pre-created JSON Schema tool by key or id."""
1766
+
1767
+ type: Optional[
1768
+ CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1769
+ ] = "json_schema"
1770
+ r"""JSON Schema tool type"""
1771
+
1772
+ key: Optional[str] = None
1773
+ r"""The key of the pre-created JSON Schema tool"""
1774
+
1775
+ id: Optional[str] = None
1776
+ r"""The ID of the pre-created JSON Schema tool"""
1777
+
1778
+ requires_approval: Optional[bool] = False
1779
+ r"""Whether this tool requires approval before execution"""
1780
+
1781
+ @model_serializer(mode="wrap")
1782
+ def serialize_model(self, handler):
1783
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1784
+ serialized = handler(self)
1785
+ m = {}
1786
+
1787
+ for n, f in type(self).model_fields.items():
1788
+ k = f.alias or n
1789
+ val = serialized.get(k)
1790
+
1791
+ if val != UNSET_SENTINEL:
1792
+ if val is not None or k not in optional_fields:
1793
+ m[k] = val
1794
+
1795
+ return m
1796
+
1210
1797
 
1211
1798
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools14Type = (
1212
1799
  Literal["function",]
@@ -1246,6 +1833,22 @@ class FunctionTool(BaseModel):
1246
1833
  requires_approval: Optional[bool] = False
1247
1834
  r"""Whether this tool requires approval before execution"""
1248
1835
 
1836
+ @model_serializer(mode="wrap")
1837
+ def serialize_model(self, handler):
1838
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1839
+ serialized = handler(self)
1840
+ m = {}
1841
+
1842
+ for n, f in type(self).model_fields.items():
1843
+ k = f.alias or n
1844
+ val = serialized.get(k)
1845
+
1846
+ if val != UNSET_SENTINEL:
1847
+ if val is not None or k not in optional_fields:
1848
+ m[k] = val
1849
+
1850
+ return m
1851
+
1249
1852
 
1250
1853
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools13Type = (
1251
1854
  Literal["code",]
@@ -1285,6 +1888,22 @@ class CodeExecutionTool(BaseModel):
1285
1888
  requires_approval: Optional[bool] = False
1286
1889
  r"""Whether this tool requires approval before execution"""
1287
1890
 
1891
+ @model_serializer(mode="wrap")
1892
+ def serialize_model(self, handler):
1893
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1894
+ serialized = handler(self)
1895
+ m = {}
1896
+
1897
+ for n, f in type(self).model_fields.items():
1898
+ k = f.alias or n
1899
+ val = serialized.get(k)
1900
+
1901
+ if val != UNSET_SENTINEL:
1902
+ if val is not None or k not in optional_fields:
1903
+ m[k] = val
1904
+
1905
+ return m
1906
+
1288
1907
 
1289
1908
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools12Type = (
1290
1909
  Literal["http",]
@@ -1324,6 +1943,22 @@ class HTTPTool(BaseModel):
1324
1943
  requires_approval: Optional[bool] = False
1325
1944
  r"""Whether this tool requires approval before execution"""
1326
1945
 
1946
+ @model_serializer(mode="wrap")
1947
+ def serialize_model(self, handler):
1948
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1949
+ serialized = handler(self)
1950
+ m = {}
1951
+
1952
+ for n, f in type(self).model_fields.items():
1953
+ k = f.alias or n
1954
+ val = serialized.get(k)
1955
+
1956
+ if val != UNSET_SENTINEL:
1957
+ if val is not None or k not in optional_fields:
1958
+ m[k] = val
1959
+
1960
+ return m
1961
+
1327
1962
 
1328
1963
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools11Type = (
1329
1964
  Literal["current_date",]
@@ -1350,6 +1985,22 @@ class CurrentDateTool(BaseModel):
1350
1985
  requires_approval: Optional[bool] = None
1351
1986
  r"""Whether this tool requires approval before execution"""
1352
1987
 
1988
+ @model_serializer(mode="wrap")
1989
+ def serialize_model(self, handler):
1990
+ optional_fields = set(["requires_approval"])
1991
+ serialized = handler(self)
1992
+ m = {}
1993
+
1994
+ for n, f in type(self).model_fields.items():
1995
+ k = f.alias or n
1996
+ val = serialized.get(k)
1997
+
1998
+ if val != UNSET_SENTINEL:
1999
+ if val is not None or k not in optional_fields:
2000
+ m[k] = val
2001
+
2002
+ return m
2003
+
1353
2004
 
1354
2005
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools10Type = (
1355
2006
  Literal["query_knowledge_base",]
@@ -1376,6 +2027,22 @@ class QueryKnowledgeBaseTool(BaseModel):
1376
2027
  requires_approval: Optional[bool] = None
1377
2028
  r"""Whether this tool requires approval before execution"""
1378
2029
 
2030
+ @model_serializer(mode="wrap")
2031
+ def serialize_model(self, handler):
2032
+ optional_fields = set(["requires_approval"])
2033
+ serialized = handler(self)
2034
+ m = {}
2035
+
2036
+ for n, f in type(self).model_fields.items():
2037
+ k = f.alias or n
2038
+ val = serialized.get(k)
2039
+
2040
+ if val != UNSET_SENTINEL:
2041
+ if val is not None or k not in optional_fields:
2042
+ m[k] = val
2043
+
2044
+ return m
2045
+
1379
2046
 
1380
2047
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools9Type = (
1381
2048
  Literal["retrieve_knowledge_bases",]
@@ -1398,6 +2065,22 @@ class RetrieveKnowledgeBasesTool(BaseModel):
1398
2065
  requires_approval: Optional[bool] = None
1399
2066
  r"""Whether this tool requires approval before execution"""
1400
2067
 
2068
+ @model_serializer(mode="wrap")
2069
+ def serialize_model(self, handler):
2070
+ optional_fields = set(["requires_approval"])
2071
+ serialized = handler(self)
2072
+ m = {}
2073
+
2074
+ for n, f in type(self).model_fields.items():
2075
+ k = f.alias or n
2076
+ val = serialized.get(k)
2077
+
2078
+ if val != UNSET_SENTINEL:
2079
+ if val is not None or k not in optional_fields:
2080
+ m[k] = val
2081
+
2082
+ return m
2083
+
1401
2084
 
1402
2085
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsTools8Type = (
1403
2086
  Literal["delete_memory_document",]
@@ -1420,6 +2103,22 @@ class DeleteMemoryDocumentTool(BaseModel):
1420
2103
  requires_approval: Optional[bool] = None
1421
2104
  r"""Whether this tool requires approval before execution"""
1422
2105
 
2106
+ @model_serializer(mode="wrap")
2107
+ def serialize_model(self, handler):
2108
+ optional_fields = set(["requires_approval"])
2109
+ serialized = handler(self)
2110
+ m = {}
2111
+
2112
+ for n, f in type(self).model_fields.items():
2113
+ k = f.alias or n
2114
+ val = serialized.get(k)
2115
+
2116
+ if val != UNSET_SENTINEL:
2117
+ if val is not None or k not in optional_fields:
2118
+ m[k] = val
2119
+
2120
+ return m
2121
+
1423
2122
 
1424
2123
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsToolsType = Literal[
1425
2124
  "retrieve_memory_stores",
@@ -1442,6 +2141,22 @@ class RetrieveMemoryStoresTool(BaseModel):
1442
2141
  requires_approval: Optional[bool] = None
1443
2142
  r"""Whether this tool requires approval before execution"""
1444
2143
 
2144
+ @model_serializer(mode="wrap")
2145
+ def serialize_model(self, handler):
2146
+ optional_fields = set(["requires_approval"])
2147
+ serialized = handler(self)
2148
+ m = {}
2149
+
2150
+ for n, f in type(self).model_fields.items():
2151
+ k = f.alias or n
2152
+ val = serialized.get(k)
2153
+
2154
+ if val != UNSET_SENTINEL:
2155
+ if val is not None or k not in optional_fields:
2156
+ m[k] = val
2157
+
2158
+ return m
2159
+
1445
2160
 
1446
2161
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodySettingsType = Literal[
1447
2162
  "write_memory_store",
@@ -1464,6 +2179,22 @@ class WriteMemoryStoreTool(BaseModel):
1464
2179
  requires_approval: Optional[bool] = None
1465
2180
  r"""Whether this tool requires approval before execution"""
1466
2181
 
2182
+ @model_serializer(mode="wrap")
2183
+ def serialize_model(self, handler):
2184
+ optional_fields = set(["requires_approval"])
2185
+ serialized = handler(self)
2186
+ m = {}
2187
+
2188
+ for n, f in type(self).model_fields.items():
2189
+ k = f.alias or n
2190
+ val = serialized.get(k)
2191
+
2192
+ if val != UNSET_SENTINEL:
2193
+ if val is not None or k not in optional_fields:
2194
+ m[k] = val
2195
+
2196
+ return m
2197
+
1467
2198
 
1468
2199
  CreateAgentRequestAgentToolInputCRUDAgentsRequestRequestBodyType = Literal[
1469
2200
  "query_memory_store",
@@ -1486,6 +2217,22 @@ class QueryMemoryStoreTool(BaseModel):
1486
2217
  requires_approval: Optional[bool] = None
1487
2218
  r"""Whether this tool requires approval before execution"""
1488
2219
 
2220
+ @model_serializer(mode="wrap")
2221
+ def serialize_model(self, handler):
2222
+ optional_fields = set(["requires_approval"])
2223
+ serialized = handler(self)
2224
+ m = {}
2225
+
2226
+ for n, f in type(self).model_fields.items():
2227
+ k = f.alias or n
2228
+ val = serialized.get(k)
2229
+
2230
+ if val != UNSET_SENTINEL:
2231
+ if val is not None or k not in optional_fields:
2232
+ m[k] = val
2233
+
2234
+ return m
2235
+
1489
2236
 
1490
2237
  CreateAgentRequestAgentToolInputCRUDAgentsRequestType = Literal["retrieve_agents",]
1491
2238
 
@@ -1506,6 +2253,22 @@ class RetrieveAgentsTool(BaseModel):
1506
2253
  requires_approval: Optional[bool] = None
1507
2254
  r"""Whether this tool requires approval before execution"""
1508
2255
 
2256
+ @model_serializer(mode="wrap")
2257
+ def serialize_model(self, handler):
2258
+ optional_fields = set(["requires_approval"])
2259
+ serialized = handler(self)
2260
+ m = {}
2261
+
2262
+ for n, f in type(self).model_fields.items():
2263
+ k = f.alias or n
2264
+ val = serialized.get(k)
2265
+
2266
+ if val != UNSET_SENTINEL:
2267
+ if val is not None or k not in optional_fields:
2268
+ m[k] = val
2269
+
2270
+ return m
2271
+
1509
2272
 
1510
2273
  CreateAgentRequestAgentToolInputCRUDAgentsType = Literal["call_sub_agent",]
1511
2274
 
@@ -1526,6 +2289,22 @@ class CallSubAgentTool(BaseModel):
1526
2289
  requires_approval: Optional[bool] = None
1527
2290
  r"""Whether this tool requires approval before execution"""
1528
2291
 
2292
+ @model_serializer(mode="wrap")
2293
+ def serialize_model(self, handler):
2294
+ optional_fields = set(["requires_approval"])
2295
+ serialized = handler(self)
2296
+ m = {}
2297
+
2298
+ for n, f in type(self).model_fields.items():
2299
+ k = f.alias or n
2300
+ val = serialized.get(k)
2301
+
2302
+ if val != UNSET_SENTINEL:
2303
+ if val is not None or k not in optional_fields:
2304
+ m[k] = val
2305
+
2306
+ return m
2307
+
1529
2308
 
1530
2309
  CreateAgentRequestAgentToolInputCRUDType = Literal["web_scraper",]
1531
2310
 
@@ -1546,6 +2325,22 @@ class WebScraperTool(BaseModel):
1546
2325
  requires_approval: Optional[bool] = None
1547
2326
  r"""Whether this tool requires approval before execution"""
1548
2327
 
2328
+ @model_serializer(mode="wrap")
2329
+ def serialize_model(self, handler):
2330
+ optional_fields = set(["requires_approval"])
2331
+ serialized = handler(self)
2332
+ m = {}
2333
+
2334
+ for n, f in type(self).model_fields.items():
2335
+ k = f.alias or n
2336
+ val = serialized.get(k)
2337
+
2338
+ if val != UNSET_SENTINEL:
2339
+ if val is not None or k not in optional_fields:
2340
+ m[k] = val
2341
+
2342
+ return m
2343
+
1549
2344
 
1550
2345
  AgentToolInputCRUDType = Literal["google_search",]
1551
2346
 
@@ -1566,6 +2361,22 @@ class GoogleSearchTool(BaseModel):
1566
2361
  requires_approval: Optional[bool] = None
1567
2362
  r"""Whether this tool requires approval before execution"""
1568
2363
 
2364
+ @model_serializer(mode="wrap")
2365
+ def serialize_model(self, handler):
2366
+ optional_fields = set(["requires_approval"])
2367
+ serialized = handler(self)
2368
+ m = {}
2369
+
2370
+ for n, f in type(self).model_fields.items():
2371
+ k = f.alias or n
2372
+ val = serialized.get(k)
2373
+
2374
+ if val != UNSET_SENTINEL:
2375
+ if val is not None or k not in optional_fields:
2376
+ m[k] = val
2377
+
2378
+ return m
2379
+
1569
2380
 
1570
2381
  AgentToolInputCRUDTypedDict = TypeAliasType(
1571
2382
  "AgentToolInputCRUDTypedDict",
@@ -1584,10 +2395,11 @@ AgentToolInputCRUDTypedDict = TypeAliasType(
1584
2395
  HTTPToolTypedDict,
1585
2396
  CodeExecutionToolTypedDict,
1586
2397
  FunctionToolTypedDict,
2398
+ JSONSchemaToolTypedDict,
1587
2399
  MCPToolTypedDict,
1588
2400
  ],
1589
2401
  )
1590
- r"""Tool configuration for agent create/update operations. Built-in tools only require a type, while custom tools (HTTP, Code, Function, MCP) must reference pre-created tools by key or id."""
2402
+ r"""Tool configuration for agent create/update operations. Built-in tools only require a type, while custom tools (HTTP, Code, Function, JSON Schema, MCP) must reference pre-created tools by key or id."""
1591
2403
 
1592
2404
 
1593
2405
  AgentToolInputCRUD = TypeAliasType(
@@ -1607,10 +2419,11 @@ AgentToolInputCRUD = TypeAliasType(
1607
2419
  HTTPTool,
1608
2420
  CodeExecutionTool,
1609
2421
  FunctionTool,
2422
+ JSONSchemaTool,
1610
2423
  MCPTool,
1611
2424
  ],
1612
2425
  )
1613
- r"""Tool configuration for agent create/update operations. Built-in tools only require a type, while custom tools (HTTP, Code, Function, MCP) must reference pre-created tools by key or id."""
2426
+ r"""Tool configuration for agent create/update operations. Built-in tools only require a type, while custom tools (HTTP, Code, Function, JSON Schema, MCP) must reference pre-created tools by key or id."""
1614
2427
 
1615
2428
 
1616
2429
  CreateAgentRequestExecuteOn = Literal[
@@ -1639,6 +2452,22 @@ class CreateAgentRequestEvaluators(BaseModel):
1639
2452
  sample_rate: Optional[float] = 50
1640
2453
  r"""The percentage of executions to evaluate with this evaluator (1-100). For example, a value of 50 means the evaluator will run on approximately half of the executions."""
1641
2454
 
2455
+ @model_serializer(mode="wrap")
2456
+ def serialize_model(self, handler):
2457
+ optional_fields = set(["sample_rate"])
2458
+ serialized = handler(self)
2459
+ m = {}
2460
+
2461
+ for n, f in type(self).model_fields.items():
2462
+ k = f.alias or n
2463
+ val = serialized.get(k)
2464
+
2465
+ if val != UNSET_SENTINEL:
2466
+ if val is not None or k not in optional_fields:
2467
+ m[k] = val
2468
+
2469
+ return m
2470
+
1642
2471
 
1643
2472
  CreateAgentRequestAgentsExecuteOn = Literal[
1644
2473
  "input",
@@ -1666,6 +2495,22 @@ class CreateAgentRequestGuardrails(BaseModel):
1666
2495
  sample_rate: Optional[float] = 50
1667
2496
  r"""The percentage of executions to evaluate with this evaluator (1-100). For example, a value of 50 means the evaluator will run on approximately half of the executions."""
1668
2497
 
2498
+ @model_serializer(mode="wrap")
2499
+ def serialize_model(self, handler):
2500
+ optional_fields = set(["sample_rate"])
2501
+ serialized = handler(self)
2502
+ m = {}
2503
+
2504
+ for n, f in type(self).model_fields.items():
2505
+ k = f.alias or n
2506
+ val = serialized.get(k)
2507
+
2508
+ if val != UNSET_SENTINEL:
2509
+ if val is not None or k not in optional_fields:
2510
+ m[k] = val
2511
+
2512
+ return m
2513
+
1669
2514
 
1670
2515
  class CreateAgentRequestSettingsTypedDict(TypedDict):
1671
2516
  r"""Configuration settings for the agent's behavior"""
@@ -1707,6 +2552,31 @@ class CreateAgentRequestSettings(BaseModel):
1707
2552
  guardrails: Optional[List[CreateAgentRequestGuardrails]] = None
1708
2553
  r"""Configuration for a guardrail applied to the agent"""
1709
2554
 
2555
+ @model_serializer(mode="wrap")
2556
+ def serialize_model(self, handler):
2557
+ optional_fields = set(
2558
+ [
2559
+ "max_iterations",
2560
+ "max_execution_time",
2561
+ "tool_approval_required",
2562
+ "tools",
2563
+ "evaluators",
2564
+ "guardrails",
2565
+ ]
2566
+ )
2567
+ serialized = handler(self)
2568
+ m = {}
2569
+
2570
+ for n, f in type(self).model_fields.items():
2571
+ k = f.alias or n
2572
+ val = serialized.get(k)
2573
+
2574
+ if val != UNSET_SENTINEL:
2575
+ if val is not None or k not in optional_fields:
2576
+ m[k] = val
2577
+
2578
+ return m
2579
+
1710
2580
 
1711
2581
  class KnowledgeBasesTypedDict(TypedDict):
1712
2582
  knowledge_id: str
@@ -1732,6 +2602,22 @@ class TeamOfAgents(BaseModel):
1732
2602
  role: Optional[str] = None
1733
2603
  r"""The role of the agent in this context. This is used to give extra information to the leader to help it decide which agent to hand off to."""
1734
2604
 
2605
+ @model_serializer(mode="wrap")
2606
+ def serialize_model(self, handler):
2607
+ optional_fields = set(["role"])
2608
+ serialized = handler(self)
2609
+ m = {}
2610
+
2611
+ for n, f in type(self).model_fields.items():
2612
+ k = f.alias or n
2613
+ val = serialized.get(k)
2614
+
2615
+ if val != UNSET_SENTINEL:
2616
+ if val is not None or k not in optional_fields:
2617
+ m[k] = val
2618
+
2619
+ return m
2620
+
1735
2621
 
1736
2622
  Source = Literal[
1737
2623
  "internal",
@@ -1821,6 +2707,33 @@ class CreateAgentRequestRequestBody(BaseModel):
1821
2707
 
1822
2708
  source: Optional[Source] = None
1823
2709
 
2710
+ @model_serializer(mode="wrap")
2711
+ def serialize_model(self, handler):
2712
+ optional_fields = set(
2713
+ [
2714
+ "display_name",
2715
+ "system_prompt",
2716
+ "fallback_models",
2717
+ "memory_stores",
2718
+ "knowledge_bases",
2719
+ "team_of_agents",
2720
+ "variables",
2721
+ "source",
2722
+ ]
2723
+ )
2724
+ serialized = handler(self)
2725
+ m = {}
2726
+
2727
+ for n, f in type(self).model_fields.items():
2728
+ k = f.alias or n
2729
+ val = serialized.get(k)
2730
+
2731
+ if val != UNSET_SENTINEL:
2732
+ if val is not None or k not in optional_fields:
2733
+ m[k] = val
2734
+
2735
+ return m
2736
+
1824
2737
 
1825
2738
  CreateAgentRequestStatus = Literal[
1826
2739
  "live",
@@ -1900,6 +2813,32 @@ class CreateAgentRequestTools(BaseModel):
1900
2813
  timeout: Optional[float] = 120
1901
2814
  r"""Tool execution timeout in seconds (default: 2 minutes, max: 10 minutes)"""
1902
2815
 
2816
+ @model_serializer(mode="wrap")
2817
+ def serialize_model(self, handler):
2818
+ optional_fields = set(
2819
+ [
2820
+ "key",
2821
+ "display_name",
2822
+ "description",
2823
+ "requires_approval",
2824
+ "tool_id",
2825
+ "conditions",
2826
+ "timeout",
2827
+ ]
2828
+ )
2829
+ serialized = handler(self)
2830
+ m = {}
2831
+
2832
+ for n, f in type(self).model_fields.items():
2833
+ k = f.alias or n
2834
+ val = serialized.get(k)
2835
+
2836
+ if val != UNSET_SENTINEL:
2837
+ if val is not None or k not in optional_fields:
2838
+ m[k] = val
2839
+
2840
+ return m
2841
+
1903
2842
 
1904
2843
  CreateAgentRequestAgentsResponseExecuteOn = Literal[
1905
2844
  "input",
@@ -1927,6 +2866,22 @@ class CreateAgentRequestAgentsEvaluators(BaseModel):
1927
2866
  sample_rate: Optional[float] = 50
1928
2867
  r"""The percentage of executions to evaluate with this evaluator (1-100). For example, a value of 50 means the evaluator will run on approximately half of the executions."""
1929
2868
 
2869
+ @model_serializer(mode="wrap")
2870
+ def serialize_model(self, handler):
2871
+ optional_fields = set(["sample_rate"])
2872
+ serialized = handler(self)
2873
+ m = {}
2874
+
2875
+ for n, f in type(self).model_fields.items():
2876
+ k = f.alias or n
2877
+ val = serialized.get(k)
2878
+
2879
+ if val != UNSET_SENTINEL:
2880
+ if val is not None or k not in optional_fields:
2881
+ m[k] = val
2882
+
2883
+ return m
2884
+
1930
2885
 
1931
2886
  CreateAgentRequestAgentsResponse201ExecuteOn = Literal[
1932
2887
  "input",
@@ -1954,6 +2909,22 @@ class CreateAgentRequestAgentsGuardrails(BaseModel):
1954
2909
  sample_rate: Optional[float] = 50
1955
2910
  r"""The percentage of executions to evaluate with this evaluator (1-100). For example, a value of 50 means the evaluator will run on approximately half of the executions."""
1956
2911
 
2912
+ @model_serializer(mode="wrap")
2913
+ def serialize_model(self, handler):
2914
+ optional_fields = set(["sample_rate"])
2915
+ serialized = handler(self)
2916
+ m = {}
2917
+
2918
+ for n, f in type(self).model_fields.items():
2919
+ k = f.alias or n
2920
+ val = serialized.get(k)
2921
+
2922
+ if val != UNSET_SENTINEL:
2923
+ if val is not None or k not in optional_fields:
2924
+ m[k] = val
2925
+
2926
+ return m
2927
+
1957
2928
 
1958
2929
  class CreateAgentRequestAgentsSettingsTypedDict(TypedDict):
1959
2930
  max_iterations: NotRequired[int]
@@ -1989,6 +2960,31 @@ class CreateAgentRequestAgentsSettings(BaseModel):
1989
2960
  guardrails: Optional[List[CreateAgentRequestAgentsGuardrails]] = None
1990
2961
  r"""Configuration for a guardrail applied to the agent"""
1991
2962
 
2963
+ @model_serializer(mode="wrap")
2964
+ def serialize_model(self, handler):
2965
+ optional_fields = set(
2966
+ [
2967
+ "max_iterations",
2968
+ "max_execution_time",
2969
+ "tool_approval_required",
2970
+ "tools",
2971
+ "evaluators",
2972
+ "guardrails",
2973
+ ]
2974
+ )
2975
+ serialized = handler(self)
2976
+ m = {}
2977
+
2978
+ for n, f in type(self).model_fields.items():
2979
+ k = f.alias or n
2980
+ val = serialized.get(k)
2981
+
2982
+ if val != UNSET_SENTINEL:
2983
+ if val is not None or k not in optional_fields:
2984
+ m[k] = val
2985
+
2986
+ return m
2987
+
1992
2988
 
1993
2989
  CreateAgentRequestVoice = Literal[
1994
2990
  "alloy",
@@ -2059,6 +3055,22 @@ class CreateAgentRequestResponseFormatAgentsResponseJSONSchema(BaseModel):
2059
3055
  strict: Optional[bool] = False
2060
3056
  r"""Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true."""
2061
3057
 
3058
+ @model_serializer(mode="wrap")
3059
+ def serialize_model(self, handler):
3060
+ optional_fields = set(["description", "schema", "strict"])
3061
+ serialized = handler(self)
3062
+ m = {}
3063
+
3064
+ for n, f in type(self).model_fields.items():
3065
+ k = f.alias or n
3066
+ val = serialized.get(k)
3067
+
3068
+ if val != UNSET_SENTINEL:
3069
+ if val is not None or k not in optional_fields:
3070
+ m[k] = val
3071
+
3072
+ return m
3073
+
2062
3074
 
2063
3075
  class CreateAgentRequestResponseFormatAgentsResponse201JSONSchemaTypedDict(TypedDict):
2064
3076
  r"""
@@ -2190,6 +3202,22 @@ class CreateAgentRequestStreamOptions(BaseModel):
2190
3202
  include_usage: Optional[bool] = None
2191
3203
  r"""If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value."""
2192
3204
 
3205
+ @model_serializer(mode="wrap")
3206
+ def serialize_model(self, handler):
3207
+ optional_fields = set(["include_usage"])
3208
+ serialized = handler(self)
3209
+ m = {}
3210
+
3211
+ for n, f in type(self).model_fields.items():
3212
+ k = f.alias or n
3213
+ val = serialized.get(k)
3214
+
3215
+ if val != UNSET_SENTINEL:
3216
+ if val is not None or k not in optional_fields:
3217
+ m[k] = val
3218
+
3219
+ return m
3220
+
2193
3221
 
2194
3222
  CreateAgentRequestThinkingTypedDict = TypeAliasType(
2195
3223
  "CreateAgentRequestThinkingTypedDict",
@@ -2232,6 +3260,22 @@ class CreateAgentRequestToolChoiceAgents2(BaseModel):
2232
3260
  type: Optional[CreateAgentRequestToolChoiceAgentsType] = None
2233
3261
  r"""The type of the tool. Currently, only function is supported."""
2234
3262
 
3263
+ @model_serializer(mode="wrap")
3264
+ def serialize_model(self, handler):
3265
+ optional_fields = set(["type"])
3266
+ serialized = handler(self)
3267
+ m = {}
3268
+
3269
+ for n, f in type(self).model_fields.items():
3270
+ k = f.alias or n
3271
+ val = serialized.get(k)
3272
+
3273
+ if val != UNSET_SENTINEL:
3274
+ if val is not None or k not in optional_fields:
3275
+ m[k] = val
3276
+
3277
+ return m
3278
+
2235
3279
 
2236
3280
  CreateAgentRequestToolChoiceAgents1 = Literal[
2237
3281
  "none",
@@ -2257,48 +3301,196 @@ CreateAgentRequestToolChoice = TypeAliasType(
2257
3301
  r"""Controls which (if any) tool is called by the model."""
2258
3302
 
2259
3303
 
2260
- CreateAgentRequestModalities = Literal[
2261
- "text",
2262
- "audio",
2263
- ]
3304
+ CreateAgentRequestModalities = Literal[
3305
+ "text",
3306
+ "audio",
3307
+ ]
3308
+
3309
+
3310
+ CreateAgentRequestIDAgents1 = Literal[
3311
+ "orq_pii_detection",
3312
+ "orq_sexual_moderation",
3313
+ "orq_harmful_moderation",
3314
+ ]
3315
+ r"""The key of the guardrail."""
3316
+
3317
+
3318
+ CreateAgentRequestIDTypedDict = TypeAliasType(
3319
+ "CreateAgentRequestIDTypedDict", Union[CreateAgentRequestIDAgents1, str]
3320
+ )
3321
+
3322
+
3323
+ CreateAgentRequestID = TypeAliasType(
3324
+ "CreateAgentRequestID", Union[CreateAgentRequestIDAgents1, str]
3325
+ )
3326
+
3327
+
3328
+ CreateAgentRequestAgentsResponse201ApplicationJSONExecuteOn = Literal[
3329
+ "input",
3330
+ "output",
3331
+ ]
3332
+ r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3333
+
3334
+
3335
+ class CreateAgentRequestAgentsResponseGuardrailsTypedDict(TypedDict):
3336
+ id: CreateAgentRequestIDTypedDict
3337
+ execute_on: CreateAgentRequestAgentsResponse201ApplicationJSONExecuteOn
3338
+ r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3339
+
3340
+
3341
+ class CreateAgentRequestAgentsResponseGuardrails(BaseModel):
3342
+ id: CreateAgentRequestID
3343
+
3344
+ execute_on: CreateAgentRequestAgentsResponse201ApplicationJSONExecuteOn
3345
+ r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3346
+
3347
+
3348
+ class CreateAgentRequestFallbacksTypedDict(TypedDict):
3349
+ model: str
3350
+ r"""Fallback model identifier"""
3351
+
3352
+
3353
+ class CreateAgentRequestFallbacks(BaseModel):
3354
+ model: str
3355
+ r"""Fallback model identifier"""
3356
+
3357
+
3358
+ class CreateAgentRequestAgentsRetryTypedDict(TypedDict):
3359
+ r"""Retry configuration for the request"""
3360
+
3361
+ count: NotRequired[float]
3362
+ r"""Number of retry attempts (1-5)"""
3363
+ on_codes: NotRequired[List[float]]
3364
+ r"""HTTP status codes that trigger retry logic"""
3365
+
3366
+
3367
+ class CreateAgentRequestAgentsRetry(BaseModel):
3368
+ r"""Retry configuration for the request"""
3369
+
3370
+ count: Optional[float] = 3
3371
+ r"""Number of retry attempts (1-5)"""
3372
+
3373
+ on_codes: Optional[List[float]] = None
3374
+ r"""HTTP status codes that trigger retry logic"""
3375
+
3376
+ @model_serializer(mode="wrap")
3377
+ def serialize_model(self, handler):
3378
+ optional_fields = set(["count", "on_codes"])
3379
+ serialized = handler(self)
3380
+ m = {}
3381
+
3382
+ for n, f in type(self).model_fields.items():
3383
+ k = f.alias or n
3384
+ val = serialized.get(k)
3385
+
3386
+ if val != UNSET_SENTINEL:
3387
+ if val is not None or k not in optional_fields:
3388
+ m[k] = val
3389
+
3390
+ return m
3391
+
3392
+
3393
+ CreateAgentRequestType = Literal["exact_match",]
3394
+
3395
+
3396
+ class CreateAgentRequestCacheTypedDict(TypedDict):
3397
+ r"""Cache configuration for the request."""
3398
+
3399
+ type: CreateAgentRequestType
3400
+ ttl: NotRequired[float]
3401
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
3402
+
3403
+
3404
+ class CreateAgentRequestCache(BaseModel):
3405
+ r"""Cache configuration for the request."""
3406
+
3407
+ type: CreateAgentRequestType
3408
+
3409
+ ttl: Optional[float] = 1800
3410
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
3411
+
3412
+ @model_serializer(mode="wrap")
3413
+ def serialize_model(self, handler):
3414
+ optional_fields = set(["ttl"])
3415
+ serialized = handler(self)
3416
+ m = {}
3417
+
3418
+ for n, f in type(self).model_fields.items():
3419
+ k = f.alias or n
3420
+ val = serialized.get(k)
3421
+
3422
+ if val != UNSET_SENTINEL:
3423
+ if val is not None or k not in optional_fields:
3424
+ m[k] = val
3425
+
3426
+ return m
3427
+
3428
+
3429
+ CreateAgentRequestLoadBalancerAgentsType = Literal["weight_based",]
3430
+
3431
+
3432
+ class CreateAgentRequestLoadBalancerAgentsModelsTypedDict(TypedDict):
3433
+ model: str
3434
+ r"""Model identifier for load balancing"""
3435
+ weight: NotRequired[float]
3436
+ r"""Weight assigned to this model for load balancing"""
3437
+
3438
+
3439
+ class CreateAgentRequestLoadBalancerAgentsModels(BaseModel):
3440
+ model: str
3441
+ r"""Model identifier for load balancing"""
3442
+
3443
+ weight: Optional[float] = 0.5
3444
+ r"""Weight assigned to this model for load balancing"""
3445
+
3446
+ @model_serializer(mode="wrap")
3447
+ def serialize_model(self, handler):
3448
+ optional_fields = set(["weight"])
3449
+ serialized = handler(self)
3450
+ m = {}
3451
+
3452
+ for n, f in type(self).model_fields.items():
3453
+ k = f.alias or n
3454
+ val = serialized.get(k)
3455
+
3456
+ if val != UNSET_SENTINEL:
3457
+ if val is not None or k not in optional_fields:
3458
+ m[k] = val
3459
+
3460
+ return m
2264
3461
 
2265
3462
 
2266
- CreateAgentRequestIDAgents1 = Literal[
2267
- "orq_pii_detection",
2268
- "orq_sexual_moderation",
2269
- "orq_harmful_moderation",
2270
- ]
2271
- r"""The key of the guardrail."""
3463
+ class CreateAgentRequestLoadBalancerAgents1TypedDict(TypedDict):
3464
+ type: CreateAgentRequestLoadBalancerAgentsType
3465
+ models: List[CreateAgentRequestLoadBalancerAgentsModelsTypedDict]
2272
3466
 
2273
3467
 
2274
- CreateAgentRequestIDTypedDict = TypeAliasType(
2275
- "CreateAgentRequestIDTypedDict", Union[CreateAgentRequestIDAgents1, str]
2276
- )
3468
+ class CreateAgentRequestLoadBalancerAgents1(BaseModel):
3469
+ type: CreateAgentRequestLoadBalancerAgentsType
2277
3470
 
3471
+ models: List[CreateAgentRequestLoadBalancerAgentsModels]
2278
3472
 
2279
- CreateAgentRequestID = TypeAliasType(
2280
- "CreateAgentRequestID", Union[CreateAgentRequestIDAgents1, str]
2281
- )
2282
3473
 
3474
+ CreateAgentRequestLoadBalancerTypedDict = CreateAgentRequestLoadBalancerAgents1TypedDict
3475
+ r"""Load balancer configuration for the request."""
2283
3476
 
2284
- CreateAgentRequestAgentsResponse201ApplicationJSONExecuteOn = Literal[
2285
- "input",
2286
- "output",
2287
- ]
2288
- r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
2289
3477
 
3478
+ CreateAgentRequestLoadBalancer = CreateAgentRequestLoadBalancerAgents1
3479
+ r"""Load balancer configuration for the request."""
2290
3480
 
2291
- class CreateAgentRequestAgentsResponseGuardrailsTypedDict(TypedDict):
2292
- id: CreateAgentRequestIDTypedDict
2293
- execute_on: CreateAgentRequestAgentsResponse201ApplicationJSONExecuteOn
2294
- r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
2295
3481
 
3482
+ class CreateAgentRequestTimeoutTypedDict(TypedDict):
3483
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
2296
3484
 
2297
- class CreateAgentRequestAgentsResponseGuardrails(BaseModel):
2298
- id: CreateAgentRequestID
3485
+ call_timeout: float
3486
+ r"""Timeout value in milliseconds"""
2299
3487
 
2300
- execute_on: CreateAgentRequestAgentsResponse201ApplicationJSONExecuteOn
2301
- r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3488
+
3489
+ class CreateAgentRequestTimeout(BaseModel):
3490
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
3491
+
3492
+ call_timeout: float
3493
+ r"""Timeout value in milliseconds"""
2302
3494
 
2303
3495
 
2304
3496
  class CreateAgentRequestParametersTypedDict(TypedDict):
@@ -2358,6 +3550,16 @@ class CreateAgentRequestParametersTypedDict(TypedDict):
2358
3550
  r"""Output types that you would like the model to generate. Most models are capable of generating text, which is the default: [\"text\"]. The gpt-4o-audio-preview model can also be used to generate audio. To request that this model generate both text and audio responses, you can use: [\"text\", \"audio\"]."""
2359
3551
  guardrails: NotRequired[List[CreateAgentRequestAgentsResponseGuardrailsTypedDict]]
2360
3552
  r"""A list of guardrails to apply to the request."""
3553
+ fallbacks: NotRequired[List[CreateAgentRequestFallbacksTypedDict]]
3554
+ r"""Array of fallback models to use if primary model fails"""
3555
+ retry: NotRequired[CreateAgentRequestAgentsRetryTypedDict]
3556
+ r"""Retry configuration for the request"""
3557
+ cache: NotRequired[CreateAgentRequestCacheTypedDict]
3558
+ r"""Cache configuration for the request."""
3559
+ load_balancer: NotRequired[CreateAgentRequestLoadBalancerTypedDict]
3560
+ r"""Load balancer configuration for the request."""
3561
+ timeout: NotRequired[CreateAgentRequestTimeoutTypedDict]
3562
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
2361
3563
 
2362
3564
 
2363
3565
  class CreateAgentRequestParameters(BaseModel):
@@ -2439,72 +3641,91 @@ class CreateAgentRequestParameters(BaseModel):
2439
3641
  guardrails: Optional[List[CreateAgentRequestAgentsResponseGuardrails]] = None
2440
3642
  r"""A list of guardrails to apply to the request."""
2441
3643
 
3644
+ fallbacks: Optional[List[CreateAgentRequestFallbacks]] = None
3645
+ r"""Array of fallback models to use if primary model fails"""
3646
+
3647
+ retry: Optional[CreateAgentRequestAgentsRetry] = None
3648
+ r"""Retry configuration for the request"""
3649
+
3650
+ cache: Optional[CreateAgentRequestCache] = None
3651
+ r"""Cache configuration for the request."""
3652
+
3653
+ load_balancer: Optional[CreateAgentRequestLoadBalancer] = None
3654
+ r"""Load balancer configuration for the request."""
3655
+
3656
+ timeout: Optional[CreateAgentRequestTimeout] = None
3657
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
3658
+
2442
3659
  @model_serializer(mode="wrap")
2443
3660
  def serialize_model(self, handler):
2444
- optional_fields = [
2445
- "audio",
2446
- "frequency_penalty",
2447
- "max_tokens",
2448
- "max_completion_tokens",
2449
- "logprobs",
2450
- "top_logprobs",
2451
- "n",
2452
- "presence_penalty",
2453
- "response_format",
2454
- "reasoning_effort",
2455
- "verbosity",
2456
- "seed",
2457
- "stop",
2458
- "stream_options",
2459
- "thinking",
2460
- "temperature",
2461
- "top_p",
2462
- "top_k",
2463
- "tool_choice",
2464
- "parallel_tool_calls",
2465
- "modalities",
2466
- "guardrails",
2467
- ]
2468
- nullable_fields = [
2469
- "audio",
2470
- "frequency_penalty",
2471
- "max_tokens",
2472
- "max_completion_tokens",
2473
- "logprobs",
2474
- "top_logprobs",
2475
- "n",
2476
- "presence_penalty",
2477
- "seed",
2478
- "stop",
2479
- "stream_options",
2480
- "temperature",
2481
- "top_p",
2482
- "top_k",
2483
- "modalities",
2484
- ]
2485
- null_default_fields = []
2486
-
3661
+ optional_fields = set(
3662
+ [
3663
+ "audio",
3664
+ "frequency_penalty",
3665
+ "max_tokens",
3666
+ "max_completion_tokens",
3667
+ "logprobs",
3668
+ "top_logprobs",
3669
+ "n",
3670
+ "presence_penalty",
3671
+ "response_format",
3672
+ "reasoning_effort",
3673
+ "verbosity",
3674
+ "seed",
3675
+ "stop",
3676
+ "stream_options",
3677
+ "thinking",
3678
+ "temperature",
3679
+ "top_p",
3680
+ "top_k",
3681
+ "tool_choice",
3682
+ "parallel_tool_calls",
3683
+ "modalities",
3684
+ "guardrails",
3685
+ "fallbacks",
3686
+ "retry",
3687
+ "cache",
3688
+ "load_balancer",
3689
+ "timeout",
3690
+ ]
3691
+ )
3692
+ nullable_fields = set(
3693
+ [
3694
+ "audio",
3695
+ "frequency_penalty",
3696
+ "max_tokens",
3697
+ "max_completion_tokens",
3698
+ "logprobs",
3699
+ "top_logprobs",
3700
+ "n",
3701
+ "presence_penalty",
3702
+ "seed",
3703
+ "stop",
3704
+ "stream_options",
3705
+ "temperature",
3706
+ "top_p",
3707
+ "top_k",
3708
+ "modalities",
3709
+ ]
3710
+ )
2487
3711
  serialized = handler(self)
2488
-
2489
3712
  m = {}
2490
3713
 
2491
3714
  for n, f in type(self).model_fields.items():
2492
3715
  k = f.alias or n
2493
3716
  val = serialized.get(k)
2494
- serialized.pop(k, None)
2495
-
2496
- optional_nullable = k in optional_fields and k in nullable_fields
2497
- is_set = (
2498
- self.__pydantic_fields_set__.intersection({n})
2499
- or k in null_default_fields
2500
- ) # pylint: disable=no-member
2501
-
2502
- if val is not None and val != UNSET_SENTINEL:
2503
- m[k] = val
2504
- elif val != UNSET_SENTINEL and (
2505
- not k in optional_fields or (optional_nullable and is_set)
2506
- ):
2507
- m[k] = val
3717
+ is_nullable_and_explicitly_set = (
3718
+ k in nullable_fields
3719
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
3720
+ )
3721
+
3722
+ if val != UNSET_SENTINEL:
3723
+ if (
3724
+ val is not None
3725
+ or k not in optional_fields
3726
+ or is_nullable_and_explicitly_set
3727
+ ):
3728
+ m[k] = val
2508
3729
 
2509
3730
  return m
2510
3731
 
@@ -2527,6 +3748,22 @@ class CreateAgentRequestRetry(BaseModel):
2527
3748
  on_codes: Optional[List[float]] = None
2528
3749
  r"""HTTP status codes that trigger retry logic"""
2529
3750
 
3751
+ @model_serializer(mode="wrap")
3752
+ def serialize_model(self, handler):
3753
+ optional_fields = set(["count", "on_codes"])
3754
+ serialized = handler(self)
3755
+ m = {}
3756
+
3757
+ for n, f in type(self).model_fields.items():
3758
+ k = f.alias or n
3759
+ val = serialized.get(k)
3760
+
3761
+ if val != UNSET_SENTINEL:
3762
+ if val is not None or k not in optional_fields:
3763
+ m[k] = val
3764
+
3765
+ return m
3766
+
2530
3767
 
2531
3768
  CreateAgentRequestFallbackModelConfigurationVoice = Literal[
2532
3769
  "alloy",
@@ -2604,6 +3841,22 @@ class CreateAgentRequestResponseFormatAgentsResponse201ApplicationJSONJSONSchema
2604
3841
  strict: Optional[bool] = False
2605
3842
  r"""Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true."""
2606
3843
 
3844
+ @model_serializer(mode="wrap")
3845
+ def serialize_model(self, handler):
3846
+ optional_fields = set(["description", "schema", "strict"])
3847
+ serialized = handler(self)
3848
+ m = {}
3849
+
3850
+ for n, f in type(self).model_fields.items():
3851
+ k = f.alias or n
3852
+ val = serialized.get(k)
3853
+
3854
+ if val != UNSET_SENTINEL:
3855
+ if val is not None or k not in optional_fields:
3856
+ m[k] = val
3857
+
3858
+ return m
3859
+
2607
3860
 
2608
3861
  class CreateAgentRequestResponseFormatAgentsResponse201ApplicationJSONResponseBodyJSONSchemaTypedDict(
2609
3862
  TypedDict
@@ -2751,6 +4004,22 @@ class CreateAgentRequestFallbackModelConfigurationStreamOptions(BaseModel):
2751
4004
  include_usage: Optional[bool] = None
2752
4005
  r"""If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value."""
2753
4006
 
4007
+ @model_serializer(mode="wrap")
4008
+ def serialize_model(self, handler):
4009
+ optional_fields = set(["include_usage"])
4010
+ serialized = handler(self)
4011
+ m = {}
4012
+
4013
+ for n, f in type(self).model_fields.items():
4014
+ k = f.alias or n
4015
+ val = serialized.get(k)
4016
+
4017
+ if val != UNSET_SENTINEL:
4018
+ if val is not None or k not in optional_fields:
4019
+ m[k] = val
4020
+
4021
+ return m
4022
+
2754
4023
 
2755
4024
  CreateAgentRequestFallbackModelConfigurationThinkingTypedDict = TypeAliasType(
2756
4025
  "CreateAgentRequestFallbackModelConfigurationThinkingTypedDict",
@@ -2793,6 +4062,22 @@ class CreateAgentRequestToolChoiceAgentsResponse2(BaseModel):
2793
4062
  type: Optional[CreateAgentRequestToolChoiceAgentsResponseType] = None
2794
4063
  r"""The type of the tool. Currently, only function is supported."""
2795
4064
 
4065
+ @model_serializer(mode="wrap")
4066
+ def serialize_model(self, handler):
4067
+ optional_fields = set(["type"])
4068
+ serialized = handler(self)
4069
+ m = {}
4070
+
4071
+ for n, f in type(self).model_fields.items():
4072
+ k = f.alias or n
4073
+ val = serialized.get(k)
4074
+
4075
+ if val != UNSET_SENTINEL:
4076
+ if val is not None or k not in optional_fields:
4077
+ m[k] = val
4078
+
4079
+ return m
4080
+
2796
4081
 
2797
4082
  CreateAgentRequestToolChoiceAgentsResponse1 = Literal[
2798
4083
  "none",
@@ -2867,6 +4152,160 @@ class CreateAgentRequestFallbackModelConfigurationGuardrails(BaseModel):
2867
4152
  r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
2868
4153
 
2869
4154
 
4155
+ class CreateAgentRequestFallbackModelConfigurationFallbacksTypedDict(TypedDict):
4156
+ model: str
4157
+ r"""Fallback model identifier"""
4158
+
4159
+
4160
+ class CreateAgentRequestFallbackModelConfigurationFallbacks(BaseModel):
4161
+ model: str
4162
+ r"""Fallback model identifier"""
4163
+
4164
+
4165
+ class CreateAgentRequestFallbackModelConfigurationAgentsResponseRetryTypedDict(
4166
+ TypedDict
4167
+ ):
4168
+ r"""Retry configuration for the request"""
4169
+
4170
+ count: NotRequired[float]
4171
+ r"""Number of retry attempts (1-5)"""
4172
+ on_codes: NotRequired[List[float]]
4173
+ r"""HTTP status codes that trigger retry logic"""
4174
+
4175
+
4176
+ class CreateAgentRequestFallbackModelConfigurationAgentsResponseRetry(BaseModel):
4177
+ r"""Retry configuration for the request"""
4178
+
4179
+ count: Optional[float] = 3
4180
+ r"""Number of retry attempts (1-5)"""
4181
+
4182
+ on_codes: Optional[List[float]] = None
4183
+ r"""HTTP status codes that trigger retry logic"""
4184
+
4185
+ @model_serializer(mode="wrap")
4186
+ def serialize_model(self, handler):
4187
+ optional_fields = set(["count", "on_codes"])
4188
+ serialized = handler(self)
4189
+ m = {}
4190
+
4191
+ for n, f in type(self).model_fields.items():
4192
+ k = f.alias or n
4193
+ val = serialized.get(k)
4194
+
4195
+ if val != UNSET_SENTINEL:
4196
+ if val is not None or k not in optional_fields:
4197
+ m[k] = val
4198
+
4199
+ return m
4200
+
4201
+
4202
+ CreateAgentRequestFallbackModelConfigurationType = Literal["exact_match",]
4203
+
4204
+
4205
+ class CreateAgentRequestFallbackModelConfigurationCacheTypedDict(TypedDict):
4206
+ r"""Cache configuration for the request."""
4207
+
4208
+ type: CreateAgentRequestFallbackModelConfigurationType
4209
+ ttl: NotRequired[float]
4210
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
4211
+
4212
+
4213
+ class CreateAgentRequestFallbackModelConfigurationCache(BaseModel):
4214
+ r"""Cache configuration for the request."""
4215
+
4216
+ type: CreateAgentRequestFallbackModelConfigurationType
4217
+
4218
+ ttl: Optional[float] = 1800
4219
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
4220
+
4221
+ @model_serializer(mode="wrap")
4222
+ def serialize_model(self, handler):
4223
+ optional_fields = set(["ttl"])
4224
+ serialized = handler(self)
4225
+ m = {}
4226
+
4227
+ for n, f in type(self).model_fields.items():
4228
+ k = f.alias or n
4229
+ val = serialized.get(k)
4230
+
4231
+ if val != UNSET_SENTINEL:
4232
+ if val is not None or k not in optional_fields:
4233
+ m[k] = val
4234
+
4235
+ return m
4236
+
4237
+
4238
+ CreateAgentRequestLoadBalancerAgentsResponseType = Literal["weight_based",]
4239
+
4240
+
4241
+ class CreateAgentRequestLoadBalancerAgentsResponseModelsTypedDict(TypedDict):
4242
+ model: str
4243
+ r"""Model identifier for load balancing"""
4244
+ weight: NotRequired[float]
4245
+ r"""Weight assigned to this model for load balancing"""
4246
+
4247
+
4248
+ class CreateAgentRequestLoadBalancerAgentsResponseModels(BaseModel):
4249
+ model: str
4250
+ r"""Model identifier for load balancing"""
4251
+
4252
+ weight: Optional[float] = 0.5
4253
+ r"""Weight assigned to this model for load balancing"""
4254
+
4255
+ @model_serializer(mode="wrap")
4256
+ def serialize_model(self, handler):
4257
+ optional_fields = set(["weight"])
4258
+ serialized = handler(self)
4259
+ m = {}
4260
+
4261
+ for n, f in type(self).model_fields.items():
4262
+ k = f.alias or n
4263
+ val = serialized.get(k)
4264
+
4265
+ if val != UNSET_SENTINEL:
4266
+ if val is not None or k not in optional_fields:
4267
+ m[k] = val
4268
+
4269
+ return m
4270
+
4271
+
4272
+ class CreateAgentRequestLoadBalancerAgentsResponse1TypedDict(TypedDict):
4273
+ type: CreateAgentRequestLoadBalancerAgentsResponseType
4274
+ models: List[CreateAgentRequestLoadBalancerAgentsResponseModelsTypedDict]
4275
+
4276
+
4277
+ class CreateAgentRequestLoadBalancerAgentsResponse1(BaseModel):
4278
+ type: CreateAgentRequestLoadBalancerAgentsResponseType
4279
+
4280
+ models: List[CreateAgentRequestLoadBalancerAgentsResponseModels]
4281
+
4282
+
4283
+ CreateAgentRequestFallbackModelConfigurationLoadBalancerTypedDict = (
4284
+ CreateAgentRequestLoadBalancerAgentsResponse1TypedDict
4285
+ )
4286
+ r"""Load balancer configuration for the request."""
4287
+
4288
+
4289
+ CreateAgentRequestFallbackModelConfigurationLoadBalancer = (
4290
+ CreateAgentRequestLoadBalancerAgentsResponse1
4291
+ )
4292
+ r"""Load balancer configuration for the request."""
4293
+
4294
+
4295
+ class CreateAgentRequestFallbackModelConfigurationTimeoutTypedDict(TypedDict):
4296
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
4297
+
4298
+ call_timeout: float
4299
+ r"""Timeout value in milliseconds"""
4300
+
4301
+
4302
+ class CreateAgentRequestFallbackModelConfigurationTimeout(BaseModel):
4303
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
4304
+
4305
+ call_timeout: float
4306
+ r"""Timeout value in milliseconds"""
4307
+
4308
+
2870
4309
  class CreateAgentRequestFallbackModelConfigurationParametersTypedDict(TypedDict):
2871
4310
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
2872
4311
 
@@ -2940,6 +4379,22 @@ class CreateAgentRequestFallbackModelConfigurationParametersTypedDict(TypedDict)
2940
4379
  List[CreateAgentRequestFallbackModelConfigurationGuardrailsTypedDict]
2941
4380
  ]
2942
4381
  r"""A list of guardrails to apply to the request."""
4382
+ fallbacks: NotRequired[
4383
+ List[CreateAgentRequestFallbackModelConfigurationFallbacksTypedDict]
4384
+ ]
4385
+ r"""Array of fallback models to use if primary model fails"""
4386
+ retry: NotRequired[
4387
+ CreateAgentRequestFallbackModelConfigurationAgentsResponseRetryTypedDict
4388
+ ]
4389
+ r"""Retry configuration for the request"""
4390
+ cache: NotRequired[CreateAgentRequestFallbackModelConfigurationCacheTypedDict]
4391
+ r"""Cache configuration for the request."""
4392
+ load_balancer: NotRequired[
4393
+ CreateAgentRequestFallbackModelConfigurationLoadBalancerTypedDict
4394
+ ]
4395
+ r"""Load balancer configuration for the request."""
4396
+ timeout: NotRequired[CreateAgentRequestFallbackModelConfigurationTimeoutTypedDict]
4397
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
2943
4398
 
2944
4399
 
2945
4400
  class CreateAgentRequestFallbackModelConfigurationParameters(BaseModel):
@@ -3031,77 +4486,102 @@ class CreateAgentRequestFallbackModelConfigurationParameters(BaseModel):
3031
4486
  ] = None
3032
4487
  r"""A list of guardrails to apply to the request."""
3033
4488
 
4489
+ fallbacks: Optional[List[CreateAgentRequestFallbackModelConfigurationFallbacks]] = (
4490
+ None
4491
+ )
4492
+ r"""Array of fallback models to use if primary model fails"""
4493
+
4494
+ retry: Optional[CreateAgentRequestFallbackModelConfigurationAgentsResponseRetry] = (
4495
+ None
4496
+ )
4497
+ r"""Retry configuration for the request"""
4498
+
4499
+ cache: Optional[CreateAgentRequestFallbackModelConfigurationCache] = None
4500
+ r"""Cache configuration for the request."""
4501
+
4502
+ load_balancer: Optional[
4503
+ CreateAgentRequestFallbackModelConfigurationLoadBalancer
4504
+ ] = None
4505
+ r"""Load balancer configuration for the request."""
4506
+
4507
+ timeout: Optional[CreateAgentRequestFallbackModelConfigurationTimeout] = None
4508
+ r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
4509
+
3034
4510
  @model_serializer(mode="wrap")
3035
4511
  def serialize_model(self, handler):
3036
- optional_fields = [
3037
- "audio",
3038
- "frequency_penalty",
3039
- "max_tokens",
3040
- "max_completion_tokens",
3041
- "logprobs",
3042
- "top_logprobs",
3043
- "n",
3044
- "presence_penalty",
3045
- "response_format",
3046
- "reasoning_effort",
3047
- "verbosity",
3048
- "seed",
3049
- "stop",
3050
- "stream_options",
3051
- "thinking",
3052
- "temperature",
3053
- "top_p",
3054
- "top_k",
3055
- "tool_choice",
3056
- "parallel_tool_calls",
3057
- "modalities",
3058
- "guardrails",
3059
- ]
3060
- nullable_fields = [
3061
- "audio",
3062
- "frequency_penalty",
3063
- "max_tokens",
3064
- "max_completion_tokens",
3065
- "logprobs",
3066
- "top_logprobs",
3067
- "n",
3068
- "presence_penalty",
3069
- "seed",
3070
- "stop",
3071
- "stream_options",
3072
- "temperature",
3073
- "top_p",
3074
- "top_k",
3075
- "modalities",
3076
- ]
3077
- null_default_fields = []
3078
-
4512
+ optional_fields = set(
4513
+ [
4514
+ "audio",
4515
+ "frequency_penalty",
4516
+ "max_tokens",
4517
+ "max_completion_tokens",
4518
+ "logprobs",
4519
+ "top_logprobs",
4520
+ "n",
4521
+ "presence_penalty",
4522
+ "response_format",
4523
+ "reasoning_effort",
4524
+ "verbosity",
4525
+ "seed",
4526
+ "stop",
4527
+ "stream_options",
4528
+ "thinking",
4529
+ "temperature",
4530
+ "top_p",
4531
+ "top_k",
4532
+ "tool_choice",
4533
+ "parallel_tool_calls",
4534
+ "modalities",
4535
+ "guardrails",
4536
+ "fallbacks",
4537
+ "retry",
4538
+ "cache",
4539
+ "load_balancer",
4540
+ "timeout",
4541
+ ]
4542
+ )
4543
+ nullable_fields = set(
4544
+ [
4545
+ "audio",
4546
+ "frequency_penalty",
4547
+ "max_tokens",
4548
+ "max_completion_tokens",
4549
+ "logprobs",
4550
+ "top_logprobs",
4551
+ "n",
4552
+ "presence_penalty",
4553
+ "seed",
4554
+ "stop",
4555
+ "stream_options",
4556
+ "temperature",
4557
+ "top_p",
4558
+ "top_k",
4559
+ "modalities",
4560
+ ]
4561
+ )
3079
4562
  serialized = handler(self)
3080
-
3081
4563
  m = {}
3082
4564
 
3083
4565
  for n, f in type(self).model_fields.items():
3084
4566
  k = f.alias or n
3085
4567
  val = serialized.get(k)
3086
- serialized.pop(k, None)
3087
-
3088
- optional_nullable = k in optional_fields and k in nullable_fields
3089
- is_set = (
3090
- self.__pydantic_fields_set__.intersection({n})
3091
- or k in null_default_fields
3092
- ) # pylint: disable=no-member
3093
-
3094
- if val is not None and val != UNSET_SENTINEL:
3095
- m[k] = val
3096
- elif val != UNSET_SENTINEL and (
3097
- not k in optional_fields or (optional_nullable and is_set)
3098
- ):
3099
- m[k] = val
4568
+ is_nullable_and_explicitly_set = (
4569
+ k in nullable_fields
4570
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
4571
+ )
4572
+
4573
+ if val != UNSET_SENTINEL:
4574
+ if (
4575
+ val is not None
4576
+ or k not in optional_fields
4577
+ or is_nullable_and_explicitly_set
4578
+ ):
4579
+ m[k] = val
3100
4580
 
3101
4581
  return m
3102
4582
 
3103
4583
 
3104
- class CreateAgentRequestFallbackModelConfigurationRetryTypedDict(TypedDict):
4584
+ class CreateAgentRequestFallbackModelConfigurationAgentsRetryTypedDict(TypedDict):
3105
4585
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3106
4586
 
3107
4587
  count: NotRequired[float]
@@ -3110,7 +4590,7 @@ class CreateAgentRequestFallbackModelConfigurationRetryTypedDict(TypedDict):
3110
4590
  r"""HTTP status codes that trigger retry logic"""
3111
4591
 
3112
4592
 
3113
- class CreateAgentRequestFallbackModelConfigurationRetry(BaseModel):
4593
+ class CreateAgentRequestFallbackModelConfigurationAgentsRetry(BaseModel):
3114
4594
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3115
4595
 
3116
4596
  count: Optional[float] = 3
@@ -3119,6 +4599,22 @@ class CreateAgentRequestFallbackModelConfigurationRetry(BaseModel):
3119
4599
  on_codes: Optional[List[float]] = None
3120
4600
  r"""HTTP status codes that trigger retry logic"""
3121
4601
 
4602
+ @model_serializer(mode="wrap")
4603
+ def serialize_model(self, handler):
4604
+ optional_fields = set(["count", "on_codes"])
4605
+ serialized = handler(self)
4606
+ m = {}
4607
+
4608
+ for n, f in type(self).model_fields.items():
4609
+ k = f.alias or n
4610
+ val = serialized.get(k)
4611
+
4612
+ if val != UNSET_SENTINEL:
4613
+ if val is not None or k not in optional_fields:
4614
+ m[k] = val
4615
+
4616
+ return m
4617
+
3122
4618
 
3123
4619
  class CreateAgentRequestFallbackModelConfiguration2TypedDict(TypedDict):
3124
4620
  r"""Fallback model configuration with optional parameters and retry settings."""
@@ -3129,7 +4625,7 @@ class CreateAgentRequestFallbackModelConfiguration2TypedDict(TypedDict):
3129
4625
  CreateAgentRequestFallbackModelConfigurationParametersTypedDict
3130
4626
  ]
3131
4627
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
3132
- retry: NotRequired[CreateAgentRequestFallbackModelConfigurationRetryTypedDict]
4628
+ retry: NotRequired[CreateAgentRequestFallbackModelConfigurationAgentsRetryTypedDict]
3133
4629
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3134
4630
 
3135
4631
 
@@ -3142,9 +4638,25 @@ class CreateAgentRequestFallbackModelConfiguration2(BaseModel):
3142
4638
  parameters: Optional[CreateAgentRequestFallbackModelConfigurationParameters] = None
3143
4639
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
3144
4640
 
3145
- retry: Optional[CreateAgentRequestFallbackModelConfigurationRetry] = None
4641
+ retry: Optional[CreateAgentRequestFallbackModelConfigurationAgentsRetry] = None
3146
4642
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3147
4643
 
4644
+ @model_serializer(mode="wrap")
4645
+ def serialize_model(self, handler):
4646
+ optional_fields = set(["parameters", "retry"])
4647
+ serialized = handler(self)
4648
+ m = {}
4649
+
4650
+ for n, f in type(self).model_fields.items():
4651
+ k = f.alias or n
4652
+ val = serialized.get(k)
4653
+
4654
+ if val != UNSET_SENTINEL:
4655
+ if val is not None or k not in optional_fields:
4656
+ m[k] = val
4657
+
4658
+ return m
4659
+
3148
4660
 
3149
4661
  CreateAgentRequestFallbackModelConfigurationTypedDict = TypeAliasType(
3150
4662
  "CreateAgentRequestFallbackModelConfigurationTypedDict",
@@ -3195,31 +4707,28 @@ class Model(BaseModel):
3195
4707
 
3196
4708
  @model_serializer(mode="wrap")
3197
4709
  def serialize_model(self, handler):
3198
- optional_fields = ["integration_id", "parameters", "retry", "fallback_models"]
3199
- nullable_fields = ["integration_id", "fallback_models"]
3200
- null_default_fields = []
3201
-
4710
+ optional_fields = set(
4711
+ ["integration_id", "parameters", "retry", "fallback_models"]
4712
+ )
4713
+ nullable_fields = set(["integration_id", "fallback_models"])
3202
4714
  serialized = handler(self)
3203
-
3204
4715
  m = {}
3205
4716
 
3206
4717
  for n, f in type(self).model_fields.items():
3207
4718
  k = f.alias or n
3208
4719
  val = serialized.get(k)
3209
- serialized.pop(k, None)
3210
-
3211
- optional_nullable = k in optional_fields and k in nullable_fields
3212
- is_set = (
3213
- self.__pydantic_fields_set__.intersection({n})
3214
- or k in null_default_fields
3215
- ) # pylint: disable=no-member
3216
-
3217
- if val is not None and val != UNSET_SENTINEL:
3218
- m[k] = val
3219
- elif val != UNSET_SENTINEL and (
3220
- not k in optional_fields or (optional_nullable and is_set)
3221
- ):
3222
- m[k] = val
4720
+ is_nullable_and_explicitly_set = (
4721
+ k in nullable_fields
4722
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
4723
+ )
4724
+
4725
+ if val != UNSET_SENTINEL:
4726
+ if (
4727
+ val is not None
4728
+ or k not in optional_fields
4729
+ or is_nullable_and_explicitly_set
4730
+ ):
4731
+ m[k] = val
3223
4732
 
3224
4733
  return m
3225
4734
 
@@ -3238,6 +4747,22 @@ class CreateAgentRequestTeamOfAgents(BaseModel):
3238
4747
  role: Optional[str] = None
3239
4748
  r"""The role of the agent in this context. This is used to give extra information to the leader to help it decide which agent to hand off to."""
3240
4749
 
4750
+ @model_serializer(mode="wrap")
4751
+ def serialize_model(self, handler):
4752
+ optional_fields = set(["role"])
4753
+ serialized = handler(self)
4754
+ m = {}
4755
+
4756
+ for n, f in type(self).model_fields.items():
4757
+ k = f.alias or n
4758
+ val = serialized.get(k)
4759
+
4760
+ if val != UNSET_SENTINEL:
4761
+ if val is not None or k not in optional_fields:
4762
+ m[k] = val
4763
+
4764
+ return m
4765
+
3241
4766
 
3242
4767
  class CreateAgentRequestMetricsTypedDict(TypedDict):
3243
4768
  total_cost: NotRequired[float]
@@ -3246,6 +4771,22 @@ class CreateAgentRequestMetricsTypedDict(TypedDict):
3246
4771
  class CreateAgentRequestMetrics(BaseModel):
3247
4772
  total_cost: Optional[float] = 0
3248
4773
 
4774
+ @model_serializer(mode="wrap")
4775
+ def serialize_model(self, handler):
4776
+ optional_fields = set(["total_cost"])
4777
+ serialized = handler(self)
4778
+ m = {}
4779
+
4780
+ for n, f in type(self).model_fields.items():
4781
+ k = f.alias or n
4782
+ val = serialized.get(k)
4783
+
4784
+ if val != UNSET_SENTINEL:
4785
+ if val is not None or k not in optional_fields:
4786
+ m[k] = val
4787
+
4788
+ return m
4789
+
3249
4790
 
3250
4791
  class CreateAgentRequestKnowledgeBasesTypedDict(TypedDict):
3251
4792
  knowledge_id: str
@@ -3367,42 +4908,39 @@ class CreateAgentRequestResponseBody(BaseModel):
3367
4908
 
3368
4909
  @model_serializer(mode="wrap")
3369
4910
  def serialize_model(self, handler):
3370
- optional_fields = [
3371
- "created_by_id",
3372
- "updated_by_id",
3373
- "created",
3374
- "updated",
3375
- "system_prompt",
3376
- "settings",
3377
- "version_hash",
3378
- "metrics",
3379
- "variables",
3380
- "knowledge_bases",
3381
- "source",
3382
- ]
3383
- nullable_fields = ["created_by_id", "updated_by_id"]
3384
- null_default_fields = []
3385
-
4911
+ optional_fields = set(
4912
+ [
4913
+ "created_by_id",
4914
+ "updated_by_id",
4915
+ "created",
4916
+ "updated",
4917
+ "system_prompt",
4918
+ "settings",
4919
+ "version_hash",
4920
+ "metrics",
4921
+ "variables",
4922
+ "knowledge_bases",
4923
+ "source",
4924
+ ]
4925
+ )
4926
+ nullable_fields = set(["created_by_id", "updated_by_id"])
3386
4927
  serialized = handler(self)
3387
-
3388
4928
  m = {}
3389
4929
 
3390
4930
  for n, f in type(self).model_fields.items():
3391
4931
  k = f.alias or n
3392
4932
  val = serialized.get(k)
3393
- serialized.pop(k, None)
3394
-
3395
- optional_nullable = k in optional_fields and k in nullable_fields
3396
- is_set = (
3397
- self.__pydantic_fields_set__.intersection({n})
3398
- or k in null_default_fields
3399
- ) # pylint: disable=no-member
3400
-
3401
- if val is not None and val != UNSET_SENTINEL:
3402
- m[k] = val
3403
- elif val != UNSET_SENTINEL and (
3404
- not k in optional_fields or (optional_nullable and is_set)
3405
- ):
3406
- m[k] = val
4933
+ is_nullable_and_explicitly_set = (
4934
+ k in nullable_fields
4935
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
4936
+ )
4937
+
4938
+ if val != UNSET_SENTINEL:
4939
+ if (
4940
+ val is not None
4941
+ or k not in optional_fields
4942
+ or is_nullable_and_explicitly_set
4943
+ ):
4944
+ m[k] = val
3407
4945
 
3408
4946
  return m