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
@@ -100,6 +100,22 @@ class UpdateAgentResponseFormatAgentsJSONSchema(BaseModel):
100
100
  strict: Optional[bool] = False
101
101
  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."""
102
102
 
103
+ @model_serializer(mode="wrap")
104
+ def serialize_model(self, handler):
105
+ optional_fields = set(["description", "schema", "strict"])
106
+ serialized = handler(self)
107
+ m = {}
108
+
109
+ for n, f in type(self).model_fields.items():
110
+ k = f.alias or n
111
+ val = serialized.get(k)
112
+
113
+ if val != UNSET_SENTINEL:
114
+ if val is not None or k not in optional_fields:
115
+ m[k] = val
116
+
117
+ return m
118
+
103
119
 
104
120
  class UpdateAgentResponseFormatJSONSchemaTypedDict(TypedDict):
105
121
  r"""
@@ -228,6 +244,22 @@ class ModelConfigurationStreamOptions(BaseModel):
228
244
  include_usage: Optional[bool] = None
229
245
  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."""
230
246
 
247
+ @model_serializer(mode="wrap")
248
+ def serialize_model(self, handler):
249
+ optional_fields = set(["include_usage"])
250
+ serialized = handler(self)
251
+ m = {}
252
+
253
+ for n, f in type(self).model_fields.items():
254
+ k = f.alias or n
255
+ val = serialized.get(k)
256
+
257
+ if val != UNSET_SENTINEL:
258
+ if val is not None or k not in optional_fields:
259
+ m[k] = val
260
+
261
+ return m
262
+
231
263
 
232
264
  ModelConfigurationThinkingTypedDict = TypeAliasType(
233
265
  "ModelConfigurationThinkingTypedDict",
@@ -270,6 +302,22 @@ class UpdateAgentToolChoice2(BaseModel):
270
302
  type: Optional[UpdateAgentToolChoiceType] = None
271
303
  r"""The type of the tool. Currently, only function is supported."""
272
304
 
305
+ @model_serializer(mode="wrap")
306
+ def serialize_model(self, handler):
307
+ optional_fields = set(["type"])
308
+ serialized = handler(self)
309
+ m = {}
310
+
311
+ for n, f in type(self).model_fields.items():
312
+ k = f.alias or n
313
+ val = serialized.get(k)
314
+
315
+ if val != UNSET_SENTINEL:
316
+ if val is not None or k not in optional_fields:
317
+ m[k] = val
318
+
319
+ return m
320
+
273
321
 
274
322
  UpdateAgentToolChoice1 = Literal[
275
323
  "none",
@@ -334,6 +382,154 @@ class ModelConfigurationGuardrails(BaseModel):
334
382
  r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
335
383
 
336
384
 
385
+ class ModelConfigurationFallbacksTypedDict(TypedDict):
386
+ model: str
387
+ r"""Fallback model identifier"""
388
+
389
+
390
+ class ModelConfigurationFallbacks(BaseModel):
391
+ model: str
392
+ r"""Fallback model identifier"""
393
+
394
+
395
+ class UpdateAgentModelConfigurationRetryTypedDict(TypedDict):
396
+ r"""Retry configuration for the request"""
397
+
398
+ count: NotRequired[float]
399
+ r"""Number of retry attempts (1-5)"""
400
+ on_codes: NotRequired[List[float]]
401
+ r"""HTTP status codes that trigger retry logic"""
402
+
403
+
404
+ class UpdateAgentModelConfigurationRetry(BaseModel):
405
+ r"""Retry configuration for the request"""
406
+
407
+ count: Optional[float] = 3
408
+ r"""Number of retry attempts (1-5)"""
409
+
410
+ on_codes: Optional[List[float]] = None
411
+ r"""HTTP status codes that trigger retry logic"""
412
+
413
+ @model_serializer(mode="wrap")
414
+ def serialize_model(self, handler):
415
+ optional_fields = set(["count", "on_codes"])
416
+ serialized = handler(self)
417
+ m = {}
418
+
419
+ for n, f in type(self).model_fields.items():
420
+ k = f.alias or n
421
+ val = serialized.get(k)
422
+
423
+ if val != UNSET_SENTINEL:
424
+ if val is not None or k not in optional_fields:
425
+ m[k] = val
426
+
427
+ return m
428
+
429
+
430
+ UpdateAgentModelConfigurationType = Literal["exact_match",]
431
+
432
+
433
+ class ModelConfigurationCacheTypedDict(TypedDict):
434
+ r"""Cache configuration for the request."""
435
+
436
+ type: UpdateAgentModelConfigurationType
437
+ ttl: NotRequired[float]
438
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
439
+
440
+
441
+ class ModelConfigurationCache(BaseModel):
442
+ r"""Cache configuration for the request."""
443
+
444
+ type: UpdateAgentModelConfigurationType
445
+
446
+ ttl: Optional[float] = 1800
447
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
448
+
449
+ @model_serializer(mode="wrap")
450
+ def serialize_model(self, handler):
451
+ optional_fields = set(["ttl"])
452
+ serialized = handler(self)
453
+ m = {}
454
+
455
+ for n, f in type(self).model_fields.items():
456
+ k = f.alias or n
457
+ val = serialized.get(k)
458
+
459
+ if val != UNSET_SENTINEL:
460
+ if val is not None or k not in optional_fields:
461
+ m[k] = val
462
+
463
+ return m
464
+
465
+
466
+ UpdateAgentLoadBalancerType = Literal["weight_based",]
467
+
468
+
469
+ class UpdateAgentLoadBalancerModelsTypedDict(TypedDict):
470
+ model: str
471
+ r"""Model identifier for load balancing"""
472
+ weight: NotRequired[float]
473
+ r"""Weight assigned to this model for load balancing"""
474
+
475
+
476
+ class UpdateAgentLoadBalancerModels(BaseModel):
477
+ model: str
478
+ r"""Model identifier for load balancing"""
479
+
480
+ weight: Optional[float] = 0.5
481
+ r"""Weight assigned to this model for load balancing"""
482
+
483
+ @model_serializer(mode="wrap")
484
+ def serialize_model(self, handler):
485
+ optional_fields = set(["weight"])
486
+ serialized = handler(self)
487
+ m = {}
488
+
489
+ for n, f in type(self).model_fields.items():
490
+ k = f.alias or n
491
+ val = serialized.get(k)
492
+
493
+ if val != UNSET_SENTINEL:
494
+ if val is not None or k not in optional_fields:
495
+ m[k] = val
496
+
497
+ return m
498
+
499
+
500
+ class UpdateAgentLoadBalancer1TypedDict(TypedDict):
501
+ type: UpdateAgentLoadBalancerType
502
+ models: List[UpdateAgentLoadBalancerModelsTypedDict]
503
+
504
+
505
+ class UpdateAgentLoadBalancer1(BaseModel):
506
+ type: UpdateAgentLoadBalancerType
507
+
508
+ models: List[UpdateAgentLoadBalancerModels]
509
+
510
+
511
+ ModelConfigurationLoadBalancerTypedDict = UpdateAgentLoadBalancer1TypedDict
512
+ r"""Load balancer configuration for the request."""
513
+
514
+
515
+ ModelConfigurationLoadBalancer = UpdateAgentLoadBalancer1
516
+ r"""Load balancer configuration for the request."""
517
+
518
+
519
+ class ModelConfigurationTimeoutTypedDict(TypedDict):
520
+ 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."""
521
+
522
+ call_timeout: float
523
+ r"""Timeout value in milliseconds"""
524
+
525
+
526
+ class ModelConfigurationTimeout(BaseModel):
527
+ 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."""
528
+
529
+ call_timeout: float
530
+ r"""Timeout value in milliseconds"""
531
+
532
+
337
533
  class ModelConfigurationParametersTypedDict(TypedDict):
338
534
  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."""
339
535
 
@@ -391,6 +587,16 @@ class ModelConfigurationParametersTypedDict(TypedDict):
391
587
  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\"]."""
392
588
  guardrails: NotRequired[List[ModelConfigurationGuardrailsTypedDict]]
393
589
  r"""A list of guardrails to apply to the request."""
590
+ fallbacks: NotRequired[List[ModelConfigurationFallbacksTypedDict]]
591
+ r"""Array of fallback models to use if primary model fails"""
592
+ retry: NotRequired[UpdateAgentModelConfigurationRetryTypedDict]
593
+ r"""Retry configuration for the request"""
594
+ cache: NotRequired[ModelConfigurationCacheTypedDict]
595
+ r"""Cache configuration for the request."""
596
+ load_balancer: NotRequired[ModelConfigurationLoadBalancerTypedDict]
597
+ r"""Load balancer configuration for the request."""
598
+ timeout: NotRequired[ModelConfigurationTimeoutTypedDict]
599
+ 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."""
394
600
 
395
601
 
396
602
  class ModelConfigurationParameters(BaseModel):
@@ -472,77 +678,96 @@ class ModelConfigurationParameters(BaseModel):
472
678
  guardrails: Optional[List[ModelConfigurationGuardrails]] = None
473
679
  r"""A list of guardrails to apply to the request."""
474
680
 
681
+ fallbacks: Optional[List[ModelConfigurationFallbacks]] = None
682
+ r"""Array of fallback models to use if primary model fails"""
683
+
684
+ retry: Optional[UpdateAgentModelConfigurationRetry] = None
685
+ r"""Retry configuration for the request"""
686
+
687
+ cache: Optional[ModelConfigurationCache] = None
688
+ r"""Cache configuration for the request."""
689
+
690
+ load_balancer: Optional[ModelConfigurationLoadBalancer] = None
691
+ r"""Load balancer configuration for the request."""
692
+
693
+ timeout: Optional[ModelConfigurationTimeout] = None
694
+ 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."""
695
+
475
696
  @model_serializer(mode="wrap")
476
697
  def serialize_model(self, handler):
477
- optional_fields = [
478
- "audio",
479
- "frequency_penalty",
480
- "max_tokens",
481
- "max_completion_tokens",
482
- "logprobs",
483
- "top_logprobs",
484
- "n",
485
- "presence_penalty",
486
- "response_format",
487
- "reasoning_effort",
488
- "verbosity",
489
- "seed",
490
- "stop",
491
- "stream_options",
492
- "thinking",
493
- "temperature",
494
- "top_p",
495
- "top_k",
496
- "tool_choice",
497
- "parallel_tool_calls",
498
- "modalities",
499
- "guardrails",
500
- ]
501
- nullable_fields = [
502
- "audio",
503
- "frequency_penalty",
504
- "max_tokens",
505
- "max_completion_tokens",
506
- "logprobs",
507
- "top_logprobs",
508
- "n",
509
- "presence_penalty",
510
- "seed",
511
- "stop",
512
- "stream_options",
513
- "temperature",
514
- "top_p",
515
- "top_k",
516
- "modalities",
517
- ]
518
- null_default_fields = []
519
-
520
- serialized = handler(self)
521
-
522
- m = {}
523
-
524
- for n, f in type(self).model_fields.items():
525
- k = f.alias or n
526
- val = serialized.get(k)
527
- serialized.pop(k, None)
528
-
529
- optional_nullable = k in optional_fields and k in nullable_fields
530
- is_set = (
531
- self.__pydantic_fields_set__.intersection({n})
532
- or k in null_default_fields
533
- ) # pylint: disable=no-member
534
-
535
- if val is not None and val != UNSET_SENTINEL:
536
- m[k] = val
537
- elif val != UNSET_SENTINEL and (
538
- not k in optional_fields or (optional_nullable and is_set)
539
- ):
540
- m[k] = val
541
-
542
- return m
543
-
544
-
545
- class ModelConfigurationRetryTypedDict(TypedDict):
698
+ optional_fields = set(
699
+ [
700
+ "audio",
701
+ "frequency_penalty",
702
+ "max_tokens",
703
+ "max_completion_tokens",
704
+ "logprobs",
705
+ "top_logprobs",
706
+ "n",
707
+ "presence_penalty",
708
+ "response_format",
709
+ "reasoning_effort",
710
+ "verbosity",
711
+ "seed",
712
+ "stop",
713
+ "stream_options",
714
+ "thinking",
715
+ "temperature",
716
+ "top_p",
717
+ "top_k",
718
+ "tool_choice",
719
+ "parallel_tool_calls",
720
+ "modalities",
721
+ "guardrails",
722
+ "fallbacks",
723
+ "retry",
724
+ "cache",
725
+ "load_balancer",
726
+ "timeout",
727
+ ]
728
+ )
729
+ nullable_fields = set(
730
+ [
731
+ "audio",
732
+ "frequency_penalty",
733
+ "max_tokens",
734
+ "max_completion_tokens",
735
+ "logprobs",
736
+ "top_logprobs",
737
+ "n",
738
+ "presence_penalty",
739
+ "seed",
740
+ "stop",
741
+ "stream_options",
742
+ "temperature",
743
+ "top_p",
744
+ "top_k",
745
+ "modalities",
746
+ ]
747
+ )
748
+ serialized = handler(self)
749
+ m = {}
750
+
751
+ for n, f in type(self).model_fields.items():
752
+ k = f.alias or n
753
+ val = serialized.get(k)
754
+ is_nullable_and_explicitly_set = (
755
+ k in nullable_fields
756
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
757
+ )
758
+
759
+ if val != UNSET_SENTINEL:
760
+ if (
761
+ val is not None
762
+ or k not in optional_fields
763
+ or is_nullable_and_explicitly_set
764
+ ):
765
+ m[k] = val
766
+
767
+ return m
768
+
769
+
770
+ class UpdateAgentModelConfigurationAgentsRetryTypedDict(TypedDict):
546
771
  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."""
547
772
 
548
773
  count: NotRequired[float]
@@ -551,7 +776,7 @@ class ModelConfigurationRetryTypedDict(TypedDict):
551
776
  r"""HTTP status codes that trigger retry logic"""
552
777
 
553
778
 
554
- class ModelConfigurationRetry(BaseModel):
779
+ class UpdateAgentModelConfigurationAgentsRetry(BaseModel):
555
780
  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
781
 
557
782
  count: Optional[float] = 3
@@ -560,6 +785,22 @@ class ModelConfigurationRetry(BaseModel):
560
785
  on_codes: Optional[List[float]] = None
561
786
  r"""HTTP status codes that trigger retry logic"""
562
787
 
788
+ @model_serializer(mode="wrap")
789
+ def serialize_model(self, handler):
790
+ optional_fields = set(["count", "on_codes"])
791
+ serialized = handler(self)
792
+ m = {}
793
+
794
+ for n, f in type(self).model_fields.items():
795
+ k = f.alias or n
796
+ val = serialized.get(k)
797
+
798
+ if val != UNSET_SENTINEL:
799
+ if val is not None or k not in optional_fields:
800
+ m[k] = val
801
+
802
+ return m
803
+
563
804
 
564
805
  class UpdateAgentModelConfiguration2TypedDict(TypedDict):
565
806
  r"""
@@ -571,7 +812,7 @@ class UpdateAgentModelConfiguration2TypedDict(TypedDict):
571
812
  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."""
572
813
  parameters: NotRequired[ModelConfigurationParametersTypedDict]
573
814
  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."""
574
- retry: NotRequired[ModelConfigurationRetryTypedDict]
815
+ retry: NotRequired[UpdateAgentModelConfigurationAgentsRetryTypedDict]
575
816
  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."""
576
817
 
577
818
 
@@ -587,9 +828,25 @@ class UpdateAgentModelConfiguration2(BaseModel):
587
828
  parameters: Optional[ModelConfigurationParameters] = None
588
829
  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."""
589
830
 
590
- retry: Optional[ModelConfigurationRetry] = None
831
+ retry: Optional[UpdateAgentModelConfigurationAgentsRetry] = None
591
832
  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."""
592
833
 
834
+ @model_serializer(mode="wrap")
835
+ def serialize_model(self, handler):
836
+ optional_fields = set(["parameters", "retry"])
837
+ serialized = handler(self)
838
+ m = {}
839
+
840
+ for n, f in type(self).model_fields.items():
841
+ k = f.alias or n
842
+ val = serialized.get(k)
843
+
844
+ if val != UNSET_SENTINEL:
845
+ if val is not None or k not in optional_fields:
846
+ m[k] = val
847
+
848
+ return m
849
+
593
850
 
594
851
  UpdateAgentModelConfigurationTypedDict = TypeAliasType(
595
852
  "UpdateAgentModelConfigurationTypedDict",
@@ -675,6 +932,22 @@ class UpdateAgentResponseFormatAgentsRequestRequestBodyJSONSchema(BaseModel):
675
932
  strict: Optional[bool] = False
676
933
  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."""
677
934
 
935
+ @model_serializer(mode="wrap")
936
+ def serialize_model(self, handler):
937
+ optional_fields = set(["description", "schema", "strict"])
938
+ serialized = handler(self)
939
+ m = {}
940
+
941
+ for n, f in type(self).model_fields.items():
942
+ k = f.alias or n
943
+ val = serialized.get(k)
944
+
945
+ if val != UNSET_SENTINEL:
946
+ if val is not None or k not in optional_fields:
947
+ m[k] = val
948
+
949
+ return m
950
+
678
951
 
679
952
  class UpdateAgentResponseFormatAgentsRequestJSONSchemaTypedDict(TypedDict):
680
953
  r"""
@@ -807,6 +1080,22 @@ class UpdateAgentFallbackModelConfigurationStreamOptions(BaseModel):
807
1080
  include_usage: Optional[bool] = None
808
1081
  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."""
809
1082
 
1083
+ @model_serializer(mode="wrap")
1084
+ def serialize_model(self, handler):
1085
+ optional_fields = set(["include_usage"])
1086
+ serialized = handler(self)
1087
+ m = {}
1088
+
1089
+ for n, f in type(self).model_fields.items():
1090
+ k = f.alias or n
1091
+ val = serialized.get(k)
1092
+
1093
+ if val != UNSET_SENTINEL:
1094
+ if val is not None or k not in optional_fields:
1095
+ m[k] = val
1096
+
1097
+ return m
1098
+
810
1099
 
811
1100
  UpdateAgentFallbackModelConfigurationThinkingTypedDict = TypeAliasType(
812
1101
  "UpdateAgentFallbackModelConfigurationThinkingTypedDict",
@@ -849,6 +1138,22 @@ class UpdateAgentToolChoiceAgents2(BaseModel):
849
1138
  type: Optional[UpdateAgentToolChoiceAgentsType] = None
850
1139
  r"""The type of the tool. Currently, only function is supported."""
851
1140
 
1141
+ @model_serializer(mode="wrap")
1142
+ def serialize_model(self, handler):
1143
+ optional_fields = set(["type"])
1144
+ serialized = handler(self)
1145
+ m = {}
1146
+
1147
+ for n, f in type(self).model_fields.items():
1148
+ k = f.alias or n
1149
+ val = serialized.get(k)
1150
+
1151
+ if val != UNSET_SENTINEL:
1152
+ if val is not None or k not in optional_fields:
1153
+ m[k] = val
1154
+
1155
+ return m
1156
+
852
1157
 
853
1158
  UpdateAgentToolChoiceAgents1 = Literal[
854
1159
  "none",
@@ -915,71 +1220,235 @@ class UpdateAgentFallbackModelConfigurationGuardrails(BaseModel):
915
1220
  r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
916
1221
 
917
1222
 
918
- class UpdateAgentFallbackModelConfigurationParametersTypedDict(TypedDict):
919
- r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1223
+ class UpdateAgentFallbackModelConfigurationFallbacksTypedDict(TypedDict):
1224
+ model: str
1225
+ r"""Fallback model identifier"""
920
1226
 
921
- audio: NotRequired[Nullable[UpdateAgentFallbackModelConfigurationAudioTypedDict]]
922
- r"""Parameters for audio output. Required when audio output is requested with modalities: [\"audio\"]. Learn more."""
923
- frequency_penalty: NotRequired[Nullable[float]]
924
- 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."""
925
- max_tokens: NotRequired[Nullable[int]]
926
- 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.
927
1227
 
928
- This value is now `deprecated` in favor of `max_completion_tokens`, and is not compatible with o1 series models.
929
- """
930
- max_completion_tokens: NotRequired[Nullable[int]]
931
- r"""An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens"""
932
- logprobs: NotRequired[Nullable[bool]]
933
- 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."""
934
- top_logprobs: NotRequired[Nullable[int]]
935
- 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."""
936
- n: NotRequired[Nullable[int]]
937
- 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."""
938
- presence_penalty: NotRequired[Nullable[float]]
939
- 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."""
940
- response_format: NotRequired[
941
- UpdateAgentFallbackModelConfigurationResponseFormatTypedDict
942
- ]
943
- r"""An object specifying the format that the model must output"""
944
- reasoning_effort: NotRequired[UpdateAgentFallbackModelConfigurationReasoningEffort]
945
- 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.
1228
+ class UpdateAgentFallbackModelConfigurationFallbacks(BaseModel):
1229
+ model: str
1230
+ r"""Fallback model identifier"""
946
1231
 
947
- - `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.
948
- - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
949
- - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
950
- - `xhigh` is currently only supported for `gpt-5.1-codex-max`.
951
1232
 
952
- Any of \"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\".
953
- """
954
- verbosity: NotRequired[str]
955
- r"""Adjusts response verbosity. Lower levels yield shorter answers."""
956
- seed: NotRequired[Nullable[float]]
957
- 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."""
958
- stop: NotRequired[Nullable[UpdateAgentFallbackModelConfigurationStopTypedDict]]
959
- r"""Up to 4 sequences where the API will stop generating further tokens."""
960
- stream_options: NotRequired[
961
- Nullable[UpdateAgentFallbackModelConfigurationStreamOptionsTypedDict]
962
- ]
963
- r"""Options for streaming response. Only set this when you set stream: true."""
964
- thinking: NotRequired[UpdateAgentFallbackModelConfigurationThinkingTypedDict]
965
- temperature: NotRequired[Nullable[float]]
966
- 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."""
967
- top_p: NotRequired[Nullable[float]]
968
- r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass."""
969
- top_k: NotRequired[Nullable[float]]
970
- r"""Limits the model to consider only the top k most likely tokens at each step."""
971
- tool_choice: NotRequired[UpdateAgentFallbackModelConfigurationToolChoiceTypedDict]
972
- r"""Controls which (if any) tool is called by the model."""
973
- parallel_tool_calls: NotRequired[bool]
974
- r"""Whether to enable parallel function calling during tool use."""
975
- modalities: NotRequired[
976
- Nullable[List[UpdateAgentFallbackModelConfigurationModalities]]
977
- ]
978
- 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\"]."""
979
- guardrails: NotRequired[
980
- List[UpdateAgentFallbackModelConfigurationGuardrailsTypedDict]
1233
+ class UpdateAgentFallbackModelConfigurationRetryTypedDict(TypedDict):
1234
+ r"""Retry configuration for the request"""
1235
+
1236
+ count: NotRequired[float]
1237
+ r"""Number of retry attempts (1-5)"""
1238
+ on_codes: NotRequired[List[float]]
1239
+ r"""HTTP status codes that trigger retry logic"""
1240
+
1241
+
1242
+ class UpdateAgentFallbackModelConfigurationRetry(BaseModel):
1243
+ r"""Retry configuration for the request"""
1244
+
1245
+ count: Optional[float] = 3
1246
+ r"""Number of retry attempts (1-5)"""
1247
+
1248
+ on_codes: Optional[List[float]] = None
1249
+ r"""HTTP status codes that trigger retry logic"""
1250
+
1251
+ @model_serializer(mode="wrap")
1252
+ def serialize_model(self, handler):
1253
+ optional_fields = set(["count", "on_codes"])
1254
+ serialized = handler(self)
1255
+ m = {}
1256
+
1257
+ for n, f in type(self).model_fields.items():
1258
+ k = f.alias or n
1259
+ val = serialized.get(k)
1260
+
1261
+ if val != UNSET_SENTINEL:
1262
+ if val is not None or k not in optional_fields:
1263
+ m[k] = val
1264
+
1265
+ return m
1266
+
1267
+
1268
+ UpdateAgentFallbackModelConfigurationType = Literal["exact_match",]
1269
+
1270
+
1271
+ class UpdateAgentFallbackModelConfigurationCacheTypedDict(TypedDict):
1272
+ r"""Cache configuration for the request."""
1273
+
1274
+ type: UpdateAgentFallbackModelConfigurationType
1275
+ ttl: NotRequired[float]
1276
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
1277
+
1278
+
1279
+ class UpdateAgentFallbackModelConfigurationCache(BaseModel):
1280
+ r"""Cache configuration for the request."""
1281
+
1282
+ type: UpdateAgentFallbackModelConfigurationType
1283
+
1284
+ ttl: Optional[float] = 1800
1285
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
1286
+
1287
+ @model_serializer(mode="wrap")
1288
+ def serialize_model(self, handler):
1289
+ optional_fields = set(["ttl"])
1290
+ serialized = handler(self)
1291
+ m = {}
1292
+
1293
+ for n, f in type(self).model_fields.items():
1294
+ k = f.alias or n
1295
+ val = serialized.get(k)
1296
+
1297
+ if val != UNSET_SENTINEL:
1298
+ if val is not None or k not in optional_fields:
1299
+ m[k] = val
1300
+
1301
+ return m
1302
+
1303
+
1304
+ UpdateAgentLoadBalancerAgentsType = Literal["weight_based",]
1305
+
1306
+
1307
+ class UpdateAgentLoadBalancerAgentsModelsTypedDict(TypedDict):
1308
+ model: str
1309
+ r"""Model identifier for load balancing"""
1310
+ weight: NotRequired[float]
1311
+ r"""Weight assigned to this model for load balancing"""
1312
+
1313
+
1314
+ class UpdateAgentLoadBalancerAgentsModels(BaseModel):
1315
+ model: str
1316
+ r"""Model identifier for load balancing"""
1317
+
1318
+ weight: Optional[float] = 0.5
1319
+ r"""Weight assigned to this model for load balancing"""
1320
+
1321
+ @model_serializer(mode="wrap")
1322
+ def serialize_model(self, handler):
1323
+ optional_fields = set(["weight"])
1324
+ serialized = handler(self)
1325
+ m = {}
1326
+
1327
+ for n, f in type(self).model_fields.items():
1328
+ k = f.alias or n
1329
+ val = serialized.get(k)
1330
+
1331
+ if val != UNSET_SENTINEL:
1332
+ if val is not None or k not in optional_fields:
1333
+ m[k] = val
1334
+
1335
+ return m
1336
+
1337
+
1338
+ class UpdateAgentLoadBalancerAgents1TypedDict(TypedDict):
1339
+ type: UpdateAgentLoadBalancerAgentsType
1340
+ models: List[UpdateAgentLoadBalancerAgentsModelsTypedDict]
1341
+
1342
+
1343
+ class UpdateAgentLoadBalancerAgents1(BaseModel):
1344
+ type: UpdateAgentLoadBalancerAgentsType
1345
+
1346
+ models: List[UpdateAgentLoadBalancerAgentsModels]
1347
+
1348
+
1349
+ UpdateAgentFallbackModelConfigurationLoadBalancerTypedDict = (
1350
+ UpdateAgentLoadBalancerAgents1TypedDict
1351
+ )
1352
+ r"""Load balancer configuration for the request."""
1353
+
1354
+
1355
+ UpdateAgentFallbackModelConfigurationLoadBalancer = UpdateAgentLoadBalancerAgents1
1356
+ r"""Load balancer configuration for the request."""
1357
+
1358
+
1359
+ class UpdateAgentFallbackModelConfigurationTimeoutTypedDict(TypedDict):
1360
+ 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."""
1361
+
1362
+ call_timeout: float
1363
+ r"""Timeout value in milliseconds"""
1364
+
1365
+
1366
+ class UpdateAgentFallbackModelConfigurationTimeout(BaseModel):
1367
+ 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."""
1368
+
1369
+ call_timeout: float
1370
+ r"""Timeout value in milliseconds"""
1371
+
1372
+
1373
+ class UpdateAgentFallbackModelConfigurationParametersTypedDict(TypedDict):
1374
+ r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1375
+
1376
+ audio: NotRequired[Nullable[UpdateAgentFallbackModelConfigurationAudioTypedDict]]
1377
+ r"""Parameters for audio output. Required when audio output is requested with modalities: [\"audio\"]. Learn more."""
1378
+ frequency_penalty: NotRequired[Nullable[float]]
1379
+ 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."""
1380
+ max_tokens: NotRequired[Nullable[int]]
1381
+ 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.
1382
+
1383
+ This value is now `deprecated` in favor of `max_completion_tokens`, and is not compatible with o1 series models.
1384
+ """
1385
+ max_completion_tokens: NotRequired[Nullable[int]]
1386
+ r"""An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens"""
1387
+ logprobs: NotRequired[Nullable[bool]]
1388
+ 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."""
1389
+ top_logprobs: NotRequired[Nullable[int]]
1390
+ 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."""
1391
+ n: NotRequired[Nullable[int]]
1392
+ 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."""
1393
+ presence_penalty: NotRequired[Nullable[float]]
1394
+ 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."""
1395
+ response_format: NotRequired[
1396
+ UpdateAgentFallbackModelConfigurationResponseFormatTypedDict
1397
+ ]
1398
+ r"""An object specifying the format that the model must output"""
1399
+ reasoning_effort: NotRequired[UpdateAgentFallbackModelConfigurationReasoningEffort]
1400
+ 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.
1401
+
1402
+ - `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.
1403
+ - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
1404
+ - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
1405
+ - `xhigh` is currently only supported for `gpt-5.1-codex-max`.
1406
+
1407
+ Any of \"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\".
1408
+ """
1409
+ verbosity: NotRequired[str]
1410
+ r"""Adjusts response verbosity. Lower levels yield shorter answers."""
1411
+ seed: NotRequired[Nullable[float]]
1412
+ 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."""
1413
+ stop: NotRequired[Nullable[UpdateAgentFallbackModelConfigurationStopTypedDict]]
1414
+ r"""Up to 4 sequences where the API will stop generating further tokens."""
1415
+ stream_options: NotRequired[
1416
+ Nullable[UpdateAgentFallbackModelConfigurationStreamOptionsTypedDict]
1417
+ ]
1418
+ r"""Options for streaming response. Only set this when you set stream: true."""
1419
+ thinking: NotRequired[UpdateAgentFallbackModelConfigurationThinkingTypedDict]
1420
+ temperature: NotRequired[Nullable[float]]
1421
+ 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."""
1422
+ top_p: NotRequired[Nullable[float]]
1423
+ r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass."""
1424
+ top_k: NotRequired[Nullable[float]]
1425
+ r"""Limits the model to consider only the top k most likely tokens at each step."""
1426
+ tool_choice: NotRequired[UpdateAgentFallbackModelConfigurationToolChoiceTypedDict]
1427
+ r"""Controls which (if any) tool is called by the model."""
1428
+ parallel_tool_calls: NotRequired[bool]
1429
+ r"""Whether to enable parallel function calling during tool use."""
1430
+ modalities: NotRequired[
1431
+ Nullable[List[UpdateAgentFallbackModelConfigurationModalities]]
1432
+ ]
1433
+ 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\"]."""
1434
+ guardrails: NotRequired[
1435
+ List[UpdateAgentFallbackModelConfigurationGuardrailsTypedDict]
981
1436
  ]
982
1437
  r"""A list of guardrails to apply to the request."""
1438
+ fallbacks: NotRequired[
1439
+ List[UpdateAgentFallbackModelConfigurationFallbacksTypedDict]
1440
+ ]
1441
+ r"""Array of fallback models to use if primary model fails"""
1442
+ retry: NotRequired[UpdateAgentFallbackModelConfigurationRetryTypedDict]
1443
+ r"""Retry configuration for the request"""
1444
+ cache: NotRequired[UpdateAgentFallbackModelConfigurationCacheTypedDict]
1445
+ r"""Cache configuration for the request."""
1446
+ load_balancer: NotRequired[
1447
+ UpdateAgentFallbackModelConfigurationLoadBalancerTypedDict
1448
+ ]
1449
+ r"""Load balancer configuration for the request."""
1450
+ timeout: NotRequired[UpdateAgentFallbackModelConfigurationTimeoutTypedDict]
1451
+ 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."""
983
1452
 
984
1453
 
985
1454
  class UpdateAgentFallbackModelConfigurationParameters(BaseModel):
@@ -1069,77 +1538,96 @@ class UpdateAgentFallbackModelConfigurationParameters(BaseModel):
1069
1538
  guardrails: Optional[List[UpdateAgentFallbackModelConfigurationGuardrails]] = None
1070
1539
  r"""A list of guardrails to apply to the request."""
1071
1540
 
1541
+ fallbacks: Optional[List[UpdateAgentFallbackModelConfigurationFallbacks]] = None
1542
+ r"""Array of fallback models to use if primary model fails"""
1543
+
1544
+ retry: Optional[UpdateAgentFallbackModelConfigurationRetry] = None
1545
+ r"""Retry configuration for the request"""
1546
+
1547
+ cache: Optional[UpdateAgentFallbackModelConfigurationCache] = None
1548
+ r"""Cache configuration for the request."""
1549
+
1550
+ load_balancer: Optional[UpdateAgentFallbackModelConfigurationLoadBalancer] = None
1551
+ r"""Load balancer configuration for the request."""
1552
+
1553
+ timeout: Optional[UpdateAgentFallbackModelConfigurationTimeout] = None
1554
+ 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."""
1555
+
1072
1556
  @model_serializer(mode="wrap")
1073
1557
  def serialize_model(self, handler):
1074
- optional_fields = [
1075
- "audio",
1076
- "frequency_penalty",
1077
- "max_tokens",
1078
- "max_completion_tokens",
1079
- "logprobs",
1080
- "top_logprobs",
1081
- "n",
1082
- "presence_penalty",
1083
- "response_format",
1084
- "reasoning_effort",
1085
- "verbosity",
1086
- "seed",
1087
- "stop",
1088
- "stream_options",
1089
- "thinking",
1090
- "temperature",
1091
- "top_p",
1092
- "top_k",
1093
- "tool_choice",
1094
- "parallel_tool_calls",
1095
- "modalities",
1096
- "guardrails",
1097
- ]
1098
- nullable_fields = [
1099
- "audio",
1100
- "frequency_penalty",
1101
- "max_tokens",
1102
- "max_completion_tokens",
1103
- "logprobs",
1104
- "top_logprobs",
1105
- "n",
1106
- "presence_penalty",
1107
- "seed",
1108
- "stop",
1109
- "stream_options",
1110
- "temperature",
1111
- "top_p",
1112
- "top_k",
1113
- "modalities",
1114
- ]
1115
- null_default_fields = []
1116
-
1558
+ optional_fields = set(
1559
+ [
1560
+ "audio",
1561
+ "frequency_penalty",
1562
+ "max_tokens",
1563
+ "max_completion_tokens",
1564
+ "logprobs",
1565
+ "top_logprobs",
1566
+ "n",
1567
+ "presence_penalty",
1568
+ "response_format",
1569
+ "reasoning_effort",
1570
+ "verbosity",
1571
+ "seed",
1572
+ "stop",
1573
+ "stream_options",
1574
+ "thinking",
1575
+ "temperature",
1576
+ "top_p",
1577
+ "top_k",
1578
+ "tool_choice",
1579
+ "parallel_tool_calls",
1580
+ "modalities",
1581
+ "guardrails",
1582
+ "fallbacks",
1583
+ "retry",
1584
+ "cache",
1585
+ "load_balancer",
1586
+ "timeout",
1587
+ ]
1588
+ )
1589
+ nullable_fields = set(
1590
+ [
1591
+ "audio",
1592
+ "frequency_penalty",
1593
+ "max_tokens",
1594
+ "max_completion_tokens",
1595
+ "logprobs",
1596
+ "top_logprobs",
1597
+ "n",
1598
+ "presence_penalty",
1599
+ "seed",
1600
+ "stop",
1601
+ "stream_options",
1602
+ "temperature",
1603
+ "top_p",
1604
+ "top_k",
1605
+ "modalities",
1606
+ ]
1607
+ )
1117
1608
  serialized = handler(self)
1118
-
1119
1609
  m = {}
1120
1610
 
1121
1611
  for n, f in type(self).model_fields.items():
1122
1612
  k = f.alias or n
1123
1613
  val = serialized.get(k)
1124
- serialized.pop(k, None)
1125
-
1126
- optional_nullable = k in optional_fields and k in nullable_fields
1127
- is_set = (
1128
- self.__pydantic_fields_set__.intersection({n})
1129
- or k in null_default_fields
1130
- ) # pylint: disable=no-member
1131
-
1132
- if val is not None and val != UNSET_SENTINEL:
1133
- m[k] = val
1134
- elif val != UNSET_SENTINEL and (
1135
- not k in optional_fields or (optional_nullable and is_set)
1136
- ):
1137
- m[k] = val
1614
+ is_nullable_and_explicitly_set = (
1615
+ k in nullable_fields
1616
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1617
+ )
1618
+
1619
+ if val != UNSET_SENTINEL:
1620
+ if (
1621
+ val is not None
1622
+ or k not in optional_fields
1623
+ or is_nullable_and_explicitly_set
1624
+ ):
1625
+ m[k] = val
1138
1626
 
1139
1627
  return m
1140
1628
 
1141
1629
 
1142
- class UpdateAgentFallbackModelConfigurationRetryTypedDict(TypedDict):
1630
+ class UpdateAgentFallbackModelConfigurationAgentsRetryTypedDict(TypedDict):
1143
1631
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1144
1632
 
1145
1633
  count: NotRequired[float]
@@ -1148,7 +1636,7 @@ class UpdateAgentFallbackModelConfigurationRetryTypedDict(TypedDict):
1148
1636
  r"""HTTP status codes that trigger retry logic"""
1149
1637
 
1150
1638
 
1151
- class UpdateAgentFallbackModelConfigurationRetry(BaseModel):
1639
+ class UpdateAgentFallbackModelConfigurationAgentsRetry(BaseModel):
1152
1640
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1153
1641
 
1154
1642
  count: Optional[float] = 3
@@ -1157,6 +1645,22 @@ class UpdateAgentFallbackModelConfigurationRetry(BaseModel):
1157
1645
  on_codes: Optional[List[float]] = None
1158
1646
  r"""HTTP status codes that trigger retry logic"""
1159
1647
 
1648
+ @model_serializer(mode="wrap")
1649
+ def serialize_model(self, handler):
1650
+ optional_fields = set(["count", "on_codes"])
1651
+ serialized = handler(self)
1652
+ m = {}
1653
+
1654
+ for n, f in type(self).model_fields.items():
1655
+ k = f.alias or n
1656
+ val = serialized.get(k)
1657
+
1658
+ if val != UNSET_SENTINEL:
1659
+ if val is not None or k not in optional_fields:
1660
+ m[k] = val
1661
+
1662
+ return m
1663
+
1160
1664
 
1161
1665
  class UpdateAgentFallbackModelConfiguration2TypedDict(TypedDict):
1162
1666
  r"""Fallback model configuration with optional parameters and retry settings."""
@@ -1165,7 +1669,7 @@ class UpdateAgentFallbackModelConfiguration2TypedDict(TypedDict):
1165
1669
  r"""A fallback model ID string. Must support tool calling."""
1166
1670
  parameters: NotRequired[UpdateAgentFallbackModelConfigurationParametersTypedDict]
1167
1671
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1168
- retry: NotRequired[UpdateAgentFallbackModelConfigurationRetryTypedDict]
1672
+ retry: NotRequired[UpdateAgentFallbackModelConfigurationAgentsRetryTypedDict]
1169
1673
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1170
1674
 
1171
1675
 
@@ -1178,9 +1682,25 @@ class UpdateAgentFallbackModelConfiguration2(BaseModel):
1178
1682
  parameters: Optional[UpdateAgentFallbackModelConfigurationParameters] = None
1179
1683
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
1180
1684
 
1181
- retry: Optional[UpdateAgentFallbackModelConfigurationRetry] = None
1685
+ retry: Optional[UpdateAgentFallbackModelConfigurationAgentsRetry] = None
1182
1686
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
1183
1687
 
1688
+ @model_serializer(mode="wrap")
1689
+ def serialize_model(self, handler):
1690
+ optional_fields = set(["parameters", "retry"])
1691
+ serialized = handler(self)
1692
+ m = {}
1693
+
1694
+ for n, f in type(self).model_fields.items():
1695
+ k = f.alias or n
1696
+ val = serialized.get(k)
1697
+
1698
+ if val != UNSET_SENTINEL:
1699
+ if val is not None or k not in optional_fields:
1700
+ m[k] = val
1701
+
1702
+ return m
1703
+
1184
1704
 
1185
1705
  UpdateAgentFallbackModelConfigurationTypedDict = TypeAliasType(
1186
1706
  "UpdateAgentFallbackModelConfigurationTypedDict",
@@ -1204,7 +1724,7 @@ UpdateAgentToolApprovalRequired = Literal[
1204
1724
  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."""
1205
1725
 
1206
1726
 
1207
- UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type = Literal[
1727
+ UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools16Type = Literal[
1208
1728
  "mcp",
1209
1729
  ]
1210
1730
  r"""MCP tool type"""
@@ -1216,7 +1736,7 @@ class AgentToolInputCRUDMCPToolTypedDict(TypedDict):
1216
1736
  tool_id: str
1217
1737
  r"""The ID of the specific nested tool within the MCP server"""
1218
1738
  type: NotRequired[
1219
- UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1739
+ UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools16Type
1220
1740
  ]
1221
1741
  r"""MCP tool type"""
1222
1742
  key: NotRequired[str]
@@ -1234,7 +1754,7 @@ class AgentToolInputCRUDMCPTool(BaseModel):
1234
1754
  r"""The ID of the specific nested tool within the MCP server"""
1235
1755
 
1236
1756
  type: Optional[
1237
- UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1757
+ UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools16Type
1238
1758
  ] = "mcp"
1239
1759
  r"""MCP tool type"""
1240
1760
 
@@ -1247,6 +1767,77 @@ class AgentToolInputCRUDMCPTool(BaseModel):
1247
1767
  requires_approval: Optional[bool] = False
1248
1768
  r"""Whether this tool requires approval before execution"""
1249
1769
 
1770
+ @model_serializer(mode="wrap")
1771
+ def serialize_model(self, handler):
1772
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1773
+ serialized = handler(self)
1774
+ m = {}
1775
+
1776
+ for n, f in type(self).model_fields.items():
1777
+ k = f.alias or n
1778
+ val = serialized.get(k)
1779
+
1780
+ if val != UNSET_SENTINEL:
1781
+ if val is not None or k not in optional_fields:
1782
+ m[k] = val
1783
+
1784
+ return m
1785
+
1786
+
1787
+ UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type = Literal[
1788
+ "json_schema",
1789
+ ]
1790
+ r"""JSON Schema tool type"""
1791
+
1792
+
1793
+ class AgentToolInputCRUDJSONSchemaToolTypedDict(TypedDict):
1794
+ r"""Enforces structured output format using JSON Schema. Must reference a pre-created JSON Schema tool by key or id."""
1795
+
1796
+ type: NotRequired[
1797
+ UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1798
+ ]
1799
+ r"""JSON Schema tool type"""
1800
+ key: NotRequired[str]
1801
+ r"""The key of the pre-created JSON Schema tool"""
1802
+ id: NotRequired[str]
1803
+ r"""The ID of the pre-created JSON Schema tool"""
1804
+ requires_approval: NotRequired[bool]
1805
+ r"""Whether this tool requires approval before execution"""
1806
+
1807
+
1808
+ class AgentToolInputCRUDJSONSchemaTool(BaseModel):
1809
+ r"""Enforces structured output format using JSON Schema. Must reference a pre-created JSON Schema tool by key or id."""
1810
+
1811
+ type: Optional[
1812
+ UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools15Type
1813
+ ] = "json_schema"
1814
+ r"""JSON Schema tool type"""
1815
+
1816
+ key: Optional[str] = None
1817
+ r"""The key of the pre-created JSON Schema tool"""
1818
+
1819
+ id: Optional[str] = None
1820
+ r"""The ID of the pre-created JSON Schema tool"""
1821
+
1822
+ requires_approval: Optional[bool] = False
1823
+ r"""Whether this tool requires approval before execution"""
1824
+
1825
+ @model_serializer(mode="wrap")
1826
+ def serialize_model(self, handler):
1827
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1828
+ serialized = handler(self)
1829
+ m = {}
1830
+
1831
+ for n, f in type(self).model_fields.items():
1832
+ k = f.alias or n
1833
+ val = serialized.get(k)
1834
+
1835
+ if val != UNSET_SENTINEL:
1836
+ if val is not None or k not in optional_fields:
1837
+ m[k] = val
1838
+
1839
+ return m
1840
+
1250
1841
 
1251
1842
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools14Type = Literal[
1252
1843
  "function",
@@ -1286,6 +1877,22 @@ class AgentToolInputCRUDFunctionTool(BaseModel):
1286
1877
  requires_approval: Optional[bool] = False
1287
1878
  r"""Whether this tool requires approval before execution"""
1288
1879
 
1880
+ @model_serializer(mode="wrap")
1881
+ def serialize_model(self, handler):
1882
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1883
+ serialized = handler(self)
1884
+ m = {}
1885
+
1886
+ for n, f in type(self).model_fields.items():
1887
+ k = f.alias or n
1888
+ val = serialized.get(k)
1889
+
1890
+ if val != UNSET_SENTINEL:
1891
+ if val is not None or k not in optional_fields:
1892
+ m[k] = val
1893
+
1894
+ return m
1895
+
1289
1896
 
1290
1897
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools13Type = Literal[
1291
1898
  "code",
@@ -1325,6 +1932,22 @@ class AgentToolInputCRUDCodeExecutionTool(BaseModel):
1325
1932
  requires_approval: Optional[bool] = False
1326
1933
  r"""Whether this tool requires approval before execution"""
1327
1934
 
1935
+ @model_serializer(mode="wrap")
1936
+ def serialize_model(self, handler):
1937
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1938
+ serialized = handler(self)
1939
+ m = {}
1940
+
1941
+ for n, f in type(self).model_fields.items():
1942
+ k = f.alias or n
1943
+ val = serialized.get(k)
1944
+
1945
+ if val != UNSET_SENTINEL:
1946
+ if val is not None or k not in optional_fields:
1947
+ m[k] = val
1948
+
1949
+ return m
1950
+
1328
1951
 
1329
1952
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools12Type = Literal[
1330
1953
  "http",
@@ -1364,6 +1987,22 @@ class AgentToolInputCRUDHTTPTool(BaseModel):
1364
1987
  requires_approval: Optional[bool] = False
1365
1988
  r"""Whether this tool requires approval before execution"""
1366
1989
 
1990
+ @model_serializer(mode="wrap")
1991
+ def serialize_model(self, handler):
1992
+ optional_fields = set(["type", "key", "id", "requires_approval"])
1993
+ serialized = handler(self)
1994
+ m = {}
1995
+
1996
+ for n, f in type(self).model_fields.items():
1997
+ k = f.alias or n
1998
+ val = serialized.get(k)
1999
+
2000
+ if val != UNSET_SENTINEL:
2001
+ if val is not None or k not in optional_fields:
2002
+ m[k] = val
2003
+
2004
+ return m
2005
+
1367
2006
 
1368
2007
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools11Type = Literal[
1369
2008
  "current_date",
@@ -1386,6 +2025,22 @@ class AgentToolInputCRUDCurrentDateTool(BaseModel):
1386
2025
  requires_approval: Optional[bool] = None
1387
2026
  r"""Whether this tool requires approval before execution"""
1388
2027
 
2028
+ @model_serializer(mode="wrap")
2029
+ def serialize_model(self, handler):
2030
+ optional_fields = set(["requires_approval"])
2031
+ serialized = handler(self)
2032
+ m = {}
2033
+
2034
+ for n, f in type(self).model_fields.items():
2035
+ k = f.alias or n
2036
+ val = serialized.get(k)
2037
+
2038
+ if val != UNSET_SENTINEL:
2039
+ if val is not None or k not in optional_fields:
2040
+ m[k] = val
2041
+
2042
+ return m
2043
+
1389
2044
 
1390
2045
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools10Type = Literal[
1391
2046
  "query_knowledge_base",
@@ -1408,6 +2063,22 @@ class AgentToolInputCRUDQueryKnowledgeBaseTool(BaseModel):
1408
2063
  requires_approval: Optional[bool] = None
1409
2064
  r"""Whether this tool requires approval before execution"""
1410
2065
 
2066
+ @model_serializer(mode="wrap")
2067
+ def serialize_model(self, handler):
2068
+ optional_fields = set(["requires_approval"])
2069
+ serialized = handler(self)
2070
+ m = {}
2071
+
2072
+ for n, f in type(self).model_fields.items():
2073
+ k = f.alias or n
2074
+ val = serialized.get(k)
2075
+
2076
+ if val != UNSET_SENTINEL:
2077
+ if val is not None or k not in optional_fields:
2078
+ m[k] = val
2079
+
2080
+ return m
2081
+
1411
2082
 
1412
2083
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools9Type = Literal[
1413
2084
  "retrieve_knowledge_bases",
@@ -1430,6 +2101,22 @@ class AgentToolInputCRUDRetrieveKnowledgeBasesTool(BaseModel):
1430
2101
  requires_approval: Optional[bool] = None
1431
2102
  r"""Whether this tool requires approval before execution"""
1432
2103
 
2104
+ @model_serializer(mode="wrap")
2105
+ def serialize_model(self, handler):
2106
+ optional_fields = set(["requires_approval"])
2107
+ serialized = handler(self)
2108
+ m = {}
2109
+
2110
+ for n, f in type(self).model_fields.items():
2111
+ k = f.alias or n
2112
+ val = serialized.get(k)
2113
+
2114
+ if val != UNSET_SENTINEL:
2115
+ if val is not None or k not in optional_fields:
2116
+ m[k] = val
2117
+
2118
+ return m
2119
+
1433
2120
 
1434
2121
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools8Type = Literal[
1435
2122
  "delete_memory_document",
@@ -1452,6 +2139,22 @@ class AgentToolInputCRUDDeleteMemoryDocumentTool(BaseModel):
1452
2139
  requires_approval: Optional[bool] = None
1453
2140
  r"""Whether this tool requires approval before execution"""
1454
2141
 
2142
+ @model_serializer(mode="wrap")
2143
+ def serialize_model(self, handler):
2144
+ optional_fields = set(["requires_approval"])
2145
+ serialized = handler(self)
2146
+ m = {}
2147
+
2148
+ for n, f in type(self).model_fields.items():
2149
+ k = f.alias or n
2150
+ val = serialized.get(k)
2151
+
2152
+ if val != UNSET_SENTINEL:
2153
+ if val is not None or k not in optional_fields:
2154
+ m[k] = val
2155
+
2156
+ return m
2157
+
1455
2158
 
1456
2159
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsTools7Type = Literal[
1457
2160
  "retrieve_memory_stores",
@@ -1474,6 +2177,22 @@ class AgentToolInputCRUDRetrieveMemoryStoresTool(BaseModel):
1474
2177
  requires_approval: Optional[bool] = None
1475
2178
  r"""Whether this tool requires approval before execution"""
1476
2179
 
2180
+ @model_serializer(mode="wrap")
2181
+ def serialize_model(self, handler):
2182
+ optional_fields = set(["requires_approval"])
2183
+ serialized = handler(self)
2184
+ m = {}
2185
+
2186
+ for n, f in type(self).model_fields.items():
2187
+ k = f.alias or n
2188
+ val = serialized.get(k)
2189
+
2190
+ if val != UNSET_SENTINEL:
2191
+ if val is not None or k not in optional_fields:
2192
+ m[k] = val
2193
+
2194
+ return m
2195
+
1477
2196
 
1478
2197
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsToolsType = Literal[
1479
2198
  "write_memory_store",
@@ -1496,6 +2215,22 @@ class AgentToolInputCRUDWriteMemoryStoreTool(BaseModel):
1496
2215
  requires_approval: Optional[bool] = None
1497
2216
  r"""Whether this tool requires approval before execution"""
1498
2217
 
2218
+ @model_serializer(mode="wrap")
2219
+ def serialize_model(self, handler):
2220
+ optional_fields = set(["requires_approval"])
2221
+ serialized = handler(self)
2222
+ m = {}
2223
+
2224
+ for n, f in type(self).model_fields.items():
2225
+ k = f.alias or n
2226
+ val = serialized.get(k)
2227
+
2228
+ if val != UNSET_SENTINEL:
2229
+ if val is not None or k not in optional_fields:
2230
+ m[k] = val
2231
+
2232
+ return m
2233
+
1499
2234
 
1500
2235
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodySettingsType = Literal[
1501
2236
  "query_memory_store",
@@ -1518,6 +2253,22 @@ class AgentToolInputCRUDQueryMemoryStoreTool(BaseModel):
1518
2253
  requires_approval: Optional[bool] = None
1519
2254
  r"""Whether this tool requires approval before execution"""
1520
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
+
1521
2272
 
1522
2273
  UpdateAgentAgentToolInputCRUDAgentsRequestRequestBodyType = Literal["retrieve_agents",]
1523
2274
 
@@ -1538,6 +2289,22 @@ class AgentToolInputCRUDRetrieveAgentsTool(BaseModel):
1538
2289
  requires_approval: Optional[bool] = None
1539
2290
  r"""Whether this tool requires approval before execution"""
1540
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
+
1541
2308
 
1542
2309
  UpdateAgentAgentToolInputCRUDAgentsRequestType = Literal["call_sub_agent",]
1543
2310
 
@@ -1558,6 +2325,22 @@ class AgentToolInputCRUDCallSubAgentTool(BaseModel):
1558
2325
  requires_approval: Optional[bool] = None
1559
2326
  r"""Whether this tool requires approval before execution"""
1560
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
+
1561
2344
 
1562
2345
  UpdateAgentAgentToolInputCRUDAgentsType = Literal["web_scraper",]
1563
2346
 
@@ -1578,6 +2361,22 @@ class AgentToolInputCRUDWebScraperTool(BaseModel):
1578
2361
  requires_approval: Optional[bool] = None
1579
2362
  r"""Whether this tool requires approval before execution"""
1580
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
+
1581
2380
 
1582
2381
  UpdateAgentAgentToolInputCRUDType = Literal["google_search",]
1583
2382
 
@@ -1598,6 +2397,22 @@ class AgentToolInputCRUDGoogleSearchTool(BaseModel):
1598
2397
  requires_approval: Optional[bool] = None
1599
2398
  r"""Whether this tool requires approval before execution"""
1600
2399
 
2400
+ @model_serializer(mode="wrap")
2401
+ def serialize_model(self, handler):
2402
+ optional_fields = set(["requires_approval"])
2403
+ serialized = handler(self)
2404
+ m = {}
2405
+
2406
+ for n, f in type(self).model_fields.items():
2407
+ k = f.alias or n
2408
+ val = serialized.get(k)
2409
+
2410
+ if val != UNSET_SENTINEL:
2411
+ if val is not None or k not in optional_fields:
2412
+ m[k] = val
2413
+
2414
+ return m
2415
+
1601
2416
 
1602
2417
  UpdateAgentAgentToolInputCRUDTypedDict = TypeAliasType(
1603
2418
  "UpdateAgentAgentToolInputCRUDTypedDict",
@@ -1616,10 +2431,11 @@ UpdateAgentAgentToolInputCRUDTypedDict = TypeAliasType(
1616
2431
  AgentToolInputCRUDHTTPToolTypedDict,
1617
2432
  AgentToolInputCRUDCodeExecutionToolTypedDict,
1618
2433
  AgentToolInputCRUDFunctionToolTypedDict,
2434
+ AgentToolInputCRUDJSONSchemaToolTypedDict,
1619
2435
  AgentToolInputCRUDMCPToolTypedDict,
1620
2436
  ],
1621
2437
  )
1622
- 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."""
2438
+ 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."""
1623
2439
 
1624
2440
 
1625
2441
  UpdateAgentAgentToolInputCRUD = TypeAliasType(
@@ -1639,10 +2455,11 @@ UpdateAgentAgentToolInputCRUD = TypeAliasType(
1639
2455
  AgentToolInputCRUDHTTPTool,
1640
2456
  AgentToolInputCRUDCodeExecutionTool,
1641
2457
  AgentToolInputCRUDFunctionTool,
2458
+ AgentToolInputCRUDJSONSchemaTool,
1642
2459
  AgentToolInputCRUDMCPTool,
1643
2460
  ],
1644
2461
  )
1645
- 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."""
2462
+ 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."""
1646
2463
 
1647
2464
 
1648
2465
  UpdateAgentExecuteOn = Literal[
@@ -1665,11 +2482,27 @@ class UpdateAgentEvaluators(BaseModel):
1665
2482
  id: str
1666
2483
  r"""Unique key or identifier of the evaluator"""
1667
2484
 
1668
- execute_on: UpdateAgentExecuteOn
1669
- r"""Determines whether the evaluator runs on the agent input (user message) or output (agent response)."""
2485
+ execute_on: UpdateAgentExecuteOn
2486
+ r"""Determines whether the evaluator runs on the agent input (user message) or output (agent response)."""
2487
+
2488
+ sample_rate: Optional[float] = 50
2489
+ 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."""
2490
+
2491
+ @model_serializer(mode="wrap")
2492
+ def serialize_model(self, handler):
2493
+ optional_fields = set(["sample_rate"])
2494
+ serialized = handler(self)
2495
+ m = {}
2496
+
2497
+ for n, f in type(self).model_fields.items():
2498
+ k = f.alias or n
2499
+ val = serialized.get(k)
2500
+
2501
+ if val != UNSET_SENTINEL:
2502
+ if val is not None or k not in optional_fields:
2503
+ m[k] = val
1670
2504
 
1671
- sample_rate: Optional[float] = 50
1672
- 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."""
2505
+ return m
1673
2506
 
1674
2507
 
1675
2508
  UpdateAgentAgentsExecuteOn = Literal[
@@ -1698,6 +2531,22 @@ class UpdateAgentGuardrails(BaseModel):
1698
2531
  sample_rate: Optional[float] = 50
1699
2532
  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."""
1700
2533
 
2534
+ @model_serializer(mode="wrap")
2535
+ def serialize_model(self, handler):
2536
+ optional_fields = set(["sample_rate"])
2537
+ serialized = handler(self)
2538
+ m = {}
2539
+
2540
+ for n, f in type(self).model_fields.items():
2541
+ k = f.alias or n
2542
+ val = serialized.get(k)
2543
+
2544
+ if val != UNSET_SENTINEL:
2545
+ if val is not None or k not in optional_fields:
2546
+ m[k] = val
2547
+
2548
+ return m
2549
+
1701
2550
 
1702
2551
  class UpdateAgentSettingsTypedDict(TypedDict):
1703
2552
  max_iterations: NotRequired[int]
@@ -1733,6 +2582,31 @@ class UpdateAgentSettings(BaseModel):
1733
2582
  guardrails: Optional[List[UpdateAgentGuardrails]] = None
1734
2583
  r"""Configuration for a guardrail applied to the agent"""
1735
2584
 
2585
+ @model_serializer(mode="wrap")
2586
+ def serialize_model(self, handler):
2587
+ optional_fields = set(
2588
+ [
2589
+ "max_iterations",
2590
+ "max_execution_time",
2591
+ "tool_approval_required",
2592
+ "tools",
2593
+ "evaluators",
2594
+ "guardrails",
2595
+ ]
2596
+ )
2597
+ serialized = handler(self)
2598
+ m = {}
2599
+
2600
+ for n, f in type(self).model_fields.items():
2601
+ k = f.alias or n
2602
+ val = serialized.get(k)
2603
+
2604
+ if val != UNSET_SENTINEL:
2605
+ if val is not None or k not in optional_fields:
2606
+ m[k] = val
2607
+
2608
+ return m
2609
+
1736
2610
 
1737
2611
  class UpdateAgentKnowledgeBasesTypedDict(TypedDict):
1738
2612
  knowledge_id: str
@@ -1758,6 +2632,22 @@ class UpdateAgentTeamOfAgents(BaseModel):
1758
2632
  role: Optional[str] = None
1759
2633
  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."""
1760
2634
 
2635
+ @model_serializer(mode="wrap")
2636
+ def serialize_model(self, handler):
2637
+ optional_fields = set(["role"])
2638
+ serialized = handler(self)
2639
+ m = {}
2640
+
2641
+ for n, f in type(self).model_fields.items():
2642
+ k = f.alias or n
2643
+ val = serialized.get(k)
2644
+
2645
+ if val != UNSET_SENTINEL:
2646
+ if val is not None or k not in optional_fields:
2647
+ m[k] = val
2648
+
2649
+ return m
2650
+
1761
2651
 
1762
2652
  class UpdateAgentUpdateAgentRequestTypedDict(TypedDict):
1763
2653
  r"""Request body for updating an existing agent via the API. Uses simplified tool input format."""
@@ -1838,6 +2728,40 @@ class UpdateAgentUpdateAgentRequest(BaseModel):
1838
2728
  variables: Optional[Dict[str, Any]] = None
1839
2729
  r"""Extracted variables from agent instructions"""
1840
2730
 
2731
+ @model_serializer(mode="wrap")
2732
+ def serialize_model(self, handler):
2733
+ optional_fields = set(
2734
+ [
2735
+ "key",
2736
+ "display_name",
2737
+ "project_id",
2738
+ "role",
2739
+ "description",
2740
+ "instructions",
2741
+ "system_prompt",
2742
+ "model",
2743
+ "fallback_models",
2744
+ "settings",
2745
+ "path",
2746
+ "memory_stores",
2747
+ "knowledge_bases",
2748
+ "team_of_agents",
2749
+ "variables",
2750
+ ]
2751
+ )
2752
+ serialized = handler(self)
2753
+ m = {}
2754
+
2755
+ for n, f in type(self).model_fields.items():
2756
+ k = f.alias or n
2757
+ val = serialized.get(k)
2758
+
2759
+ if val != UNSET_SENTINEL:
2760
+ if val is not None or k not in optional_fields:
2761
+ m[k] = val
2762
+
2763
+ return m
2764
+
1841
2765
 
1842
2766
  class UpdateAgentRequestTypedDict(TypedDict):
1843
2767
  agent_key: str
@@ -1957,6 +2881,32 @@ class UpdateAgentTools(BaseModel):
1957
2881
  timeout: Optional[float] = 120
1958
2882
  r"""Tool execution timeout in seconds (default: 2 minutes, max: 10 minutes)"""
1959
2883
 
2884
+ @model_serializer(mode="wrap")
2885
+ def serialize_model(self, handler):
2886
+ optional_fields = set(
2887
+ [
2888
+ "key",
2889
+ "display_name",
2890
+ "description",
2891
+ "requires_approval",
2892
+ "tool_id",
2893
+ "conditions",
2894
+ "timeout",
2895
+ ]
2896
+ )
2897
+ serialized = handler(self)
2898
+ m = {}
2899
+
2900
+ for n, f in type(self).model_fields.items():
2901
+ k = f.alias or n
2902
+ val = serialized.get(k)
2903
+
2904
+ if val != UNSET_SENTINEL:
2905
+ if val is not None or k not in optional_fields:
2906
+ m[k] = val
2907
+
2908
+ return m
2909
+
1960
2910
 
1961
2911
  UpdateAgentAgentsResponseExecuteOn = Literal[
1962
2912
  "input",
@@ -1984,6 +2934,22 @@ class UpdateAgentAgentsEvaluators(BaseModel):
1984
2934
  sample_rate: Optional[float] = 50
1985
2935
  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."""
1986
2936
 
2937
+ @model_serializer(mode="wrap")
2938
+ def serialize_model(self, handler):
2939
+ optional_fields = set(["sample_rate"])
2940
+ serialized = handler(self)
2941
+ m = {}
2942
+
2943
+ for n, f in type(self).model_fields.items():
2944
+ k = f.alias or n
2945
+ val = serialized.get(k)
2946
+
2947
+ if val != UNSET_SENTINEL:
2948
+ if val is not None or k not in optional_fields:
2949
+ m[k] = val
2950
+
2951
+ return m
2952
+
1987
2953
 
1988
2954
  UpdateAgentAgentsResponse200ExecuteOn = Literal[
1989
2955
  "input",
@@ -2011,6 +2977,22 @@ class UpdateAgentAgentsGuardrails(BaseModel):
2011
2977
  sample_rate: Optional[float] = 50
2012
2978
  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."""
2013
2979
 
2980
+ @model_serializer(mode="wrap")
2981
+ def serialize_model(self, handler):
2982
+ optional_fields = set(["sample_rate"])
2983
+ serialized = handler(self)
2984
+ m = {}
2985
+
2986
+ for n, f in type(self).model_fields.items():
2987
+ k = f.alias or n
2988
+ val = serialized.get(k)
2989
+
2990
+ if val != UNSET_SENTINEL:
2991
+ if val is not None or k not in optional_fields:
2992
+ m[k] = val
2993
+
2994
+ return m
2995
+
2014
2996
 
2015
2997
  class UpdateAgentAgentsSettingsTypedDict(TypedDict):
2016
2998
  max_iterations: NotRequired[int]
@@ -2046,6 +3028,31 @@ class UpdateAgentAgentsSettings(BaseModel):
2046
3028
  guardrails: Optional[List[UpdateAgentAgentsGuardrails]] = None
2047
3029
  r"""Configuration for a guardrail applied to the agent"""
2048
3030
 
3031
+ @model_serializer(mode="wrap")
3032
+ def serialize_model(self, handler):
3033
+ optional_fields = set(
3034
+ [
3035
+ "max_iterations",
3036
+ "max_execution_time",
3037
+ "tool_approval_required",
3038
+ "tools",
3039
+ "evaluators",
3040
+ "guardrails",
3041
+ ]
3042
+ )
3043
+ serialized = handler(self)
3044
+ m = {}
3045
+
3046
+ for n, f in type(self).model_fields.items():
3047
+ k = f.alias or n
3048
+ val = serialized.get(k)
3049
+
3050
+ if val != UNSET_SENTINEL:
3051
+ if val is not None or k not in optional_fields:
3052
+ m[k] = val
3053
+
3054
+ return m
3055
+
2049
3056
 
2050
3057
  UpdateAgentVoice = Literal[
2051
3058
  "alloy",
@@ -2114,6 +3121,22 @@ class UpdateAgentResponseFormatAgentsResponseJSONSchema(BaseModel):
2114
3121
  strict: Optional[bool] = False
2115
3122
  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."""
2116
3123
 
3124
+ @model_serializer(mode="wrap")
3125
+ def serialize_model(self, handler):
3126
+ optional_fields = set(["description", "schema", "strict"])
3127
+ serialized = handler(self)
3128
+ m = {}
3129
+
3130
+ for n, f in type(self).model_fields.items():
3131
+ k = f.alias or n
3132
+ val = serialized.get(k)
3133
+
3134
+ if val != UNSET_SENTINEL:
3135
+ if val is not None or k not in optional_fields:
3136
+ m[k] = val
3137
+
3138
+ return m
3139
+
2117
3140
 
2118
3141
  class UpdateAgentResponseFormatAgentsResponse200JSONSchemaTypedDict(TypedDict):
2119
3142
  r"""
@@ -2246,6 +3269,22 @@ class UpdateAgentStreamOptions(BaseModel):
2246
3269
  include_usage: Optional[bool] = None
2247
3270
  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."""
2248
3271
 
3272
+ @model_serializer(mode="wrap")
3273
+ def serialize_model(self, handler):
3274
+ optional_fields = set(["include_usage"])
3275
+ serialized = handler(self)
3276
+ m = {}
3277
+
3278
+ for n, f in type(self).model_fields.items():
3279
+ k = f.alias or n
3280
+ val = serialized.get(k)
3281
+
3282
+ if val != UNSET_SENTINEL:
3283
+ if val is not None or k not in optional_fields:
3284
+ m[k] = val
3285
+
3286
+ return m
3287
+
2249
3288
 
2250
3289
  UpdateAgentThinkingTypedDict = TypeAliasType(
2251
3290
  "UpdateAgentThinkingTypedDict",
@@ -2288,6 +3327,22 @@ class UpdateAgentToolChoiceAgentsResponse2(BaseModel):
2288
3327
  type: Optional[UpdateAgentToolChoiceAgentsResponseType] = None
2289
3328
  r"""The type of the tool. Currently, only function is supported."""
2290
3329
 
3330
+ @model_serializer(mode="wrap")
3331
+ def serialize_model(self, handler):
3332
+ optional_fields = set(["type"])
3333
+ serialized = handler(self)
3334
+ m = {}
3335
+
3336
+ for n, f in type(self).model_fields.items():
3337
+ k = f.alias or n
3338
+ val = serialized.get(k)
3339
+
3340
+ if val != UNSET_SENTINEL:
3341
+ if val is not None or k not in optional_fields:
3342
+ m[k] = val
3343
+
3344
+ return m
3345
+
2291
3346
 
2292
3347
  UpdateAgentToolChoiceAgentsResponse1 = Literal[
2293
3348
  "none",
@@ -2306,53 +3361,201 @@ UpdateAgentToolChoiceTypedDict = TypeAliasType(
2306
3361
  r"""Controls which (if any) tool is called by the model."""
2307
3362
 
2308
3363
 
2309
- UpdateAgentToolChoice = TypeAliasType(
2310
- "UpdateAgentToolChoice",
2311
- Union[UpdateAgentToolChoiceAgentsResponse2, UpdateAgentToolChoiceAgentsResponse1],
2312
- )
2313
- r"""Controls which (if any) tool is called by the model."""
3364
+ UpdateAgentToolChoice = TypeAliasType(
3365
+ "UpdateAgentToolChoice",
3366
+ Union[UpdateAgentToolChoiceAgentsResponse2, UpdateAgentToolChoiceAgentsResponse1],
3367
+ )
3368
+ r"""Controls which (if any) tool is called by the model."""
3369
+
3370
+
3371
+ UpdateAgentModalities = Literal[
3372
+ "text",
3373
+ "audio",
3374
+ ]
3375
+
3376
+
3377
+ UpdateAgentIDAgentsResponse1 = Literal[
3378
+ "orq_pii_detection",
3379
+ "orq_sexual_moderation",
3380
+ "orq_harmful_moderation",
3381
+ ]
3382
+ r"""The key of the guardrail."""
3383
+
3384
+
3385
+ UpdateAgentIDTypedDict = TypeAliasType(
3386
+ "UpdateAgentIDTypedDict", Union[UpdateAgentIDAgentsResponse1, str]
3387
+ )
3388
+
3389
+
3390
+ UpdateAgentID = TypeAliasType("UpdateAgentID", Union[UpdateAgentIDAgentsResponse1, str])
3391
+
3392
+
3393
+ UpdateAgentAgentsResponse200ApplicationJSONExecuteOn = Literal[
3394
+ "input",
3395
+ "output",
3396
+ ]
3397
+ r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3398
+
3399
+
3400
+ class UpdateAgentAgentsResponseGuardrailsTypedDict(TypedDict):
3401
+ id: UpdateAgentIDTypedDict
3402
+ execute_on: UpdateAgentAgentsResponse200ApplicationJSONExecuteOn
3403
+ r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3404
+
3405
+
3406
+ class UpdateAgentAgentsResponseGuardrails(BaseModel):
3407
+ id: UpdateAgentID
3408
+
3409
+ execute_on: UpdateAgentAgentsResponse200ApplicationJSONExecuteOn
3410
+ r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3411
+
3412
+
3413
+ class UpdateAgentFallbacksTypedDict(TypedDict):
3414
+ model: str
3415
+ r"""Fallback model identifier"""
3416
+
3417
+
3418
+ class UpdateAgentFallbacks(BaseModel):
3419
+ model: str
3420
+ r"""Fallback model identifier"""
3421
+
3422
+
3423
+ class UpdateAgentAgentsRetryTypedDict(TypedDict):
3424
+ r"""Retry configuration for the request"""
3425
+
3426
+ count: NotRequired[float]
3427
+ r"""Number of retry attempts (1-5)"""
3428
+ on_codes: NotRequired[List[float]]
3429
+ r"""HTTP status codes that trigger retry logic"""
3430
+
3431
+
3432
+ class UpdateAgentAgentsRetry(BaseModel):
3433
+ r"""Retry configuration for the request"""
3434
+
3435
+ count: Optional[float] = 3
3436
+ r"""Number of retry attempts (1-5)"""
3437
+
3438
+ on_codes: Optional[List[float]] = None
3439
+ r"""HTTP status codes that trigger retry logic"""
3440
+
3441
+ @model_serializer(mode="wrap")
3442
+ def serialize_model(self, handler):
3443
+ optional_fields = set(["count", "on_codes"])
3444
+ serialized = handler(self)
3445
+ m = {}
3446
+
3447
+ for n, f in type(self).model_fields.items():
3448
+ k = f.alias or n
3449
+ val = serialized.get(k)
3450
+
3451
+ if val != UNSET_SENTINEL:
3452
+ if val is not None or k not in optional_fields:
3453
+ m[k] = val
3454
+
3455
+ return m
3456
+
3457
+
3458
+ UpdateAgentType = Literal["exact_match",]
3459
+
3460
+
3461
+ class UpdateAgentCacheTypedDict(TypedDict):
3462
+ r"""Cache configuration for the request."""
3463
+
3464
+ type: UpdateAgentType
3465
+ ttl: NotRequired[float]
3466
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
3467
+
3468
+
3469
+ class UpdateAgentCache(BaseModel):
3470
+ r"""Cache configuration for the request."""
3471
+
3472
+ type: UpdateAgentType
3473
+
3474
+ ttl: Optional[float] = 1800
3475
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
3476
+
3477
+ @model_serializer(mode="wrap")
3478
+ def serialize_model(self, handler):
3479
+ optional_fields = set(["ttl"])
3480
+ serialized = handler(self)
3481
+ m = {}
3482
+
3483
+ for n, f in type(self).model_fields.items():
3484
+ k = f.alias or n
3485
+ val = serialized.get(k)
3486
+
3487
+ if val != UNSET_SENTINEL:
3488
+ if val is not None or k not in optional_fields:
3489
+ m[k] = val
3490
+
3491
+ return m
3492
+
3493
+
3494
+ UpdateAgentLoadBalancerAgentsResponseType = Literal["weight_based",]
3495
+
3496
+
3497
+ class UpdateAgentLoadBalancerAgentsResponseModelsTypedDict(TypedDict):
3498
+ model: str
3499
+ r"""Model identifier for load balancing"""
3500
+ weight: NotRequired[float]
3501
+ r"""Weight assigned to this model for load balancing"""
3502
+
3503
+
3504
+ class UpdateAgentLoadBalancerAgentsResponseModels(BaseModel):
3505
+ model: str
3506
+ r"""Model identifier for load balancing"""
3507
+
3508
+ weight: Optional[float] = 0.5
3509
+ r"""Weight assigned to this model for load balancing"""
3510
+
3511
+ @model_serializer(mode="wrap")
3512
+ def serialize_model(self, handler):
3513
+ optional_fields = set(["weight"])
3514
+ serialized = handler(self)
3515
+ m = {}
3516
+
3517
+ for n, f in type(self).model_fields.items():
3518
+ k = f.alias or n
3519
+ val = serialized.get(k)
3520
+
3521
+ if val != UNSET_SENTINEL:
3522
+ if val is not None or k not in optional_fields:
3523
+ m[k] = val
3524
+
3525
+ return m
2314
3526
 
2315
3527
 
2316
- UpdateAgentModalities = Literal[
2317
- "text",
2318
- "audio",
2319
- ]
3528
+ class UpdateAgentLoadBalancerAgentsResponse1TypedDict(TypedDict):
3529
+ type: UpdateAgentLoadBalancerAgentsResponseType
3530
+ models: List[UpdateAgentLoadBalancerAgentsResponseModelsTypedDict]
2320
3531
 
2321
3532
 
2322
- UpdateAgentIDAgentsResponse1 = Literal[
2323
- "orq_pii_detection",
2324
- "orq_sexual_moderation",
2325
- "orq_harmful_moderation",
2326
- ]
2327
- r"""The key of the guardrail."""
3533
+ class UpdateAgentLoadBalancerAgentsResponse1(BaseModel):
3534
+ type: UpdateAgentLoadBalancerAgentsResponseType
2328
3535
 
3536
+ models: List[UpdateAgentLoadBalancerAgentsResponseModels]
2329
3537
 
2330
- UpdateAgentIDTypedDict = TypeAliasType(
2331
- "UpdateAgentIDTypedDict", Union[UpdateAgentIDAgentsResponse1, str]
2332
- )
2333
3538
 
3539
+ UpdateAgentLoadBalancerTypedDict = UpdateAgentLoadBalancerAgentsResponse1TypedDict
3540
+ r"""Load balancer configuration for the request."""
2334
3541
 
2335
- UpdateAgentID = TypeAliasType("UpdateAgentID", Union[UpdateAgentIDAgentsResponse1, str])
2336
3542
 
3543
+ UpdateAgentLoadBalancer = UpdateAgentLoadBalancerAgentsResponse1
3544
+ r"""Load balancer configuration for the request."""
2337
3545
 
2338
- UpdateAgentAgentsResponse200ApplicationJSONExecuteOn = Literal[
2339
- "input",
2340
- "output",
2341
- ]
2342
- r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
2343
3546
 
3547
+ class UpdateAgentTimeoutTypedDict(TypedDict):
3548
+ 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."""
2344
3549
 
2345
- class UpdateAgentAgentsResponseGuardrailsTypedDict(TypedDict):
2346
- id: UpdateAgentIDTypedDict
2347
- execute_on: UpdateAgentAgentsResponse200ApplicationJSONExecuteOn
2348
- r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3550
+ call_timeout: float
3551
+ r"""Timeout value in milliseconds"""
2349
3552
 
2350
3553
 
2351
- class UpdateAgentAgentsResponseGuardrails(BaseModel):
2352
- id: UpdateAgentID
3554
+ class UpdateAgentTimeout(BaseModel):
3555
+ 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."""
2353
3556
 
2354
- execute_on: UpdateAgentAgentsResponse200ApplicationJSONExecuteOn
2355
- r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
3557
+ call_timeout: float
3558
+ r"""Timeout value in milliseconds"""
2356
3559
 
2357
3560
 
2358
3561
  class UpdateAgentParametersTypedDict(TypedDict):
@@ -2412,6 +3615,16 @@ class UpdateAgentParametersTypedDict(TypedDict):
2412
3615
  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\"]."""
2413
3616
  guardrails: NotRequired[List[UpdateAgentAgentsResponseGuardrailsTypedDict]]
2414
3617
  r"""A list of guardrails to apply to the request."""
3618
+ fallbacks: NotRequired[List[UpdateAgentFallbacksTypedDict]]
3619
+ r"""Array of fallback models to use if primary model fails"""
3620
+ retry: NotRequired[UpdateAgentAgentsRetryTypedDict]
3621
+ r"""Retry configuration for the request"""
3622
+ cache: NotRequired[UpdateAgentCacheTypedDict]
3623
+ r"""Cache configuration for the request."""
3624
+ load_balancer: NotRequired[UpdateAgentLoadBalancerTypedDict]
3625
+ r"""Load balancer configuration for the request."""
3626
+ timeout: NotRequired[UpdateAgentTimeoutTypedDict]
3627
+ 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."""
2415
3628
 
2416
3629
 
2417
3630
  class UpdateAgentParameters(BaseModel):
@@ -2493,72 +3706,91 @@ class UpdateAgentParameters(BaseModel):
2493
3706
  guardrails: Optional[List[UpdateAgentAgentsResponseGuardrails]] = None
2494
3707
  r"""A list of guardrails to apply to the request."""
2495
3708
 
3709
+ fallbacks: Optional[List[UpdateAgentFallbacks]] = None
3710
+ r"""Array of fallback models to use if primary model fails"""
3711
+
3712
+ retry: Optional[UpdateAgentAgentsRetry] = None
3713
+ r"""Retry configuration for the request"""
3714
+
3715
+ cache: Optional[UpdateAgentCache] = None
3716
+ r"""Cache configuration for the request."""
3717
+
3718
+ load_balancer: Optional[UpdateAgentLoadBalancer] = None
3719
+ r"""Load balancer configuration for the request."""
3720
+
3721
+ timeout: Optional[UpdateAgentTimeout] = None
3722
+ 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."""
3723
+
2496
3724
  @model_serializer(mode="wrap")
2497
3725
  def serialize_model(self, handler):
2498
- optional_fields = [
2499
- "audio",
2500
- "frequency_penalty",
2501
- "max_tokens",
2502
- "max_completion_tokens",
2503
- "logprobs",
2504
- "top_logprobs",
2505
- "n",
2506
- "presence_penalty",
2507
- "response_format",
2508
- "reasoning_effort",
2509
- "verbosity",
2510
- "seed",
2511
- "stop",
2512
- "stream_options",
2513
- "thinking",
2514
- "temperature",
2515
- "top_p",
2516
- "top_k",
2517
- "tool_choice",
2518
- "parallel_tool_calls",
2519
- "modalities",
2520
- "guardrails",
2521
- ]
2522
- nullable_fields = [
2523
- "audio",
2524
- "frequency_penalty",
2525
- "max_tokens",
2526
- "max_completion_tokens",
2527
- "logprobs",
2528
- "top_logprobs",
2529
- "n",
2530
- "presence_penalty",
2531
- "seed",
2532
- "stop",
2533
- "stream_options",
2534
- "temperature",
2535
- "top_p",
2536
- "top_k",
2537
- "modalities",
2538
- ]
2539
- null_default_fields = []
2540
-
3726
+ optional_fields = set(
3727
+ [
3728
+ "audio",
3729
+ "frequency_penalty",
3730
+ "max_tokens",
3731
+ "max_completion_tokens",
3732
+ "logprobs",
3733
+ "top_logprobs",
3734
+ "n",
3735
+ "presence_penalty",
3736
+ "response_format",
3737
+ "reasoning_effort",
3738
+ "verbosity",
3739
+ "seed",
3740
+ "stop",
3741
+ "stream_options",
3742
+ "thinking",
3743
+ "temperature",
3744
+ "top_p",
3745
+ "top_k",
3746
+ "tool_choice",
3747
+ "parallel_tool_calls",
3748
+ "modalities",
3749
+ "guardrails",
3750
+ "fallbacks",
3751
+ "retry",
3752
+ "cache",
3753
+ "load_balancer",
3754
+ "timeout",
3755
+ ]
3756
+ )
3757
+ nullable_fields = set(
3758
+ [
3759
+ "audio",
3760
+ "frequency_penalty",
3761
+ "max_tokens",
3762
+ "max_completion_tokens",
3763
+ "logprobs",
3764
+ "top_logprobs",
3765
+ "n",
3766
+ "presence_penalty",
3767
+ "seed",
3768
+ "stop",
3769
+ "stream_options",
3770
+ "temperature",
3771
+ "top_p",
3772
+ "top_k",
3773
+ "modalities",
3774
+ ]
3775
+ )
2541
3776
  serialized = handler(self)
2542
-
2543
3777
  m = {}
2544
3778
 
2545
3779
  for n, f in type(self).model_fields.items():
2546
3780
  k = f.alias or n
2547
3781
  val = serialized.get(k)
2548
- serialized.pop(k, None)
2549
-
2550
- optional_nullable = k in optional_fields and k in nullable_fields
2551
- is_set = (
2552
- self.__pydantic_fields_set__.intersection({n})
2553
- or k in null_default_fields
2554
- ) # pylint: disable=no-member
2555
-
2556
- if val is not None and val != UNSET_SENTINEL:
2557
- m[k] = val
2558
- elif val != UNSET_SENTINEL and (
2559
- not k in optional_fields or (optional_nullable and is_set)
2560
- ):
2561
- m[k] = val
3782
+ is_nullable_and_explicitly_set = (
3783
+ k in nullable_fields
3784
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
3785
+ )
3786
+
3787
+ if val != UNSET_SENTINEL:
3788
+ if (
3789
+ val is not None
3790
+ or k not in optional_fields
3791
+ or is_nullable_and_explicitly_set
3792
+ ):
3793
+ m[k] = val
2562
3794
 
2563
3795
  return m
2564
3796
 
@@ -2581,6 +3813,22 @@ class UpdateAgentRetry(BaseModel):
2581
3813
  on_codes: Optional[List[float]] = None
2582
3814
  r"""HTTP status codes that trigger retry logic"""
2583
3815
 
3816
+ @model_serializer(mode="wrap")
3817
+ def serialize_model(self, handler):
3818
+ optional_fields = set(["count", "on_codes"])
3819
+ serialized = handler(self)
3820
+ m = {}
3821
+
3822
+ for n, f in type(self).model_fields.items():
3823
+ k = f.alias or n
3824
+ val = serialized.get(k)
3825
+
3826
+ if val != UNSET_SENTINEL:
3827
+ if val is not None or k not in optional_fields:
3828
+ m[k] = val
3829
+
3830
+ return m
3831
+
2584
3832
 
2585
3833
  UpdateAgentFallbackModelConfigurationAgentsVoice = Literal[
2586
3834
  "alloy",
@@ -2656,6 +3904,22 @@ class UpdateAgentResponseFormatAgentsResponse200ApplicationJSONJSONSchema(BaseMo
2656
3904
  strict: Optional[bool] = False
2657
3905
  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."""
2658
3906
 
3907
+ @model_serializer(mode="wrap")
3908
+ def serialize_model(self, handler):
3909
+ optional_fields = set(["description", "schema", "strict"])
3910
+ serialized = handler(self)
3911
+ m = {}
3912
+
3913
+ for n, f in type(self).model_fields.items():
3914
+ k = f.alias or n
3915
+ val = serialized.get(k)
3916
+
3917
+ if val != UNSET_SENTINEL:
3918
+ if val is not None or k not in optional_fields:
3919
+ m[k] = val
3920
+
3921
+ return m
3922
+
2659
3923
 
2660
3924
  class UpdateAgentResponseFormatAgentsResponse200ApplicationJSONResponseBodyJSONSchemaTypedDict(
2661
3925
  TypedDict
@@ -2801,6 +4065,22 @@ class UpdateAgentFallbackModelConfigurationAgentsStreamOptions(BaseModel):
2801
4065
  include_usage: Optional[bool] = None
2802
4066
  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."""
2803
4067
 
4068
+ @model_serializer(mode="wrap")
4069
+ def serialize_model(self, handler):
4070
+ optional_fields = set(["include_usage"])
4071
+ serialized = handler(self)
4072
+ m = {}
4073
+
4074
+ for n, f in type(self).model_fields.items():
4075
+ k = f.alias or n
4076
+ val = serialized.get(k)
4077
+
4078
+ if val != UNSET_SENTINEL:
4079
+ if val is not None or k not in optional_fields:
4080
+ m[k] = val
4081
+
4082
+ return m
4083
+
2804
4084
 
2805
4085
  UpdateAgentFallbackModelConfigurationAgentsThinkingTypedDict = TypeAliasType(
2806
4086
  "UpdateAgentFallbackModelConfigurationAgentsThinkingTypedDict",
@@ -2843,6 +4123,22 @@ class UpdateAgentToolChoiceAgentsResponse2002(BaseModel):
2843
4123
  type: Optional[UpdateAgentToolChoiceAgentsResponse200Type] = None
2844
4124
  r"""The type of the tool. Currently, only function is supported."""
2845
4125
 
4126
+ @model_serializer(mode="wrap")
4127
+ def serialize_model(self, handler):
4128
+ optional_fields = set(["type"])
4129
+ serialized = handler(self)
4130
+ m = {}
4131
+
4132
+ for n, f in type(self).model_fields.items():
4133
+ k = f.alias or n
4134
+ val = serialized.get(k)
4135
+
4136
+ if val != UNSET_SENTINEL:
4137
+ if val is not None or k not in optional_fields:
4138
+ m[k] = val
4139
+
4140
+ return m
4141
+
2846
4142
 
2847
4143
  UpdateAgentToolChoiceAgentsResponse2001 = Literal[
2848
4144
  "none",
@@ -2916,6 +4212,158 @@ class UpdateAgentFallbackModelConfigurationAgentsGuardrails(BaseModel):
2916
4212
  r"""Determines whether the guardrail runs on the input (user message) or output (model response)."""
2917
4213
 
2918
4214
 
4215
+ class UpdateAgentFallbackModelConfigurationAgentsFallbacksTypedDict(TypedDict):
4216
+ model: str
4217
+ r"""Fallback model identifier"""
4218
+
4219
+
4220
+ class UpdateAgentFallbackModelConfigurationAgentsFallbacks(BaseModel):
4221
+ model: str
4222
+ r"""Fallback model identifier"""
4223
+
4224
+
4225
+ class UpdateAgentFallbackModelConfigurationAgentsResponse200RetryTypedDict(TypedDict):
4226
+ r"""Retry configuration for the request"""
4227
+
4228
+ count: NotRequired[float]
4229
+ r"""Number of retry attempts (1-5)"""
4230
+ on_codes: NotRequired[List[float]]
4231
+ r"""HTTP status codes that trigger retry logic"""
4232
+
4233
+
4234
+ class UpdateAgentFallbackModelConfigurationAgentsResponse200Retry(BaseModel):
4235
+ r"""Retry configuration for the request"""
4236
+
4237
+ count: Optional[float] = 3
4238
+ r"""Number of retry attempts (1-5)"""
4239
+
4240
+ on_codes: Optional[List[float]] = None
4241
+ r"""HTTP status codes that trigger retry logic"""
4242
+
4243
+ @model_serializer(mode="wrap")
4244
+ def serialize_model(self, handler):
4245
+ optional_fields = set(["count", "on_codes"])
4246
+ serialized = handler(self)
4247
+ m = {}
4248
+
4249
+ for n, f in type(self).model_fields.items():
4250
+ k = f.alias or n
4251
+ val = serialized.get(k)
4252
+
4253
+ if val != UNSET_SENTINEL:
4254
+ if val is not None or k not in optional_fields:
4255
+ m[k] = val
4256
+
4257
+ return m
4258
+
4259
+
4260
+ UpdateAgentFallbackModelConfigurationAgentsType = Literal["exact_match",]
4261
+
4262
+
4263
+ class UpdateAgentFallbackModelConfigurationAgentsCacheTypedDict(TypedDict):
4264
+ r"""Cache configuration for the request."""
4265
+
4266
+ type: UpdateAgentFallbackModelConfigurationAgentsType
4267
+ ttl: NotRequired[float]
4268
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
4269
+
4270
+
4271
+ class UpdateAgentFallbackModelConfigurationAgentsCache(BaseModel):
4272
+ r"""Cache configuration for the request."""
4273
+
4274
+ type: UpdateAgentFallbackModelConfigurationAgentsType
4275
+
4276
+ ttl: Optional[float] = 1800
4277
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
4278
+
4279
+ @model_serializer(mode="wrap")
4280
+ def serialize_model(self, handler):
4281
+ optional_fields = set(["ttl"])
4282
+ serialized = handler(self)
4283
+ m = {}
4284
+
4285
+ for n, f in type(self).model_fields.items():
4286
+ k = f.alias or n
4287
+ val = serialized.get(k)
4288
+
4289
+ if val != UNSET_SENTINEL:
4290
+ if val is not None or k not in optional_fields:
4291
+ m[k] = val
4292
+
4293
+ return m
4294
+
4295
+
4296
+ UpdateAgentLoadBalancerAgentsResponse200Type = Literal["weight_based",]
4297
+
4298
+
4299
+ class UpdateAgentLoadBalancerAgentsResponse200ModelsTypedDict(TypedDict):
4300
+ model: str
4301
+ r"""Model identifier for load balancing"""
4302
+ weight: NotRequired[float]
4303
+ r"""Weight assigned to this model for load balancing"""
4304
+
4305
+
4306
+ class UpdateAgentLoadBalancerAgentsResponse200Models(BaseModel):
4307
+ model: str
4308
+ r"""Model identifier for load balancing"""
4309
+
4310
+ weight: Optional[float] = 0.5
4311
+ r"""Weight assigned to this model for load balancing"""
4312
+
4313
+ @model_serializer(mode="wrap")
4314
+ def serialize_model(self, handler):
4315
+ optional_fields = set(["weight"])
4316
+ serialized = handler(self)
4317
+ m = {}
4318
+
4319
+ for n, f in type(self).model_fields.items():
4320
+ k = f.alias or n
4321
+ val = serialized.get(k)
4322
+
4323
+ if val != UNSET_SENTINEL:
4324
+ if val is not None or k not in optional_fields:
4325
+ m[k] = val
4326
+
4327
+ return m
4328
+
4329
+
4330
+ class UpdateAgentLoadBalancerAgentsResponse2001TypedDict(TypedDict):
4331
+ type: UpdateAgentLoadBalancerAgentsResponse200Type
4332
+ models: List[UpdateAgentLoadBalancerAgentsResponse200ModelsTypedDict]
4333
+
4334
+
4335
+ class UpdateAgentLoadBalancerAgentsResponse2001(BaseModel):
4336
+ type: UpdateAgentLoadBalancerAgentsResponse200Type
4337
+
4338
+ models: List[UpdateAgentLoadBalancerAgentsResponse200Models]
4339
+
4340
+
4341
+ UpdateAgentFallbackModelConfigurationAgentsLoadBalancerTypedDict = (
4342
+ UpdateAgentLoadBalancerAgentsResponse2001TypedDict
4343
+ )
4344
+ r"""Load balancer configuration for the request."""
4345
+
4346
+
4347
+ UpdateAgentFallbackModelConfigurationAgentsLoadBalancer = (
4348
+ UpdateAgentLoadBalancerAgentsResponse2001
4349
+ )
4350
+ r"""Load balancer configuration for the request."""
4351
+
4352
+
4353
+ class UpdateAgentFallbackModelConfigurationAgentsTimeoutTypedDict(TypedDict):
4354
+ 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."""
4355
+
4356
+ call_timeout: float
4357
+ r"""Timeout value in milliseconds"""
4358
+
4359
+
4360
+ class UpdateAgentFallbackModelConfigurationAgentsTimeout(BaseModel):
4361
+ 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."""
4362
+
4363
+ call_timeout: float
4364
+ r"""Timeout value in milliseconds"""
4365
+
4366
+
2919
4367
  class UpdateAgentFallbackModelConfigurationAgentsParametersTypedDict(TypedDict):
2920
4368
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
2921
4369
 
@@ -2989,6 +4437,22 @@ class UpdateAgentFallbackModelConfigurationAgentsParametersTypedDict(TypedDict):
2989
4437
  List[UpdateAgentFallbackModelConfigurationAgentsGuardrailsTypedDict]
2990
4438
  ]
2991
4439
  r"""A list of guardrails to apply to the request."""
4440
+ fallbacks: NotRequired[
4441
+ List[UpdateAgentFallbackModelConfigurationAgentsFallbacksTypedDict]
4442
+ ]
4443
+ r"""Array of fallback models to use if primary model fails"""
4444
+ retry: NotRequired[
4445
+ UpdateAgentFallbackModelConfigurationAgentsResponse200RetryTypedDict
4446
+ ]
4447
+ r"""Retry configuration for the request"""
4448
+ cache: NotRequired[UpdateAgentFallbackModelConfigurationAgentsCacheTypedDict]
4449
+ r"""Cache configuration for the request."""
4450
+ load_balancer: NotRequired[
4451
+ UpdateAgentFallbackModelConfigurationAgentsLoadBalancerTypedDict
4452
+ ]
4453
+ r"""Load balancer configuration for the request."""
4454
+ timeout: NotRequired[UpdateAgentFallbackModelConfigurationAgentsTimeoutTypedDict]
4455
+ 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."""
2992
4456
 
2993
4457
 
2994
4458
  class UpdateAgentFallbackModelConfigurationAgentsParameters(BaseModel):
@@ -3080,77 +4544,100 @@ class UpdateAgentFallbackModelConfigurationAgentsParameters(BaseModel):
3080
4544
  ] = None
3081
4545
  r"""A list of guardrails to apply to the request."""
3082
4546
 
4547
+ fallbacks: Optional[List[UpdateAgentFallbackModelConfigurationAgentsFallbacks]] = (
4548
+ None
4549
+ )
4550
+ r"""Array of fallback models to use if primary model fails"""
4551
+
4552
+ retry: Optional[UpdateAgentFallbackModelConfigurationAgentsResponse200Retry] = None
4553
+ r"""Retry configuration for the request"""
4554
+
4555
+ cache: Optional[UpdateAgentFallbackModelConfigurationAgentsCache] = None
4556
+ r"""Cache configuration for the request."""
4557
+
4558
+ load_balancer: Optional[UpdateAgentFallbackModelConfigurationAgentsLoadBalancer] = (
4559
+ None
4560
+ )
4561
+ r"""Load balancer configuration for the request."""
4562
+
4563
+ timeout: Optional[UpdateAgentFallbackModelConfigurationAgentsTimeout] = None
4564
+ 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."""
4565
+
3083
4566
  @model_serializer(mode="wrap")
3084
4567
  def serialize_model(self, handler):
3085
- optional_fields = [
3086
- "audio",
3087
- "frequency_penalty",
3088
- "max_tokens",
3089
- "max_completion_tokens",
3090
- "logprobs",
3091
- "top_logprobs",
3092
- "n",
3093
- "presence_penalty",
3094
- "response_format",
3095
- "reasoning_effort",
3096
- "verbosity",
3097
- "seed",
3098
- "stop",
3099
- "stream_options",
3100
- "thinking",
3101
- "temperature",
3102
- "top_p",
3103
- "top_k",
3104
- "tool_choice",
3105
- "parallel_tool_calls",
3106
- "modalities",
3107
- "guardrails",
3108
- ]
3109
- nullable_fields = [
3110
- "audio",
3111
- "frequency_penalty",
3112
- "max_tokens",
3113
- "max_completion_tokens",
3114
- "logprobs",
3115
- "top_logprobs",
3116
- "n",
3117
- "presence_penalty",
3118
- "seed",
3119
- "stop",
3120
- "stream_options",
3121
- "temperature",
3122
- "top_p",
3123
- "top_k",
3124
- "modalities",
3125
- ]
3126
- null_default_fields = []
3127
-
4568
+ optional_fields = set(
4569
+ [
4570
+ "audio",
4571
+ "frequency_penalty",
4572
+ "max_tokens",
4573
+ "max_completion_tokens",
4574
+ "logprobs",
4575
+ "top_logprobs",
4576
+ "n",
4577
+ "presence_penalty",
4578
+ "response_format",
4579
+ "reasoning_effort",
4580
+ "verbosity",
4581
+ "seed",
4582
+ "stop",
4583
+ "stream_options",
4584
+ "thinking",
4585
+ "temperature",
4586
+ "top_p",
4587
+ "top_k",
4588
+ "tool_choice",
4589
+ "parallel_tool_calls",
4590
+ "modalities",
4591
+ "guardrails",
4592
+ "fallbacks",
4593
+ "retry",
4594
+ "cache",
4595
+ "load_balancer",
4596
+ "timeout",
4597
+ ]
4598
+ )
4599
+ nullable_fields = set(
4600
+ [
4601
+ "audio",
4602
+ "frequency_penalty",
4603
+ "max_tokens",
4604
+ "max_completion_tokens",
4605
+ "logprobs",
4606
+ "top_logprobs",
4607
+ "n",
4608
+ "presence_penalty",
4609
+ "seed",
4610
+ "stop",
4611
+ "stream_options",
4612
+ "temperature",
4613
+ "top_p",
4614
+ "top_k",
4615
+ "modalities",
4616
+ ]
4617
+ )
3128
4618
  serialized = handler(self)
3129
-
3130
4619
  m = {}
3131
4620
 
3132
4621
  for n, f in type(self).model_fields.items():
3133
4622
  k = f.alias or n
3134
4623
  val = serialized.get(k)
3135
- serialized.pop(k, None)
3136
-
3137
- optional_nullable = k in optional_fields and k in nullable_fields
3138
- is_set = (
3139
- self.__pydantic_fields_set__.intersection({n})
3140
- or k in null_default_fields
3141
- ) # pylint: disable=no-member
3142
-
3143
- if val is not None and val != UNSET_SENTINEL:
3144
- m[k] = val
3145
- elif val != UNSET_SENTINEL and (
3146
- not k in optional_fields or (optional_nullable and is_set)
3147
- ):
3148
- m[k] = val
4624
+ is_nullable_and_explicitly_set = (
4625
+ k in nullable_fields
4626
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
4627
+ )
4628
+
4629
+ if val != UNSET_SENTINEL:
4630
+ if (
4631
+ val is not None
4632
+ or k not in optional_fields
4633
+ or is_nullable_and_explicitly_set
4634
+ ):
4635
+ m[k] = val
3149
4636
 
3150
4637
  return m
3151
4638
 
3152
4639
 
3153
- class UpdateAgentFallbackModelConfigurationAgentsRetryTypedDict(TypedDict):
4640
+ class UpdateAgentFallbackModelConfigurationAgentsResponseRetryTypedDict(TypedDict):
3154
4641
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3155
4642
 
3156
4643
  count: NotRequired[float]
@@ -3159,7 +4646,7 @@ class UpdateAgentFallbackModelConfigurationAgentsRetryTypedDict(TypedDict):
3159
4646
  r"""HTTP status codes that trigger retry logic"""
3160
4647
 
3161
4648
 
3162
- class UpdateAgentFallbackModelConfigurationAgentsRetry(BaseModel):
4649
+ class UpdateAgentFallbackModelConfigurationAgentsResponseRetry(BaseModel):
3163
4650
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3164
4651
 
3165
4652
  count: Optional[float] = 3
@@ -3168,6 +4655,22 @@ class UpdateAgentFallbackModelConfigurationAgentsRetry(BaseModel):
3168
4655
  on_codes: Optional[List[float]] = None
3169
4656
  r"""HTTP status codes that trigger retry logic"""
3170
4657
 
4658
+ @model_serializer(mode="wrap")
4659
+ def serialize_model(self, handler):
4660
+ optional_fields = set(["count", "on_codes"])
4661
+ serialized = handler(self)
4662
+ m = {}
4663
+
4664
+ for n, f in type(self).model_fields.items():
4665
+ k = f.alias or n
4666
+ val = serialized.get(k)
4667
+
4668
+ if val != UNSET_SENTINEL:
4669
+ if val is not None or k not in optional_fields:
4670
+ m[k] = val
4671
+
4672
+ return m
4673
+
3171
4674
 
3172
4675
  class UpdateAgentFallbackModelConfigurationAgents2TypedDict(TypedDict):
3173
4676
  r"""Fallback model configuration with optional parameters and retry settings."""
@@ -3178,7 +4681,9 @@ class UpdateAgentFallbackModelConfigurationAgents2TypedDict(TypedDict):
3178
4681
  UpdateAgentFallbackModelConfigurationAgentsParametersTypedDict
3179
4682
  ]
3180
4683
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
3181
- retry: NotRequired[UpdateAgentFallbackModelConfigurationAgentsRetryTypedDict]
4684
+ retry: NotRequired[
4685
+ UpdateAgentFallbackModelConfigurationAgentsResponseRetryTypedDict
4686
+ ]
3182
4687
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3183
4688
 
3184
4689
 
@@ -3191,9 +4696,25 @@ class UpdateAgentFallbackModelConfigurationAgents2(BaseModel):
3191
4696
  parameters: Optional[UpdateAgentFallbackModelConfigurationAgentsParameters] = None
3192
4697
  r"""Optional model parameters specific to this fallback model. Overrides primary model parameters if this fallback is used."""
3193
4698
 
3194
- retry: Optional[UpdateAgentFallbackModelConfigurationAgentsRetry] = None
4699
+ retry: Optional[UpdateAgentFallbackModelConfigurationAgentsResponseRetry] = None
3195
4700
  r"""Retry configuration for this fallback model. Allows customizing retry count (1-5) and HTTP status codes that trigger retries."""
3196
4701
 
4702
+ @model_serializer(mode="wrap")
4703
+ def serialize_model(self, handler):
4704
+ optional_fields = set(["parameters", "retry"])
4705
+ serialized = handler(self)
4706
+ m = {}
4707
+
4708
+ for n, f in type(self).model_fields.items():
4709
+ k = f.alias or n
4710
+ val = serialized.get(k)
4711
+
4712
+ if val != UNSET_SENTINEL:
4713
+ if val is not None or k not in optional_fields:
4714
+ m[k] = val
4715
+
4716
+ return m
4717
+
3197
4718
 
3198
4719
  UpdateAgentAgentsFallbackModelConfigurationTypedDict = TypeAliasType(
3199
4720
  "UpdateAgentAgentsFallbackModelConfigurationTypedDict",
@@ -3244,31 +4765,28 @@ class UpdateAgentModel(BaseModel):
3244
4765
 
3245
4766
  @model_serializer(mode="wrap")
3246
4767
  def serialize_model(self, handler):
3247
- optional_fields = ["integration_id", "parameters", "retry", "fallback_models"]
3248
- nullable_fields = ["integration_id", "fallback_models"]
3249
- null_default_fields = []
3250
-
4768
+ optional_fields = set(
4769
+ ["integration_id", "parameters", "retry", "fallback_models"]
4770
+ )
4771
+ nullable_fields = set(["integration_id", "fallback_models"])
3251
4772
  serialized = handler(self)
3252
-
3253
4773
  m = {}
3254
4774
 
3255
4775
  for n, f in type(self).model_fields.items():
3256
4776
  k = f.alias or n
3257
4777
  val = serialized.get(k)
3258
- serialized.pop(k, None)
3259
-
3260
- optional_nullable = k in optional_fields and k in nullable_fields
3261
- is_set = (
3262
- self.__pydantic_fields_set__.intersection({n})
3263
- or k in null_default_fields
3264
- ) # pylint: disable=no-member
3265
-
3266
- if val is not None and val != UNSET_SENTINEL:
3267
- m[k] = val
3268
- elif val != UNSET_SENTINEL and (
3269
- not k in optional_fields or (optional_nullable and is_set)
3270
- ):
3271
- m[k] = val
4778
+ is_nullable_and_explicitly_set = (
4779
+ k in nullable_fields
4780
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
4781
+ )
4782
+
4783
+ if val != UNSET_SENTINEL:
4784
+ if (
4785
+ val is not None
4786
+ or k not in optional_fields
4787
+ or is_nullable_and_explicitly_set
4788
+ ):
4789
+ m[k] = val
3272
4790
 
3273
4791
  return m
3274
4792
 
@@ -3287,6 +4805,22 @@ class UpdateAgentAgentsTeamOfAgents(BaseModel):
3287
4805
  role: Optional[str] = None
3288
4806
  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."""
3289
4807
 
4808
+ @model_serializer(mode="wrap")
4809
+ def serialize_model(self, handler):
4810
+ optional_fields = set(["role"])
4811
+ serialized = handler(self)
4812
+ m = {}
4813
+
4814
+ for n, f in type(self).model_fields.items():
4815
+ k = f.alias or n
4816
+ val = serialized.get(k)
4817
+
4818
+ if val != UNSET_SENTINEL:
4819
+ if val is not None or k not in optional_fields:
4820
+ m[k] = val
4821
+
4822
+ return m
4823
+
3290
4824
 
3291
4825
  class UpdateAgentMetricsTypedDict(TypedDict):
3292
4826
  total_cost: NotRequired[float]
@@ -3295,6 +4829,22 @@ class UpdateAgentMetricsTypedDict(TypedDict):
3295
4829
  class UpdateAgentMetrics(BaseModel):
3296
4830
  total_cost: Optional[float] = 0
3297
4831
 
4832
+ @model_serializer(mode="wrap")
4833
+ def serialize_model(self, handler):
4834
+ optional_fields = set(["total_cost"])
4835
+ serialized = handler(self)
4836
+ m = {}
4837
+
4838
+ for n, f in type(self).model_fields.items():
4839
+ k = f.alias or n
4840
+ val = serialized.get(k)
4841
+
4842
+ if val != UNSET_SENTINEL:
4843
+ if val is not None or k not in optional_fields:
4844
+ m[k] = val
4845
+
4846
+ return m
4847
+
3298
4848
 
3299
4849
  class UpdateAgentAgentsKnowledgeBasesTypedDict(TypedDict):
3300
4850
  knowledge_id: str
@@ -3419,42 +4969,39 @@ class UpdateAgentResponseBody(BaseModel):
3419
4969
 
3420
4970
  @model_serializer(mode="wrap")
3421
4971
  def serialize_model(self, handler):
3422
- optional_fields = [
3423
- "created_by_id",
3424
- "updated_by_id",
3425
- "created",
3426
- "updated",
3427
- "system_prompt",
3428
- "settings",
3429
- "version_hash",
3430
- "metrics",
3431
- "variables",
3432
- "knowledge_bases",
3433
- "source",
3434
- ]
3435
- nullable_fields = ["created_by_id", "updated_by_id"]
3436
- null_default_fields = []
3437
-
4972
+ optional_fields = set(
4973
+ [
4974
+ "created_by_id",
4975
+ "updated_by_id",
4976
+ "created",
4977
+ "updated",
4978
+ "system_prompt",
4979
+ "settings",
4980
+ "version_hash",
4981
+ "metrics",
4982
+ "variables",
4983
+ "knowledge_bases",
4984
+ "source",
4985
+ ]
4986
+ )
4987
+ nullable_fields = set(["created_by_id", "updated_by_id"])
3438
4988
  serialized = handler(self)
3439
-
3440
4989
  m = {}
3441
4990
 
3442
4991
  for n, f in type(self).model_fields.items():
3443
4992
  k = f.alias or n
3444
4993
  val = serialized.get(k)
3445
- serialized.pop(k, None)
3446
-
3447
- optional_nullable = k in optional_fields and k in nullable_fields
3448
- is_set = (
3449
- self.__pydantic_fields_set__.intersection({n})
3450
- or k in null_default_fields
3451
- ) # pylint: disable=no-member
3452
-
3453
- if val is not None and val != UNSET_SENTINEL:
3454
- m[k] = val
3455
- elif val != UNSET_SENTINEL and (
3456
- not k in optional_fields or (optional_nullable and is_set)
3457
- ):
3458
- m[k] = val
4994
+ is_nullable_and_explicitly_set = (
4995
+ k in nullable_fields
4996
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
4997
+ )
4998
+
4999
+ if val != UNSET_SENTINEL:
5000
+ if (
5001
+ val is not None
5002
+ or k not in optional_fields
5003
+ or is_nullable_and_explicitly_set
5004
+ ):
5005
+ m[k] = val
3459
5006
 
3460
5007
  return m