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
@@ -0,0 +1,1890 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .publiccontact import PublicContact, PublicContactTypedDict
5
+ from .publicidentity import PublicIdentity, PublicIdentityTypedDict
6
+ from orq_ai_sdk.types import (
7
+ BaseModel,
8
+ Nullable,
9
+ OptionalNullable,
10
+ UNSET,
11
+ UNSET_SENTINEL,
12
+ )
13
+ from orq_ai_sdk.utils import eventstreaming
14
+ import pydantic
15
+ from pydantic import model_serializer
16
+ from typing import Any, Dict, List, Literal, Optional, Union
17
+ from typing_extensions import (
18
+ Annotated,
19
+ NotRequired,
20
+ TypeAliasType,
21
+ TypedDict,
22
+ deprecated,
23
+ )
24
+
25
+
26
+ CreateCompletionStopTypedDict = TypeAliasType(
27
+ "CreateCompletionStopTypedDict", Union[str, List[str]]
28
+ )
29
+ r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
30
+
31
+
32
+ CreateCompletionStop = TypeAliasType("CreateCompletionStop", Union[str, List[str]])
33
+ r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
34
+
35
+
36
+ class CreateCompletionRetryTypedDict(TypedDict):
37
+ r"""Retry configuration for the request"""
38
+
39
+ count: NotRequired[float]
40
+ r"""Number of retry attempts (1-5)"""
41
+ on_codes: NotRequired[List[float]]
42
+ r"""HTTP status codes that trigger retry logic"""
43
+
44
+
45
+ class CreateCompletionRetry(BaseModel):
46
+ r"""Retry configuration for the request"""
47
+
48
+ count: Optional[float] = 3
49
+ r"""Number of retry attempts (1-5)"""
50
+
51
+ on_codes: Optional[List[float]] = None
52
+ r"""HTTP status codes that trigger retry logic"""
53
+
54
+ @model_serializer(mode="wrap")
55
+ def serialize_model(self, handler):
56
+ optional_fields = set(["count", "on_codes"])
57
+ serialized = handler(self)
58
+ m = {}
59
+
60
+ for n, f in type(self).model_fields.items():
61
+ k = f.alias or n
62
+ val = serialized.get(k)
63
+
64
+ if val != UNSET_SENTINEL:
65
+ if val is not None or k not in optional_fields:
66
+ m[k] = val
67
+
68
+ return m
69
+
70
+
71
+ class CreateCompletionFallbacksTypedDict(TypedDict):
72
+ model: str
73
+ r"""Fallback model identifier"""
74
+
75
+
76
+ class CreateCompletionFallbacks(BaseModel):
77
+ model: str
78
+ r"""Fallback model identifier"""
79
+
80
+
81
+ CreateCompletionVersion = Literal["latest",]
82
+ r"""Version of the prompt to use (currently only \"latest\" supported)"""
83
+
84
+
85
+ class CreateCompletionPromptTypedDict(TypedDict):
86
+ r"""Prompt configuration for the request"""
87
+
88
+ id: str
89
+ r"""Unique identifier of the prompt to use"""
90
+ version: CreateCompletionVersion
91
+ r"""Version of the prompt to use (currently only \"latest\" supported)"""
92
+
93
+
94
+ class CreateCompletionPrompt(BaseModel):
95
+ r"""Prompt configuration for the request"""
96
+
97
+ id: str
98
+ r"""Unique identifier of the prompt to use"""
99
+
100
+ version: CreateCompletionVersion
101
+ r"""Version of the prompt to use (currently only \"latest\" supported)"""
102
+
103
+
104
+ class CreateCompletionThreadTypedDict(TypedDict):
105
+ r"""Thread information to group related requests"""
106
+
107
+ id: str
108
+ r"""Unique thread identifier to group related invocations."""
109
+ tags: NotRequired[List[str]]
110
+ r"""Optional tags to differentiate or categorize threads"""
111
+
112
+
113
+ class CreateCompletionThread(BaseModel):
114
+ r"""Thread information to group related requests"""
115
+
116
+ id: str
117
+ r"""Unique thread identifier to group related invocations."""
118
+
119
+ tags: Optional[List[str]] = None
120
+ r"""Optional tags to differentiate or categorize threads"""
121
+
122
+ @model_serializer(mode="wrap")
123
+ def serialize_model(self, handler):
124
+ optional_fields = set(["tags"])
125
+ serialized = handler(self)
126
+ m = {}
127
+
128
+ for n, f in type(self).model_fields.items():
129
+ k = f.alias or n
130
+ val = serialized.get(k)
131
+
132
+ if val != UNSET_SENTINEL:
133
+ if val is not None or k not in optional_fields:
134
+ m[k] = val
135
+
136
+ return m
137
+
138
+
139
+ class CreateCompletionInputs2TypedDict(TypedDict):
140
+ key: str
141
+ value: NotRequired[Any]
142
+ is_pii: NotRequired[bool]
143
+
144
+
145
+ class CreateCompletionInputs2(BaseModel):
146
+ key: str
147
+
148
+ value: Optional[Any] = None
149
+
150
+ is_pii: Optional[bool] = None
151
+
152
+ @model_serializer(mode="wrap")
153
+ def serialize_model(self, handler):
154
+ optional_fields = set(["value", "is_pii"])
155
+ serialized = handler(self)
156
+ m = {}
157
+
158
+ for n, f in type(self).model_fields.items():
159
+ k = f.alias or n
160
+ val = serialized.get(k)
161
+
162
+ if val != UNSET_SENTINEL:
163
+ if val is not None or k not in optional_fields:
164
+ m[k] = val
165
+
166
+ return m
167
+
168
+
169
+ CreateCompletionInputsTypedDict = TypeAliasType(
170
+ "CreateCompletionInputsTypedDict",
171
+ Union[Dict[str, Any], List[CreateCompletionInputs2TypedDict]],
172
+ )
173
+ r"""Values to replace in the prompt messages using {{variableName}} syntax"""
174
+
175
+
176
+ CreateCompletionInputs = TypeAliasType(
177
+ "CreateCompletionInputs", Union[Dict[str, Any], List[CreateCompletionInputs2]]
178
+ )
179
+ r"""Values to replace in the prompt messages using {{variableName}} syntax"""
180
+
181
+
182
+ CreateCompletionType = Literal["exact_match",]
183
+
184
+
185
+ class CreateCompletionCacheTypedDict(TypedDict):
186
+ r"""Cache configuration for the request."""
187
+
188
+ type: CreateCompletionType
189
+ ttl: NotRequired[float]
190
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
191
+
192
+
193
+ class CreateCompletionCache(BaseModel):
194
+ r"""Cache configuration for the request."""
195
+
196
+ type: CreateCompletionType
197
+
198
+ ttl: Optional[float] = 1800
199
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
200
+
201
+ @model_serializer(mode="wrap")
202
+ def serialize_model(self, handler):
203
+ optional_fields = set(["ttl"])
204
+ serialized = handler(self)
205
+ m = {}
206
+
207
+ for n, f in type(self).model_fields.items():
208
+ k = f.alias or n
209
+ val = serialized.get(k)
210
+
211
+ if val != UNSET_SENTINEL:
212
+ if val is not None or k not in optional_fields:
213
+ m[k] = val
214
+
215
+ return m
216
+
217
+
218
+ CreateCompletionSearchType = Literal[
219
+ "vector_search",
220
+ "keyword_search",
221
+ "hybrid_search",
222
+ ]
223
+ r"""The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`"""
224
+
225
+
226
+ class CreateCompletionOrExistsTypedDict(TypedDict):
227
+ r"""Exists"""
228
+
229
+ exists: bool
230
+
231
+
232
+ class CreateCompletionOrExists(BaseModel):
233
+ r"""Exists"""
234
+
235
+ exists: bool
236
+
237
+
238
+ CreateCompletionOrRouterCompletionsNinTypedDict = TypeAliasType(
239
+ "CreateCompletionOrRouterCompletionsNinTypedDict", Union[str, float, bool]
240
+ )
241
+
242
+
243
+ CreateCompletionOrRouterCompletionsNin = TypeAliasType(
244
+ "CreateCompletionOrRouterCompletionsNin", Union[str, float, bool]
245
+ )
246
+
247
+
248
+ class CreateCompletionOrNinTypedDict(TypedDict):
249
+ r"""Not in"""
250
+
251
+ nin: List[CreateCompletionOrRouterCompletionsNinTypedDict]
252
+
253
+
254
+ class CreateCompletionOrNin(BaseModel):
255
+ r"""Not in"""
256
+
257
+ nin: List[CreateCompletionOrRouterCompletionsNin]
258
+
259
+
260
+ CreateCompletionOrRouterCompletionsInTypedDict = TypeAliasType(
261
+ "CreateCompletionOrRouterCompletionsInTypedDict", Union[str, float, bool]
262
+ )
263
+
264
+
265
+ CreateCompletionOrRouterCompletionsIn = TypeAliasType(
266
+ "CreateCompletionOrRouterCompletionsIn", Union[str, float, bool]
267
+ )
268
+
269
+
270
+ class CreateCompletionOrInTypedDict(TypedDict):
271
+ r"""In"""
272
+
273
+ in_: List[CreateCompletionOrRouterCompletionsInTypedDict]
274
+
275
+
276
+ class CreateCompletionOrIn(BaseModel):
277
+ r"""In"""
278
+
279
+ in_: Annotated[
280
+ List[CreateCompletionOrRouterCompletionsIn], pydantic.Field(alias="in")
281
+ ]
282
+
283
+
284
+ class CreateCompletionOrLteTypedDict(TypedDict):
285
+ r"""Less than or equal to"""
286
+
287
+ lte: float
288
+
289
+
290
+ class CreateCompletionOrLte(BaseModel):
291
+ r"""Less than or equal to"""
292
+
293
+ lte: float
294
+
295
+
296
+ class CreateCompletionOrLtTypedDict(TypedDict):
297
+ r"""Less than"""
298
+
299
+ lt: float
300
+
301
+
302
+ class CreateCompletionOrLt(BaseModel):
303
+ r"""Less than"""
304
+
305
+ lt: float
306
+
307
+
308
+ class CreateCompletionOrGteTypedDict(TypedDict):
309
+ r"""Greater than or equal to"""
310
+
311
+ gte: float
312
+
313
+
314
+ class CreateCompletionOrGte(BaseModel):
315
+ r"""Greater than or equal to"""
316
+
317
+ gte: float
318
+
319
+
320
+ class CreateCompletionOrGtTypedDict(TypedDict):
321
+ r"""Greater than"""
322
+
323
+ gt: float
324
+
325
+
326
+ class CreateCompletionOrGt(BaseModel):
327
+ r"""Greater than"""
328
+
329
+ gt: float
330
+
331
+
332
+ CreateCompletionOrRouterCompletionsNeTypedDict = TypeAliasType(
333
+ "CreateCompletionOrRouterCompletionsNeTypedDict", Union[str, float, bool]
334
+ )
335
+
336
+
337
+ CreateCompletionOrRouterCompletionsNe = TypeAliasType(
338
+ "CreateCompletionOrRouterCompletionsNe", Union[str, float, bool]
339
+ )
340
+
341
+
342
+ class CreateCompletionOrNeTypedDict(TypedDict):
343
+ r"""Not equal to"""
344
+
345
+ ne: CreateCompletionOrRouterCompletionsNeTypedDict
346
+
347
+
348
+ class CreateCompletionOrNe(BaseModel):
349
+ r"""Not equal to"""
350
+
351
+ ne: CreateCompletionOrRouterCompletionsNe
352
+
353
+
354
+ CreateCompletionOrRouterCompletionsEqTypedDict = TypeAliasType(
355
+ "CreateCompletionOrRouterCompletionsEqTypedDict", Union[str, float, bool]
356
+ )
357
+
358
+
359
+ CreateCompletionOrRouterCompletionsEq = TypeAliasType(
360
+ "CreateCompletionOrRouterCompletionsEq", Union[str, float, bool]
361
+ )
362
+
363
+
364
+ class CreateCompletionOrEqTypedDict(TypedDict):
365
+ r"""Equal to"""
366
+
367
+ eq: CreateCompletionOrRouterCompletionsEqTypedDict
368
+
369
+
370
+ class CreateCompletionOrEq(BaseModel):
371
+ r"""Equal to"""
372
+
373
+ eq: CreateCompletionOrRouterCompletionsEq
374
+
375
+
376
+ CreateCompletionFilterByRouterCompletionsOrTypedDict = TypeAliasType(
377
+ "CreateCompletionFilterByRouterCompletionsOrTypedDict",
378
+ Union[
379
+ CreateCompletionOrEqTypedDict,
380
+ CreateCompletionOrNeTypedDict,
381
+ CreateCompletionOrGtTypedDict,
382
+ CreateCompletionOrGteTypedDict,
383
+ CreateCompletionOrLtTypedDict,
384
+ CreateCompletionOrLteTypedDict,
385
+ CreateCompletionOrInTypedDict,
386
+ CreateCompletionOrNinTypedDict,
387
+ CreateCompletionOrExistsTypedDict,
388
+ ],
389
+ )
390
+
391
+
392
+ CreateCompletionFilterByRouterCompletionsOr = TypeAliasType(
393
+ "CreateCompletionFilterByRouterCompletionsOr",
394
+ Union[
395
+ CreateCompletionOrEq,
396
+ CreateCompletionOrNe,
397
+ CreateCompletionOrGt,
398
+ CreateCompletionOrGte,
399
+ CreateCompletionOrLt,
400
+ CreateCompletionOrLte,
401
+ CreateCompletionOrIn,
402
+ CreateCompletionOrNin,
403
+ CreateCompletionOrExists,
404
+ ],
405
+ )
406
+
407
+
408
+ class CreateCompletionFilterByOrTypedDict(TypedDict):
409
+ r"""Or"""
410
+
411
+ or_: List[Dict[str, CreateCompletionFilterByRouterCompletionsOrTypedDict]]
412
+
413
+
414
+ class CreateCompletionFilterByOr(BaseModel):
415
+ r"""Or"""
416
+
417
+ or_: Annotated[
418
+ List[Dict[str, CreateCompletionFilterByRouterCompletionsOr]],
419
+ pydantic.Field(alias="or"),
420
+ ]
421
+
422
+
423
+ class CreateCompletionAndExistsTypedDict(TypedDict):
424
+ r"""Exists"""
425
+
426
+ exists: bool
427
+
428
+
429
+ class CreateCompletionAndExists(BaseModel):
430
+ r"""Exists"""
431
+
432
+ exists: bool
433
+
434
+
435
+ CreateCompletionAndRouterCompletionsNinTypedDict = TypeAliasType(
436
+ "CreateCompletionAndRouterCompletionsNinTypedDict", Union[str, float, bool]
437
+ )
438
+
439
+
440
+ CreateCompletionAndRouterCompletionsNin = TypeAliasType(
441
+ "CreateCompletionAndRouterCompletionsNin", Union[str, float, bool]
442
+ )
443
+
444
+
445
+ class CreateCompletionAndNinTypedDict(TypedDict):
446
+ r"""Not in"""
447
+
448
+ nin: List[CreateCompletionAndRouterCompletionsNinTypedDict]
449
+
450
+
451
+ class CreateCompletionAndNin(BaseModel):
452
+ r"""Not in"""
453
+
454
+ nin: List[CreateCompletionAndRouterCompletionsNin]
455
+
456
+
457
+ CreateCompletionAndRouterCompletionsInTypedDict = TypeAliasType(
458
+ "CreateCompletionAndRouterCompletionsInTypedDict", Union[str, float, bool]
459
+ )
460
+
461
+
462
+ CreateCompletionAndRouterCompletionsIn = TypeAliasType(
463
+ "CreateCompletionAndRouterCompletionsIn", Union[str, float, bool]
464
+ )
465
+
466
+
467
+ class CreateCompletionAndInTypedDict(TypedDict):
468
+ r"""In"""
469
+
470
+ in_: List[CreateCompletionAndRouterCompletionsInTypedDict]
471
+
472
+
473
+ class CreateCompletionAndIn(BaseModel):
474
+ r"""In"""
475
+
476
+ in_: Annotated[
477
+ List[CreateCompletionAndRouterCompletionsIn], pydantic.Field(alias="in")
478
+ ]
479
+
480
+
481
+ class CreateCompletionAndLteTypedDict(TypedDict):
482
+ r"""Less than or equal to"""
483
+
484
+ lte: float
485
+
486
+
487
+ class CreateCompletionAndLte(BaseModel):
488
+ r"""Less than or equal to"""
489
+
490
+ lte: float
491
+
492
+
493
+ class CreateCompletionAndLtTypedDict(TypedDict):
494
+ r"""Less than"""
495
+
496
+ lt: float
497
+
498
+
499
+ class CreateCompletionAndLt(BaseModel):
500
+ r"""Less than"""
501
+
502
+ lt: float
503
+
504
+
505
+ class CreateCompletionAndGteTypedDict(TypedDict):
506
+ r"""Greater than or equal to"""
507
+
508
+ gte: float
509
+
510
+
511
+ class CreateCompletionAndGte(BaseModel):
512
+ r"""Greater than or equal to"""
513
+
514
+ gte: float
515
+
516
+
517
+ class CreateCompletionAndGtTypedDict(TypedDict):
518
+ r"""Greater than"""
519
+
520
+ gt: float
521
+
522
+
523
+ class CreateCompletionAndGt(BaseModel):
524
+ r"""Greater than"""
525
+
526
+ gt: float
527
+
528
+
529
+ CreateCompletionAndRouterCompletionsNeTypedDict = TypeAliasType(
530
+ "CreateCompletionAndRouterCompletionsNeTypedDict", Union[str, float, bool]
531
+ )
532
+
533
+
534
+ CreateCompletionAndRouterCompletionsNe = TypeAliasType(
535
+ "CreateCompletionAndRouterCompletionsNe", Union[str, float, bool]
536
+ )
537
+
538
+
539
+ class CreateCompletionAndNeTypedDict(TypedDict):
540
+ r"""Not equal to"""
541
+
542
+ ne: CreateCompletionAndRouterCompletionsNeTypedDict
543
+
544
+
545
+ class CreateCompletionAndNe(BaseModel):
546
+ r"""Not equal to"""
547
+
548
+ ne: CreateCompletionAndRouterCompletionsNe
549
+
550
+
551
+ CreateCompletionAndRouterCompletionsEqTypedDict = TypeAliasType(
552
+ "CreateCompletionAndRouterCompletionsEqTypedDict", Union[str, float, bool]
553
+ )
554
+
555
+
556
+ CreateCompletionAndRouterCompletionsEq = TypeAliasType(
557
+ "CreateCompletionAndRouterCompletionsEq", Union[str, float, bool]
558
+ )
559
+
560
+
561
+ class CreateCompletionAndEqTypedDict(TypedDict):
562
+ r"""Equal to"""
563
+
564
+ eq: CreateCompletionAndRouterCompletionsEqTypedDict
565
+
566
+
567
+ class CreateCompletionAndEq(BaseModel):
568
+ r"""Equal to"""
569
+
570
+ eq: CreateCompletionAndRouterCompletionsEq
571
+
572
+
573
+ CreateCompletionFilterByRouterCompletionsAndTypedDict = TypeAliasType(
574
+ "CreateCompletionFilterByRouterCompletionsAndTypedDict",
575
+ Union[
576
+ CreateCompletionAndEqTypedDict,
577
+ CreateCompletionAndNeTypedDict,
578
+ CreateCompletionAndGtTypedDict,
579
+ CreateCompletionAndGteTypedDict,
580
+ CreateCompletionAndLtTypedDict,
581
+ CreateCompletionAndLteTypedDict,
582
+ CreateCompletionAndInTypedDict,
583
+ CreateCompletionAndNinTypedDict,
584
+ CreateCompletionAndExistsTypedDict,
585
+ ],
586
+ )
587
+
588
+
589
+ CreateCompletionFilterByRouterCompletionsAnd = TypeAliasType(
590
+ "CreateCompletionFilterByRouterCompletionsAnd",
591
+ Union[
592
+ CreateCompletionAndEq,
593
+ CreateCompletionAndNe,
594
+ CreateCompletionAndGt,
595
+ CreateCompletionAndGte,
596
+ CreateCompletionAndLt,
597
+ CreateCompletionAndLte,
598
+ CreateCompletionAndIn,
599
+ CreateCompletionAndNin,
600
+ CreateCompletionAndExists,
601
+ ],
602
+ )
603
+
604
+
605
+ class CreateCompletionFilterByAndTypedDict(TypedDict):
606
+ r"""And"""
607
+
608
+ and_: List[Dict[str, CreateCompletionFilterByRouterCompletionsAndTypedDict]]
609
+
610
+
611
+ class CreateCompletionFilterByAnd(BaseModel):
612
+ r"""And"""
613
+
614
+ and_: Annotated[
615
+ List[Dict[str, CreateCompletionFilterByRouterCompletionsAnd]],
616
+ pydantic.Field(alias="and"),
617
+ ]
618
+
619
+
620
+ class CreateCompletion1ExistsTypedDict(TypedDict):
621
+ r"""Exists"""
622
+
623
+ exists: bool
624
+
625
+
626
+ class CreateCompletion1Exists(BaseModel):
627
+ r"""Exists"""
628
+
629
+ exists: bool
630
+
631
+
632
+ CreateCompletion1RouterCompletionsNinTypedDict = TypeAliasType(
633
+ "CreateCompletion1RouterCompletionsNinTypedDict", Union[str, float, bool]
634
+ )
635
+
636
+
637
+ CreateCompletion1RouterCompletionsNin = TypeAliasType(
638
+ "CreateCompletion1RouterCompletionsNin", Union[str, float, bool]
639
+ )
640
+
641
+
642
+ class CreateCompletion1NinTypedDict(TypedDict):
643
+ r"""Not in"""
644
+
645
+ nin: List[CreateCompletion1RouterCompletionsNinTypedDict]
646
+
647
+
648
+ class CreateCompletion1Nin(BaseModel):
649
+ r"""Not in"""
650
+
651
+ nin: List[CreateCompletion1RouterCompletionsNin]
652
+
653
+
654
+ CreateCompletion1RouterCompletionsInTypedDict = TypeAliasType(
655
+ "CreateCompletion1RouterCompletionsInTypedDict", Union[str, float, bool]
656
+ )
657
+
658
+
659
+ CreateCompletion1RouterCompletionsIn = TypeAliasType(
660
+ "CreateCompletion1RouterCompletionsIn", Union[str, float, bool]
661
+ )
662
+
663
+
664
+ class CreateCompletion1InTypedDict(TypedDict):
665
+ r"""In"""
666
+
667
+ in_: List[CreateCompletion1RouterCompletionsInTypedDict]
668
+
669
+
670
+ class CreateCompletion1In(BaseModel):
671
+ r"""In"""
672
+
673
+ in_: Annotated[
674
+ List[CreateCompletion1RouterCompletionsIn], pydantic.Field(alias="in")
675
+ ]
676
+
677
+
678
+ class CreateCompletion1LteTypedDict(TypedDict):
679
+ r"""Less than or equal to"""
680
+
681
+ lte: float
682
+
683
+
684
+ class CreateCompletion1Lte(BaseModel):
685
+ r"""Less than or equal to"""
686
+
687
+ lte: float
688
+
689
+
690
+ class CreateCompletion1LtTypedDict(TypedDict):
691
+ r"""Less than"""
692
+
693
+ lt: float
694
+
695
+
696
+ class CreateCompletion1Lt(BaseModel):
697
+ r"""Less than"""
698
+
699
+ lt: float
700
+
701
+
702
+ class CreateCompletion1GteTypedDict(TypedDict):
703
+ r"""Greater than or equal to"""
704
+
705
+ gte: float
706
+
707
+
708
+ class CreateCompletion1Gte(BaseModel):
709
+ r"""Greater than or equal to"""
710
+
711
+ gte: float
712
+
713
+
714
+ class CreateCompletion1GtTypedDict(TypedDict):
715
+ r"""Greater than"""
716
+
717
+ gt: float
718
+
719
+
720
+ class CreateCompletion1Gt(BaseModel):
721
+ r"""Greater than"""
722
+
723
+ gt: float
724
+
725
+
726
+ CreateCompletion1RouterCompletionsNeTypedDict = TypeAliasType(
727
+ "CreateCompletion1RouterCompletionsNeTypedDict", Union[str, float, bool]
728
+ )
729
+
730
+
731
+ CreateCompletion1RouterCompletionsNe = TypeAliasType(
732
+ "CreateCompletion1RouterCompletionsNe", Union[str, float, bool]
733
+ )
734
+
735
+
736
+ class CreateCompletion1NeTypedDict(TypedDict):
737
+ r"""Not equal to"""
738
+
739
+ ne: CreateCompletion1RouterCompletionsNeTypedDict
740
+
741
+
742
+ class CreateCompletion1Ne(BaseModel):
743
+ r"""Not equal to"""
744
+
745
+ ne: CreateCompletion1RouterCompletionsNe
746
+
747
+
748
+ CreateCompletion1RouterCompletionsEqTypedDict = TypeAliasType(
749
+ "CreateCompletion1RouterCompletionsEqTypedDict", Union[str, float, bool]
750
+ )
751
+
752
+
753
+ CreateCompletion1RouterCompletionsEq = TypeAliasType(
754
+ "CreateCompletion1RouterCompletionsEq", Union[str, float, bool]
755
+ )
756
+
757
+
758
+ class CreateCompletion1EqTypedDict(TypedDict):
759
+ r"""Equal to"""
760
+
761
+ eq: CreateCompletion1RouterCompletionsEqTypedDict
762
+
763
+
764
+ class CreateCompletion1Eq(BaseModel):
765
+ r"""Equal to"""
766
+
767
+ eq: CreateCompletion1RouterCompletionsEq
768
+
769
+
770
+ CreateCompletionFilterBy1TypedDict = TypeAliasType(
771
+ "CreateCompletionFilterBy1TypedDict",
772
+ Union[
773
+ CreateCompletion1EqTypedDict,
774
+ CreateCompletion1NeTypedDict,
775
+ CreateCompletion1GtTypedDict,
776
+ CreateCompletion1GteTypedDict,
777
+ CreateCompletion1LtTypedDict,
778
+ CreateCompletion1LteTypedDict,
779
+ CreateCompletion1InTypedDict,
780
+ CreateCompletion1NinTypedDict,
781
+ CreateCompletion1ExistsTypedDict,
782
+ ],
783
+ )
784
+
785
+
786
+ CreateCompletionFilterBy1 = TypeAliasType(
787
+ "CreateCompletionFilterBy1",
788
+ Union[
789
+ CreateCompletion1Eq,
790
+ CreateCompletion1Ne,
791
+ CreateCompletion1Gt,
792
+ CreateCompletion1Gte,
793
+ CreateCompletion1Lt,
794
+ CreateCompletion1Lte,
795
+ CreateCompletion1In,
796
+ CreateCompletion1Nin,
797
+ CreateCompletion1Exists,
798
+ ],
799
+ )
800
+
801
+
802
+ CreateCompletionFilterByTypedDict = TypeAliasType(
803
+ "CreateCompletionFilterByTypedDict",
804
+ Union[
805
+ CreateCompletionFilterByAndTypedDict,
806
+ CreateCompletionFilterByOrTypedDict,
807
+ Dict[str, CreateCompletionFilterBy1TypedDict],
808
+ ],
809
+ )
810
+ r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
811
+
812
+
813
+ CreateCompletionFilterBy = TypeAliasType(
814
+ "CreateCompletionFilterBy",
815
+ Union[
816
+ CreateCompletionFilterByAnd,
817
+ CreateCompletionFilterByOr,
818
+ Dict[str, CreateCompletionFilterBy1],
819
+ ],
820
+ )
821
+ r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
822
+
823
+
824
+ class CreateCompletionSearchOptionsTypedDict(TypedDict):
825
+ r"""Additional search options"""
826
+
827
+ include_vectors: NotRequired[bool]
828
+ r"""Whether to include the vector in the chunk"""
829
+ include_metadata: NotRequired[bool]
830
+ r"""Whether to include the metadata in the chunk"""
831
+ include_scores: NotRequired[bool]
832
+ r"""Whether to include the scores in the chunk"""
833
+
834
+
835
+ class CreateCompletionSearchOptions(BaseModel):
836
+ r"""Additional search options"""
837
+
838
+ include_vectors: Optional[bool] = None
839
+ r"""Whether to include the vector in the chunk"""
840
+
841
+ include_metadata: Optional[bool] = None
842
+ r"""Whether to include the metadata in the chunk"""
843
+
844
+ include_scores: Optional[bool] = None
845
+ r"""Whether to include the scores in the chunk"""
846
+
847
+ @model_serializer(mode="wrap")
848
+ def serialize_model(self, handler):
849
+ optional_fields = set(["include_vectors", "include_metadata", "include_scores"])
850
+ serialized = handler(self)
851
+ m = {}
852
+
853
+ for n, f in type(self).model_fields.items():
854
+ k = f.alias or n
855
+ val = serialized.get(k)
856
+
857
+ if val != UNSET_SENTINEL:
858
+ if val is not None or k not in optional_fields:
859
+ m[k] = val
860
+
861
+ return m
862
+
863
+
864
+ class CreateCompletionRerankConfigTypedDict(TypedDict):
865
+ r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
866
+
867
+ model: str
868
+ r"""The name of the rerank model to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/rerank-models)."""
869
+ threshold: NotRequired[float]
870
+ r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
871
+ top_k: NotRequired[int]
872
+ r"""The number of top results to return after reranking. If not provided, will default to the knowledge base configured `top_k`."""
873
+
874
+
875
+ class CreateCompletionRerankConfig(BaseModel):
876
+ r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
877
+
878
+ model: str
879
+ r"""The name of the rerank model to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/rerank-models)."""
880
+
881
+ threshold: Optional[float] = 0
882
+ r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
883
+
884
+ top_k: Optional[int] = 10
885
+ r"""The number of top results to return after reranking. If not provided, will default to the knowledge base configured `top_k`."""
886
+
887
+ @model_serializer(mode="wrap")
888
+ def serialize_model(self, handler):
889
+ optional_fields = set(["threshold", "top_k"])
890
+ serialized = handler(self)
891
+ m = {}
892
+
893
+ for n, f in type(self).model_fields.items():
894
+ k = f.alias or n
895
+ val = serialized.get(k)
896
+
897
+ if val != UNSET_SENTINEL:
898
+ if val is not None or k not in optional_fields:
899
+ m[k] = val
900
+
901
+ return m
902
+
903
+
904
+ class CreateCompletionAgenticRagConfigTypedDict(TypedDict):
905
+ r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
906
+
907
+ model: str
908
+ r"""The name of the model for the Agent to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/chat-models)."""
909
+
910
+
911
+ class CreateCompletionAgenticRagConfig(BaseModel):
912
+ r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
913
+
914
+ model: str
915
+ r"""The name of the model for the Agent to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/chat-models)."""
916
+
917
+
918
+ class CreateCompletionKnowledgeBasesTypedDict(TypedDict):
919
+ knowledge_id: str
920
+ r"""Unique identifier of the knowledge base to search"""
921
+ top_k: NotRequired[int]
922
+ r"""The number of results to return. If not provided, will default to the knowledge base configured `top_k`."""
923
+ threshold: NotRequired[float]
924
+ r"""The threshold to apply to the search. If not provided, will default to the knowledge base configured `threshold`"""
925
+ search_type: NotRequired[CreateCompletionSearchType]
926
+ r"""The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`"""
927
+ filter_by: NotRequired[CreateCompletionFilterByTypedDict]
928
+ r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
929
+ search_options: NotRequired[CreateCompletionSearchOptionsTypedDict]
930
+ r"""Additional search options"""
931
+ rerank_config: NotRequired[CreateCompletionRerankConfigTypedDict]
932
+ r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
933
+ agentic_rag_config: NotRequired[CreateCompletionAgenticRagConfigTypedDict]
934
+ r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
935
+ query: NotRequired[str]
936
+ r"""The query to use to search the knowledge base. If not provided we will use the last user message from the messages of the requests"""
937
+
938
+
939
+ class CreateCompletionKnowledgeBases(BaseModel):
940
+ knowledge_id: str
941
+ r"""Unique identifier of the knowledge base to search"""
942
+
943
+ top_k: Optional[int] = None
944
+ r"""The number of results to return. If not provided, will default to the knowledge base configured `top_k`."""
945
+
946
+ threshold: Optional[float] = None
947
+ r"""The threshold to apply to the search. If not provided, will default to the knowledge base configured `threshold`"""
948
+
949
+ search_type: Optional[CreateCompletionSearchType] = "hybrid_search"
950
+ r"""The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`"""
951
+
952
+ filter_by: Optional[CreateCompletionFilterBy] = None
953
+ r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
954
+
955
+ search_options: Optional[CreateCompletionSearchOptions] = None
956
+ r"""Additional search options"""
957
+
958
+ rerank_config: Optional[CreateCompletionRerankConfig] = None
959
+ r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
960
+
961
+ agentic_rag_config: Optional[CreateCompletionAgenticRagConfig] = None
962
+ r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
963
+
964
+ query: Optional[str] = None
965
+ r"""The query to use to search the knowledge base. If not provided we will use the last user message from the messages of the requests"""
966
+
967
+ @model_serializer(mode="wrap")
968
+ def serialize_model(self, handler):
969
+ optional_fields = set(
970
+ [
971
+ "top_k",
972
+ "threshold",
973
+ "search_type",
974
+ "filter_by",
975
+ "search_options",
976
+ "rerank_config",
977
+ "agentic_rag_config",
978
+ "query",
979
+ ]
980
+ )
981
+ serialized = handler(self)
982
+ m = {}
983
+
984
+ for n, f in type(self).model_fields.items():
985
+ k = f.alias or n
986
+ val = serialized.get(k)
987
+
988
+ if val != UNSET_SENTINEL:
989
+ if val is not None or k not in optional_fields:
990
+ m[k] = val
991
+
992
+ return m
993
+
994
+
995
+ CreateCompletionLoadBalancerType = Literal["weight_based",]
996
+
997
+
998
+ class CreateCompletionLoadBalancerModelsTypedDict(TypedDict):
999
+ model: str
1000
+ r"""Model identifier for load balancing"""
1001
+ weight: NotRequired[float]
1002
+ r"""Weight assigned to this model for load balancing"""
1003
+
1004
+
1005
+ class CreateCompletionLoadBalancerModels(BaseModel):
1006
+ model: str
1007
+ r"""Model identifier for load balancing"""
1008
+
1009
+ weight: Optional[float] = 0.5
1010
+ r"""Weight assigned to this model for load balancing"""
1011
+
1012
+ @model_serializer(mode="wrap")
1013
+ def serialize_model(self, handler):
1014
+ optional_fields = set(["weight"])
1015
+ serialized = handler(self)
1016
+ m = {}
1017
+
1018
+ for n, f in type(self).model_fields.items():
1019
+ k = f.alias or n
1020
+ val = serialized.get(k)
1021
+
1022
+ if val != UNSET_SENTINEL:
1023
+ if val is not None or k not in optional_fields:
1024
+ m[k] = val
1025
+
1026
+ return m
1027
+
1028
+
1029
+ class CreateCompletionLoadBalancer1TypedDict(TypedDict):
1030
+ type: CreateCompletionLoadBalancerType
1031
+ models: List[CreateCompletionLoadBalancerModelsTypedDict]
1032
+
1033
+
1034
+ class CreateCompletionLoadBalancer1(BaseModel):
1035
+ type: CreateCompletionLoadBalancerType
1036
+
1037
+ models: List[CreateCompletionLoadBalancerModels]
1038
+
1039
+
1040
+ CreateCompletionLoadBalancerTypedDict = CreateCompletionLoadBalancer1TypedDict
1041
+ r"""Array of models with weights for load balancing requests"""
1042
+
1043
+
1044
+ CreateCompletionLoadBalancer = CreateCompletionLoadBalancer1
1045
+ r"""Array of models with weights for load balancing requests"""
1046
+
1047
+
1048
+ class CreateCompletionTimeoutTypedDict(TypedDict):
1049
+ 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."""
1050
+
1051
+ call_timeout: float
1052
+ r"""Timeout value in milliseconds"""
1053
+
1054
+
1055
+ class CreateCompletionTimeout(BaseModel):
1056
+ 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."""
1057
+
1058
+ call_timeout: float
1059
+ r"""Timeout value in milliseconds"""
1060
+
1061
+
1062
+ @deprecated(
1063
+ "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
1064
+ )
1065
+ class CreateCompletionOrqTypedDict(TypedDict):
1066
+ r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
1067
+
1068
+ name: NotRequired[str]
1069
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
1070
+ retry: NotRequired[CreateCompletionRetryTypedDict]
1071
+ r"""Retry configuration for the request"""
1072
+ fallbacks: NotRequired[List[CreateCompletionFallbacksTypedDict]]
1073
+ r"""Array of fallback models to use if primary model fails"""
1074
+ prompt: NotRequired[CreateCompletionPromptTypedDict]
1075
+ r"""Prompt configuration for the request"""
1076
+ identity: NotRequired[PublicIdentityTypedDict]
1077
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
1078
+ contact: NotRequired[PublicContactTypedDict]
1079
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
1080
+ thread: NotRequired[CreateCompletionThreadTypedDict]
1081
+ r"""Thread information to group related requests"""
1082
+ inputs: NotRequired[CreateCompletionInputsTypedDict]
1083
+ r"""Values to replace in the prompt messages using {{variableName}} syntax"""
1084
+ cache: NotRequired[CreateCompletionCacheTypedDict]
1085
+ r"""Cache configuration for the request."""
1086
+ knowledge_bases: NotRequired[List[CreateCompletionKnowledgeBasesTypedDict]]
1087
+ load_balancer: NotRequired[CreateCompletionLoadBalancerTypedDict]
1088
+ r"""Array of models with weights for load balancing requests"""
1089
+ timeout: NotRequired[CreateCompletionTimeoutTypedDict]
1090
+ 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."""
1091
+
1092
+
1093
+ @deprecated(
1094
+ "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
1095
+ )
1096
+ class CreateCompletionOrq(BaseModel):
1097
+ r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
1098
+
1099
+ name: Optional[str] = None
1100
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
1101
+
1102
+ retry: Optional[CreateCompletionRetry] = None
1103
+ r"""Retry configuration for the request"""
1104
+
1105
+ fallbacks: Optional[List[CreateCompletionFallbacks]] = None
1106
+ r"""Array of fallback models to use if primary model fails"""
1107
+
1108
+ prompt: Optional[CreateCompletionPrompt] = None
1109
+ r"""Prompt configuration for the request"""
1110
+
1111
+ identity: Optional[PublicIdentity] = None
1112
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
1113
+
1114
+ contact: Annotated[
1115
+ Optional[PublicContact],
1116
+ pydantic.Field(
1117
+ deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
1118
+ ),
1119
+ ] = None
1120
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
1121
+
1122
+ thread: Optional[CreateCompletionThread] = None
1123
+ r"""Thread information to group related requests"""
1124
+
1125
+ inputs: Optional[CreateCompletionInputs] = None
1126
+ r"""Values to replace in the prompt messages using {{variableName}} syntax"""
1127
+
1128
+ cache: Optional[CreateCompletionCache] = None
1129
+ r"""Cache configuration for the request."""
1130
+
1131
+ knowledge_bases: Optional[List[CreateCompletionKnowledgeBases]] = None
1132
+
1133
+ load_balancer: Optional[CreateCompletionLoadBalancer] = None
1134
+ r"""Array of models with weights for load balancing requests"""
1135
+
1136
+ timeout: Optional[CreateCompletionTimeout] = None
1137
+ 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."""
1138
+
1139
+ @model_serializer(mode="wrap")
1140
+ def serialize_model(self, handler):
1141
+ optional_fields = set(
1142
+ [
1143
+ "name",
1144
+ "retry",
1145
+ "fallbacks",
1146
+ "prompt",
1147
+ "identity",
1148
+ "contact",
1149
+ "thread",
1150
+ "inputs",
1151
+ "cache",
1152
+ "knowledge_bases",
1153
+ "load_balancer",
1154
+ "timeout",
1155
+ ]
1156
+ )
1157
+ serialized = handler(self)
1158
+ m = {}
1159
+
1160
+ for n, f in type(self).model_fields.items():
1161
+ k = f.alias or n
1162
+ val = serialized.get(k)
1163
+
1164
+ if val != UNSET_SENTINEL:
1165
+ if val is not None or k not in optional_fields:
1166
+ m[k] = val
1167
+
1168
+ return m
1169
+
1170
+
1171
+ class CreateCompletionRequestBodyTypedDict(TypedDict):
1172
+ model: str
1173
+ r"""ID of the model to use"""
1174
+ prompt: str
1175
+ r"""The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays."""
1176
+ echo: NotRequired[Nullable[bool]]
1177
+ r"""Echo back the prompt in addition to the completion"""
1178
+ frequency_penalty: NotRequired[Nullable[float]]
1179
+ 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."""
1180
+ max_tokens: NotRequired[Nullable[float]]
1181
+ r"""The maximum number of tokens that can be generated in the completion."""
1182
+ presence_penalty: NotRequired[Nullable[float]]
1183
+ 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."""
1184
+ seed: NotRequired[Nullable[float]]
1185
+ 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."""
1186
+ stop: NotRequired[Nullable[CreateCompletionStopTypedDict]]
1187
+ r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
1188
+ temperature: NotRequired[Nullable[float]]
1189
+ 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."""
1190
+ top_p: NotRequired[Nullable[float]]
1191
+ r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered."""
1192
+ n: NotRequired[Nullable[float]]
1193
+ r"""How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota."""
1194
+ user: NotRequired[str]
1195
+ r"""A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse."""
1196
+ orq: NotRequired[CreateCompletionOrqTypedDict]
1197
+ r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
1198
+ stream: NotRequired[bool]
1199
+
1200
+
1201
+ class CreateCompletionRequestBody(BaseModel):
1202
+ model: str
1203
+ r"""ID of the model to use"""
1204
+
1205
+ prompt: str
1206
+ r"""The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays."""
1207
+
1208
+ echo: OptionalNullable[bool] = False
1209
+ r"""Echo back the prompt in addition to the completion"""
1210
+
1211
+ frequency_penalty: OptionalNullable[float] = 0
1212
+ 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."""
1213
+
1214
+ max_tokens: OptionalNullable[float] = 16
1215
+ r"""The maximum number of tokens that can be generated in the completion."""
1216
+
1217
+ presence_penalty: OptionalNullable[float] = 0
1218
+ 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."""
1219
+
1220
+ seed: OptionalNullable[float] = UNSET
1221
+ 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."""
1222
+
1223
+ stop: OptionalNullable[CreateCompletionStop] = UNSET
1224
+ r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
1225
+
1226
+ temperature: OptionalNullable[float] = 1
1227
+ 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."""
1228
+
1229
+ top_p: OptionalNullable[float] = 1
1230
+ r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered."""
1231
+
1232
+ n: OptionalNullable[float] = 1
1233
+ r"""How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota."""
1234
+
1235
+ user: Optional[str] = None
1236
+ r"""A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse."""
1237
+
1238
+ orq: Annotated[
1239
+ Optional[CreateCompletionOrq],
1240
+ pydantic.Field(
1241
+ deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
1242
+ ),
1243
+ ] = None
1244
+ r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
1245
+
1246
+ stream: Optional[bool] = False
1247
+
1248
+ @model_serializer(mode="wrap")
1249
+ def serialize_model(self, handler):
1250
+ optional_fields = set(
1251
+ [
1252
+ "echo",
1253
+ "frequency_penalty",
1254
+ "max_tokens",
1255
+ "presence_penalty",
1256
+ "seed",
1257
+ "stop",
1258
+ "temperature",
1259
+ "top_p",
1260
+ "n",
1261
+ "user",
1262
+ "orq",
1263
+ "stream",
1264
+ ]
1265
+ )
1266
+ nullable_fields = set(
1267
+ [
1268
+ "echo",
1269
+ "frequency_penalty",
1270
+ "max_tokens",
1271
+ "presence_penalty",
1272
+ "seed",
1273
+ "stop",
1274
+ "temperature",
1275
+ "top_p",
1276
+ "n",
1277
+ ]
1278
+ )
1279
+ serialized = handler(self)
1280
+ m = {}
1281
+
1282
+ for n, f in type(self).model_fields.items():
1283
+ k = f.alias or n
1284
+ val = serialized.get(k)
1285
+ is_nullable_and_explicitly_set = (
1286
+ k in nullable_fields
1287
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1288
+ )
1289
+
1290
+ if val != UNSET_SENTINEL:
1291
+ if (
1292
+ val is not None
1293
+ or k not in optional_fields
1294
+ or is_nullable_and_explicitly_set
1295
+ ):
1296
+ m[k] = val
1297
+
1298
+ return m
1299
+
1300
+
1301
+ CreateCompletionRouterCompletionsFinishReason = Literal[
1302
+ "stop",
1303
+ "length",
1304
+ "content_filter",
1305
+ "tool_calls",
1306
+ ]
1307
+ r"""The reason the model stopped generating tokens."""
1308
+
1309
+
1310
+ class CreateCompletionRouterCompletionsChoicesTypedDict(TypedDict):
1311
+ finish_reason: CreateCompletionRouterCompletionsFinishReason
1312
+ r"""The reason the model stopped generating tokens."""
1313
+ index: float
1314
+ r"""The index of the choice in the list of choices."""
1315
+ text: str
1316
+
1317
+
1318
+ class CreateCompletionRouterCompletionsChoices(BaseModel):
1319
+ finish_reason: CreateCompletionRouterCompletionsFinishReason
1320
+ r"""The reason the model stopped generating tokens."""
1321
+
1322
+ index: float
1323
+ r"""The index of the choice in the list of choices."""
1324
+
1325
+ text: str
1326
+
1327
+
1328
+ CreateCompletionCreatedTypedDict = TypeAliasType(
1329
+ "CreateCompletionCreatedTypedDict", Union[str, float]
1330
+ )
1331
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1332
+
1333
+
1334
+ CreateCompletionCreated = TypeAliasType("CreateCompletionCreated", Union[str, float])
1335
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1336
+
1337
+
1338
+ class CreateCompletionRouterCompletionsPromptTokensDetailsTypedDict(TypedDict):
1339
+ cached_tokens: NotRequired[Nullable[int]]
1340
+ cache_creation_tokens: NotRequired[Nullable[int]]
1341
+ audio_tokens: NotRequired[Nullable[int]]
1342
+ r"""The number of audio input tokens consumed by the request."""
1343
+
1344
+
1345
+ class CreateCompletionRouterCompletionsPromptTokensDetails(BaseModel):
1346
+ cached_tokens: OptionalNullable[int] = UNSET
1347
+
1348
+ cache_creation_tokens: OptionalNullable[int] = UNSET
1349
+
1350
+ audio_tokens: OptionalNullable[int] = UNSET
1351
+ r"""The number of audio input tokens consumed by the request."""
1352
+
1353
+ @model_serializer(mode="wrap")
1354
+ def serialize_model(self, handler):
1355
+ optional_fields = set(
1356
+ ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
1357
+ )
1358
+ nullable_fields = set(
1359
+ ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
1360
+ )
1361
+ serialized = handler(self)
1362
+ m = {}
1363
+
1364
+ for n, f in type(self).model_fields.items():
1365
+ k = f.alias or n
1366
+ val = serialized.get(k)
1367
+ is_nullable_and_explicitly_set = (
1368
+ k in nullable_fields
1369
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1370
+ )
1371
+
1372
+ if val != UNSET_SENTINEL:
1373
+ if (
1374
+ val is not None
1375
+ or k not in optional_fields
1376
+ or is_nullable_and_explicitly_set
1377
+ ):
1378
+ m[k] = val
1379
+
1380
+ return m
1381
+
1382
+
1383
+ class CreateCompletionRouterCompletionsCompletionTokensDetailsTypedDict(TypedDict):
1384
+ reasoning_tokens: NotRequired[Nullable[float]]
1385
+ accepted_prediction_tokens: NotRequired[Nullable[float]]
1386
+ rejected_prediction_tokens: NotRequired[Nullable[float]]
1387
+ audio_tokens: NotRequired[Nullable[int]]
1388
+ r"""The number of audio output tokens produced by the response."""
1389
+
1390
+
1391
+ class CreateCompletionRouterCompletionsCompletionTokensDetails(BaseModel):
1392
+ reasoning_tokens: OptionalNullable[float] = UNSET
1393
+
1394
+ accepted_prediction_tokens: OptionalNullable[float] = UNSET
1395
+
1396
+ rejected_prediction_tokens: OptionalNullable[float] = UNSET
1397
+
1398
+ audio_tokens: OptionalNullable[int] = UNSET
1399
+ r"""The number of audio output tokens produced by the response."""
1400
+
1401
+ @model_serializer(mode="wrap")
1402
+ def serialize_model(self, handler):
1403
+ optional_fields = set(
1404
+ [
1405
+ "reasoning_tokens",
1406
+ "accepted_prediction_tokens",
1407
+ "rejected_prediction_tokens",
1408
+ "audio_tokens",
1409
+ ]
1410
+ )
1411
+ nullable_fields = set(
1412
+ [
1413
+ "reasoning_tokens",
1414
+ "accepted_prediction_tokens",
1415
+ "rejected_prediction_tokens",
1416
+ "audio_tokens",
1417
+ ]
1418
+ )
1419
+ serialized = handler(self)
1420
+ m = {}
1421
+
1422
+ for n, f in type(self).model_fields.items():
1423
+ k = f.alias or n
1424
+ val = serialized.get(k)
1425
+ is_nullable_and_explicitly_set = (
1426
+ k in nullable_fields
1427
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1428
+ )
1429
+
1430
+ if val != UNSET_SENTINEL:
1431
+ if (
1432
+ val is not None
1433
+ or k not in optional_fields
1434
+ or is_nullable_and_explicitly_set
1435
+ ):
1436
+ m[k] = val
1437
+
1438
+ return m
1439
+
1440
+
1441
+ class CreateCompletionRouterCompletionsUsageTypedDict(TypedDict):
1442
+ r"""Usage statistics for the completion request."""
1443
+
1444
+ completion_tokens: NotRequired[float]
1445
+ r"""Number of tokens in the generated completion."""
1446
+ prompt_tokens: NotRequired[float]
1447
+ r"""Number of tokens in the prompt."""
1448
+ total_tokens: NotRequired[float]
1449
+ r"""Total number of tokens used in the request (prompt + completion)."""
1450
+ prompt_tokens_details: NotRequired[
1451
+ Nullable[CreateCompletionRouterCompletionsPromptTokensDetailsTypedDict]
1452
+ ]
1453
+ completion_tokens_details: NotRequired[
1454
+ Nullable[CreateCompletionRouterCompletionsCompletionTokensDetailsTypedDict]
1455
+ ]
1456
+
1457
+
1458
+ class CreateCompletionRouterCompletionsUsage(BaseModel):
1459
+ r"""Usage statistics for the completion request."""
1460
+
1461
+ completion_tokens: Optional[float] = None
1462
+ r"""Number of tokens in the generated completion."""
1463
+
1464
+ prompt_tokens: Optional[float] = None
1465
+ r"""Number of tokens in the prompt."""
1466
+
1467
+ total_tokens: Optional[float] = None
1468
+ r"""Total number of tokens used in the request (prompt + completion)."""
1469
+
1470
+ prompt_tokens_details: OptionalNullable[
1471
+ CreateCompletionRouterCompletionsPromptTokensDetails
1472
+ ] = UNSET
1473
+
1474
+ completion_tokens_details: OptionalNullable[
1475
+ CreateCompletionRouterCompletionsCompletionTokensDetails
1476
+ ] = UNSET
1477
+
1478
+ @model_serializer(mode="wrap")
1479
+ def serialize_model(self, handler):
1480
+ optional_fields = set(
1481
+ [
1482
+ "completion_tokens",
1483
+ "prompt_tokens",
1484
+ "total_tokens",
1485
+ "prompt_tokens_details",
1486
+ "completion_tokens_details",
1487
+ ]
1488
+ )
1489
+ nullable_fields = set(["prompt_tokens_details", "completion_tokens_details"])
1490
+ serialized = handler(self)
1491
+ m = {}
1492
+
1493
+ for n, f in type(self).model_fields.items():
1494
+ k = f.alias or n
1495
+ val = serialized.get(k)
1496
+ is_nullable_and_explicitly_set = (
1497
+ k in nullable_fields
1498
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1499
+ )
1500
+
1501
+ if val != UNSET_SENTINEL:
1502
+ if (
1503
+ val is not None
1504
+ or k not in optional_fields
1505
+ or is_nullable_and_explicitly_set
1506
+ ):
1507
+ m[k] = val
1508
+
1509
+ return m
1510
+
1511
+
1512
+ class CreateCompletionDataTypedDict(TypedDict):
1513
+ id: str
1514
+ r"""A unique identifier for the completion."""
1515
+ choices: List[CreateCompletionRouterCompletionsChoicesTypedDict]
1516
+ r"""The list of completion choices the model generated for the input prompt."""
1517
+ model: str
1518
+ r"""The model used for the chat completion."""
1519
+ object: str
1520
+ r"""The object type"""
1521
+ created: NotRequired[CreateCompletionCreatedTypedDict]
1522
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1523
+ system_fingerprint: NotRequired[str]
1524
+ r"""This fingerprint represents the backend configuration that the model runs with."""
1525
+ usage: NotRequired[CreateCompletionRouterCompletionsUsageTypedDict]
1526
+ r"""Usage statistics for the completion request."""
1527
+
1528
+
1529
+ class CreateCompletionData(BaseModel):
1530
+ id: str
1531
+ r"""A unique identifier for the completion."""
1532
+
1533
+ choices: List[CreateCompletionRouterCompletionsChoices]
1534
+ r"""The list of completion choices the model generated for the input prompt."""
1535
+
1536
+ model: str
1537
+ r"""The model used for the chat completion."""
1538
+
1539
+ object: str
1540
+ r"""The object type"""
1541
+
1542
+ created: Optional[CreateCompletionCreated] = None
1543
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1544
+
1545
+ system_fingerprint: Optional[str] = None
1546
+ r"""This fingerprint represents the backend configuration that the model runs with."""
1547
+
1548
+ usage: Optional[CreateCompletionRouterCompletionsUsage] = None
1549
+ r"""Usage statistics for the completion request."""
1550
+
1551
+ @model_serializer(mode="wrap")
1552
+ def serialize_model(self, handler):
1553
+ optional_fields = set(["created", "system_fingerprint", "usage"])
1554
+ serialized = handler(self)
1555
+ m = {}
1556
+
1557
+ for n, f in type(self).model_fields.items():
1558
+ k = f.alias or n
1559
+ val = serialized.get(k)
1560
+
1561
+ if val != UNSET_SENTINEL:
1562
+ if val is not None or k not in optional_fields:
1563
+ m[k] = val
1564
+
1565
+ return m
1566
+
1567
+
1568
+ class CreateCompletionRouterCompletionsResponseBodyTypedDict(TypedDict):
1569
+ r"""Represents a completion response from the API."""
1570
+
1571
+ data: NotRequired[CreateCompletionDataTypedDict]
1572
+
1573
+
1574
+ class CreateCompletionRouterCompletionsResponseBody(BaseModel):
1575
+ r"""Represents a completion response from the API."""
1576
+
1577
+ data: Optional[CreateCompletionData] = None
1578
+
1579
+ @model_serializer(mode="wrap")
1580
+ def serialize_model(self, handler):
1581
+ optional_fields = set(["data"])
1582
+ serialized = handler(self)
1583
+ m = {}
1584
+
1585
+ for n, f in type(self).model_fields.items():
1586
+ k = f.alias or n
1587
+ val = serialized.get(k)
1588
+
1589
+ if val != UNSET_SENTINEL:
1590
+ if val is not None or k not in optional_fields:
1591
+ m[k] = val
1592
+
1593
+ return m
1594
+
1595
+
1596
+ CreateCompletionFinishReason = Literal[
1597
+ "stop",
1598
+ "length",
1599
+ "content_filter",
1600
+ "tool_calls",
1601
+ ]
1602
+ r"""The reason the model stopped generating tokens."""
1603
+
1604
+
1605
+ class CreateCompletionChoicesTypedDict(TypedDict):
1606
+ finish_reason: CreateCompletionFinishReason
1607
+ r"""The reason the model stopped generating tokens."""
1608
+ index: float
1609
+ r"""The index of the choice in the list of choices."""
1610
+ text: str
1611
+
1612
+
1613
+ class CreateCompletionChoices(BaseModel):
1614
+ finish_reason: CreateCompletionFinishReason
1615
+ r"""The reason the model stopped generating tokens."""
1616
+
1617
+ index: float
1618
+ r"""The index of the choice in the list of choices."""
1619
+
1620
+ text: str
1621
+
1622
+
1623
+ CreatedTypedDict = TypeAliasType("CreatedTypedDict", Union[str, float])
1624
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1625
+
1626
+
1627
+ Created = TypeAliasType("Created", Union[str, float])
1628
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1629
+
1630
+
1631
+ class CreateCompletionPromptTokensDetailsTypedDict(TypedDict):
1632
+ cached_tokens: NotRequired[Nullable[int]]
1633
+ cache_creation_tokens: NotRequired[Nullable[int]]
1634
+ audio_tokens: NotRequired[Nullable[int]]
1635
+ r"""The number of audio input tokens consumed by the request."""
1636
+
1637
+
1638
+ class CreateCompletionPromptTokensDetails(BaseModel):
1639
+ cached_tokens: OptionalNullable[int] = UNSET
1640
+
1641
+ cache_creation_tokens: OptionalNullable[int] = UNSET
1642
+
1643
+ audio_tokens: OptionalNullable[int] = UNSET
1644
+ r"""The number of audio input tokens consumed by the request."""
1645
+
1646
+ @model_serializer(mode="wrap")
1647
+ def serialize_model(self, handler):
1648
+ optional_fields = set(
1649
+ ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
1650
+ )
1651
+ nullable_fields = set(
1652
+ ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
1653
+ )
1654
+ serialized = handler(self)
1655
+ m = {}
1656
+
1657
+ for n, f in type(self).model_fields.items():
1658
+ k = f.alias or n
1659
+ val = serialized.get(k)
1660
+ is_nullable_and_explicitly_set = (
1661
+ k in nullable_fields
1662
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1663
+ )
1664
+
1665
+ if val != UNSET_SENTINEL:
1666
+ if (
1667
+ val is not None
1668
+ or k not in optional_fields
1669
+ or is_nullable_and_explicitly_set
1670
+ ):
1671
+ m[k] = val
1672
+
1673
+ return m
1674
+
1675
+
1676
+ class CreateCompletionCompletionTokensDetailsTypedDict(TypedDict):
1677
+ reasoning_tokens: NotRequired[Nullable[float]]
1678
+ accepted_prediction_tokens: NotRequired[Nullable[float]]
1679
+ rejected_prediction_tokens: NotRequired[Nullable[float]]
1680
+ audio_tokens: NotRequired[Nullable[int]]
1681
+ r"""The number of audio output tokens produced by the response."""
1682
+
1683
+
1684
+ class CreateCompletionCompletionTokensDetails(BaseModel):
1685
+ reasoning_tokens: OptionalNullable[float] = UNSET
1686
+
1687
+ accepted_prediction_tokens: OptionalNullable[float] = UNSET
1688
+
1689
+ rejected_prediction_tokens: OptionalNullable[float] = UNSET
1690
+
1691
+ audio_tokens: OptionalNullable[int] = UNSET
1692
+ r"""The number of audio output tokens produced by the response."""
1693
+
1694
+ @model_serializer(mode="wrap")
1695
+ def serialize_model(self, handler):
1696
+ optional_fields = set(
1697
+ [
1698
+ "reasoning_tokens",
1699
+ "accepted_prediction_tokens",
1700
+ "rejected_prediction_tokens",
1701
+ "audio_tokens",
1702
+ ]
1703
+ )
1704
+ nullable_fields = set(
1705
+ [
1706
+ "reasoning_tokens",
1707
+ "accepted_prediction_tokens",
1708
+ "rejected_prediction_tokens",
1709
+ "audio_tokens",
1710
+ ]
1711
+ )
1712
+ serialized = handler(self)
1713
+ m = {}
1714
+
1715
+ for n, f in type(self).model_fields.items():
1716
+ k = f.alias or n
1717
+ val = serialized.get(k)
1718
+ is_nullable_and_explicitly_set = (
1719
+ k in nullable_fields
1720
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1721
+ )
1722
+
1723
+ if val != UNSET_SENTINEL:
1724
+ if (
1725
+ val is not None
1726
+ or k not in optional_fields
1727
+ or is_nullable_and_explicitly_set
1728
+ ):
1729
+ m[k] = val
1730
+
1731
+ return m
1732
+
1733
+
1734
+ class CreateCompletionUsageTypedDict(TypedDict):
1735
+ r"""Usage statistics for the completion request."""
1736
+
1737
+ completion_tokens: NotRequired[float]
1738
+ r"""Number of tokens in the generated completion."""
1739
+ prompt_tokens: NotRequired[float]
1740
+ r"""Number of tokens in the prompt."""
1741
+ total_tokens: NotRequired[float]
1742
+ r"""Total number of tokens used in the request (prompt + completion)."""
1743
+ prompt_tokens_details: NotRequired[
1744
+ Nullable[CreateCompletionPromptTokensDetailsTypedDict]
1745
+ ]
1746
+ completion_tokens_details: NotRequired[
1747
+ Nullable[CreateCompletionCompletionTokensDetailsTypedDict]
1748
+ ]
1749
+
1750
+
1751
+ class CreateCompletionUsage(BaseModel):
1752
+ r"""Usage statistics for the completion request."""
1753
+
1754
+ completion_tokens: Optional[float] = None
1755
+ r"""Number of tokens in the generated completion."""
1756
+
1757
+ prompt_tokens: Optional[float] = None
1758
+ r"""Number of tokens in the prompt."""
1759
+
1760
+ total_tokens: Optional[float] = None
1761
+ r"""Total number of tokens used in the request (prompt + completion)."""
1762
+
1763
+ prompt_tokens_details: OptionalNullable[CreateCompletionPromptTokensDetails] = UNSET
1764
+
1765
+ completion_tokens_details: OptionalNullable[
1766
+ CreateCompletionCompletionTokensDetails
1767
+ ] = UNSET
1768
+
1769
+ @model_serializer(mode="wrap")
1770
+ def serialize_model(self, handler):
1771
+ optional_fields = set(
1772
+ [
1773
+ "completion_tokens",
1774
+ "prompt_tokens",
1775
+ "total_tokens",
1776
+ "prompt_tokens_details",
1777
+ "completion_tokens_details",
1778
+ ]
1779
+ )
1780
+ nullable_fields = set(["prompt_tokens_details", "completion_tokens_details"])
1781
+ serialized = handler(self)
1782
+ m = {}
1783
+
1784
+ for n, f in type(self).model_fields.items():
1785
+ k = f.alias or n
1786
+ val = serialized.get(k)
1787
+ is_nullable_and_explicitly_set = (
1788
+ k in nullable_fields
1789
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1790
+ )
1791
+
1792
+ if val != UNSET_SENTINEL:
1793
+ if (
1794
+ val is not None
1795
+ or k not in optional_fields
1796
+ or is_nullable_and_explicitly_set
1797
+ ):
1798
+ m[k] = val
1799
+
1800
+ return m
1801
+
1802
+
1803
+ class CreateCompletionResponseBodyTypedDict(TypedDict):
1804
+ r"""Represents a completion response from the API."""
1805
+
1806
+ id: str
1807
+ r"""A unique identifier for the completion."""
1808
+ choices: List[CreateCompletionChoicesTypedDict]
1809
+ r"""The list of completion choices the model generated for the input prompt."""
1810
+ model: str
1811
+ r"""The model used for the chat completion."""
1812
+ object: str
1813
+ r"""The object type"""
1814
+ created: NotRequired[CreatedTypedDict]
1815
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1816
+ system_fingerprint: NotRequired[str]
1817
+ r"""This fingerprint represents the backend configuration that the model runs with."""
1818
+ usage: NotRequired[CreateCompletionUsageTypedDict]
1819
+ r"""Usage statistics for the completion request."""
1820
+
1821
+
1822
+ class CreateCompletionResponseBody(BaseModel):
1823
+ r"""Represents a completion response from the API."""
1824
+
1825
+ id: str
1826
+ r"""A unique identifier for the completion."""
1827
+
1828
+ choices: List[CreateCompletionChoices]
1829
+ r"""The list of completion choices the model generated for the input prompt."""
1830
+
1831
+ model: str
1832
+ r"""The model used for the chat completion."""
1833
+
1834
+ object: str
1835
+ r"""The object type"""
1836
+
1837
+ created: Optional[Created] = None
1838
+ r"""The Unix timestamp (in seconds) of when the chat completion was created."""
1839
+
1840
+ system_fingerprint: Optional[str] = None
1841
+ r"""This fingerprint represents the backend configuration that the model runs with."""
1842
+
1843
+ usage: Optional[CreateCompletionUsage] = None
1844
+ r"""Usage statistics for the completion request."""
1845
+
1846
+ @model_serializer(mode="wrap")
1847
+ def serialize_model(self, handler):
1848
+ optional_fields = set(["created", "system_fingerprint", "usage"])
1849
+ serialized = handler(self)
1850
+ m = {}
1851
+
1852
+ for n, f in type(self).model_fields.items():
1853
+ k = f.alias or n
1854
+ val = serialized.get(k)
1855
+
1856
+ if val != UNSET_SENTINEL:
1857
+ if val is not None or k not in optional_fields:
1858
+ m[k] = val
1859
+
1860
+ return m
1861
+
1862
+
1863
+ CreateCompletionResponseTypedDict = TypeAliasType(
1864
+ "CreateCompletionResponseTypedDict",
1865
+ Union[
1866
+ CreateCompletionResponseBodyTypedDict,
1867
+ Union[
1868
+ eventstreaming.EventStream[
1869
+ CreateCompletionRouterCompletionsResponseBodyTypedDict
1870
+ ],
1871
+ eventstreaming.EventStreamAsync[
1872
+ CreateCompletionRouterCompletionsResponseBodyTypedDict
1873
+ ],
1874
+ ],
1875
+ ],
1876
+ )
1877
+
1878
+
1879
+ CreateCompletionResponse = TypeAliasType(
1880
+ "CreateCompletionResponse",
1881
+ Union[
1882
+ CreateCompletionResponseBody,
1883
+ Union[
1884
+ eventstreaming.EventStream[CreateCompletionRouterCompletionsResponseBody],
1885
+ eventstreaming.EventStreamAsync[
1886
+ CreateCompletionRouterCompletionsResponseBody
1887
+ ],
1888
+ ],
1889
+ ],
1890
+ )