orq-ai-sdk 4.2.0rc49__py3-none-any.whl → 4.2.12__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 (103) 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/chat.py +22 -0
  5. orq_ai_sdk/completions.py +438 -0
  6. orq_ai_sdk/contacts.py +43 -886
  7. orq_ai_sdk/deployments.py +61 -0
  8. orq_ai_sdk/edits.py +364 -0
  9. orq_ai_sdk/embeddings.py +344 -0
  10. orq_ai_sdk/generations.py +370 -0
  11. orq_ai_sdk/images.py +28 -0
  12. orq_ai_sdk/models/__init__.py +3839 -424
  13. orq_ai_sdk/models/conversationresponse.py +1 -1
  14. orq_ai_sdk/models/conversationwithmessagesresponse.py +1 -1
  15. orq_ai_sdk/models/createagentrequestop.py +768 -12
  16. orq_ai_sdk/models/createagentresponse.py +68 -2
  17. orq_ai_sdk/models/createchatcompletionop.py +538 -313
  18. orq_ai_sdk/models/createcompletionop.py +2078 -0
  19. orq_ai_sdk/models/createcontactop.py +5 -10
  20. orq_ai_sdk/models/createconversationop.py +1 -1
  21. orq_ai_sdk/models/createconversationresponseop.py +2 -2
  22. orq_ai_sdk/models/createdatasetitemop.py +4 -4
  23. orq_ai_sdk/models/createdatasetop.py +1 -1
  24. orq_ai_sdk/models/createdatasourceop.py +1 -1
  25. orq_ai_sdk/models/createembeddingop.py +579 -0
  26. orq_ai_sdk/models/createevalop.py +14 -14
  27. orq_ai_sdk/models/createidentityop.py +1 -1
  28. orq_ai_sdk/models/createimageeditop.py +715 -0
  29. orq_ai_sdk/models/createimageop.py +228 -82
  30. orq_ai_sdk/models/createimagevariationop.py +706 -0
  31. orq_ai_sdk/models/creatememoryop.py +4 -2
  32. orq_ai_sdk/models/createmoderationop.py +521 -0
  33. orq_ai_sdk/models/createpromptop.py +375 -6
  34. orq_ai_sdk/models/creatererankop.py +608 -0
  35. orq_ai_sdk/models/createresponseop.py +2567 -0
  36. orq_ai_sdk/models/createspeechop.py +466 -0
  37. orq_ai_sdk/models/createtoolop.py +6 -6
  38. orq_ai_sdk/models/createtranscriptionop.py +732 -0
  39. orq_ai_sdk/models/createtranslationop.py +702 -0
  40. orq_ai_sdk/models/deploymentgetconfigop.py +17 -7
  41. orq_ai_sdk/models/deploymentsop.py +1 -0
  42. orq_ai_sdk/models/deploymentstreamop.py +7 -0
  43. orq_ai_sdk/models/filegetop.py +1 -1
  44. orq_ai_sdk/models/filelistop.py +1 -1
  45. orq_ai_sdk/models/fileuploadop.py +1 -1
  46. orq_ai_sdk/models/generateconversationnameop.py +1 -1
  47. orq_ai_sdk/models/getallmemoriesop.py +4 -2
  48. orq_ai_sdk/models/getallpromptsop.py +188 -3
  49. orq_ai_sdk/models/getalltoolsop.py +6 -6
  50. orq_ai_sdk/models/getevalsop.py +17 -17
  51. orq_ai_sdk/models/getonepromptop.py +188 -3
  52. orq_ai_sdk/models/getpromptversionop.py +188 -3
  53. orq_ai_sdk/models/invokedeploymentrequest.py +11 -4
  54. orq_ai_sdk/models/listagentsop.py +372 -0
  55. orq_ai_sdk/models/listdatasetdatapointsop.py +4 -4
  56. orq_ai_sdk/models/listdatasetsop.py +1 -1
  57. orq_ai_sdk/models/listdatasourcesop.py +1 -1
  58. orq_ai_sdk/models/listidentitiesop.py +1 -1
  59. orq_ai_sdk/models/listmodelsop.py +1 -0
  60. orq_ai_sdk/models/listpromptversionsop.py +188 -3
  61. orq_ai_sdk/models/partdoneevent.py +1 -1
  62. orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
  63. orq_ai_sdk/models/publiccontact.py +9 -3
  64. orq_ai_sdk/models/publicidentity.py +62 -0
  65. orq_ai_sdk/models/reasoningpart.py +1 -1
  66. orq_ai_sdk/models/responsedoneevent.py +14 -11
  67. orq_ai_sdk/models/retrieveagentrequestop.py +382 -0
  68. orq_ai_sdk/models/retrievedatapointop.py +4 -4
  69. orq_ai_sdk/models/retrievedatasetop.py +1 -1
  70. orq_ai_sdk/models/retrievedatasourceop.py +1 -1
  71. orq_ai_sdk/models/retrieveidentityop.py +1 -1
  72. orq_ai_sdk/models/retrievememoryop.py +4 -2
  73. orq_ai_sdk/models/retrievetoolop.py +6 -6
  74. orq_ai_sdk/models/runagentop.py +379 -9
  75. orq_ai_sdk/models/streamrunagentop.py +385 -9
  76. orq_ai_sdk/models/updateagentop.py +770 -12
  77. orq_ai_sdk/models/updateconversationop.py +1 -1
  78. orq_ai_sdk/models/updatedatapointop.py +4 -4
  79. orq_ai_sdk/models/updatedatasetop.py +1 -1
  80. orq_ai_sdk/models/updatedatasourceop.py +1 -1
  81. orq_ai_sdk/models/updateevalop.py +14 -14
  82. orq_ai_sdk/models/updateidentityop.py +1 -1
  83. orq_ai_sdk/models/updatememoryop.py +4 -2
  84. orq_ai_sdk/models/updatepromptop.py +375 -6
  85. orq_ai_sdk/models/updatetoolop.py +7 -7
  86. orq_ai_sdk/moderations.py +218 -0
  87. orq_ai_sdk/orq_completions.py +666 -0
  88. orq_ai_sdk/orq_responses.py +398 -0
  89. orq_ai_sdk/rerank.py +330 -0
  90. orq_ai_sdk/router.py +89 -641
  91. orq_ai_sdk/speech.py +333 -0
  92. orq_ai_sdk/transcriptions.py +416 -0
  93. orq_ai_sdk/translations.py +384 -0
  94. orq_ai_sdk/variations.py +364 -0
  95. orq_ai_sdk-4.2.12.dist-info/METADATA +888 -0
  96. {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.12.dist-info}/RECORD +98 -75
  97. {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.12.dist-info}/WHEEL +1 -1
  98. orq_ai_sdk/models/deletecontactop.py +0 -44
  99. orq_ai_sdk/models/listcontactsop.py +0 -265
  100. orq_ai_sdk/models/retrievecontactop.py +0 -142
  101. orq_ai_sdk/models/updatecontactop.py +0 -233
  102. orq_ai_sdk-4.2.0rc49.dist-info/METADATA +0 -788
  103. {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,702 @@
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 dataclasses import dataclass, field
7
+ import httpx
8
+ import io
9
+ from orq_ai_sdk.models import OrqError
10
+ from orq_ai_sdk.types import BaseModel, Nullable, UNSET_SENTINEL
11
+ from orq_ai_sdk.utils import FieldMetadata, MultipartFormMetadata
12
+ import pydantic
13
+ from pydantic import model_serializer
14
+ from typing import IO, List, Literal, Optional, Union
15
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
16
+
17
+
18
+ CreateTranslationResponseFormat = Literal[
19
+ "json",
20
+ "text",
21
+ "srt",
22
+ "verbose_json",
23
+ "vtt",
24
+ ]
25
+ r"""The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt."""
26
+
27
+
28
+ CreateTranslationTimestampsGranularity = Literal[
29
+ "none",
30
+ "word",
31
+ "character",
32
+ ]
33
+ r"""The granularity of the timestamps in the transcription. Word provides word-level timestamps and character provides character-level timestamps per word."""
34
+
35
+
36
+ class CreateTranslationFallbacksTypedDict(TypedDict):
37
+ model: str
38
+ r"""Fallback model identifier"""
39
+
40
+
41
+ class CreateTranslationFallbacks(BaseModel):
42
+ model: str
43
+ r"""Fallback model identifier"""
44
+
45
+
46
+ class CreateTranslationRetryTypedDict(TypedDict):
47
+ r"""Retry configuration for the request"""
48
+
49
+ count: NotRequired[float]
50
+ r"""Number of retry attempts (1-5)"""
51
+ on_codes: NotRequired[List[float]]
52
+ r"""HTTP status codes that trigger retry logic"""
53
+
54
+
55
+ class CreateTranslationRetry(BaseModel):
56
+ r"""Retry configuration for the request"""
57
+
58
+ count: Optional[float] = 3
59
+ r"""Number of retry attempts (1-5)"""
60
+
61
+ on_codes: Optional[List[float]] = None
62
+ r"""HTTP status codes that trigger retry logic"""
63
+
64
+ @model_serializer(mode="wrap")
65
+ def serialize_model(self, handler):
66
+ optional_fields = set(["count", "on_codes"])
67
+ serialized = handler(self)
68
+ m = {}
69
+
70
+ for n, f in type(self).model_fields.items():
71
+ k = f.alias or n
72
+ val = serialized.get(k)
73
+
74
+ if val != UNSET_SENTINEL:
75
+ if val is not None or k not in optional_fields:
76
+ m[k] = val
77
+
78
+ return m
79
+
80
+
81
+ CreateTranslationLoadBalancerType = Literal["weight_based",]
82
+
83
+
84
+ class CreateTranslationLoadBalancerModelsTypedDict(TypedDict):
85
+ model: str
86
+ r"""Model identifier for load balancing"""
87
+ weight: NotRequired[float]
88
+ r"""Weight assigned to this model for load balancing"""
89
+
90
+
91
+ class CreateTranslationLoadBalancerModels(BaseModel):
92
+ model: str
93
+ r"""Model identifier for load balancing"""
94
+
95
+ weight: Optional[float] = 0.5
96
+ r"""Weight assigned to this model for load balancing"""
97
+
98
+ @model_serializer(mode="wrap")
99
+ def serialize_model(self, handler):
100
+ optional_fields = set(["weight"])
101
+ serialized = handler(self)
102
+ m = {}
103
+
104
+ for n, f in type(self).model_fields.items():
105
+ k = f.alias or n
106
+ val = serialized.get(k)
107
+
108
+ if val != UNSET_SENTINEL:
109
+ if val is not None or k not in optional_fields:
110
+ m[k] = val
111
+
112
+ return m
113
+
114
+
115
+ class CreateTranslationLoadBalancer1TypedDict(TypedDict):
116
+ type: CreateTranslationLoadBalancerType
117
+ models: List[CreateTranslationLoadBalancerModelsTypedDict]
118
+
119
+
120
+ class CreateTranslationLoadBalancer1(BaseModel):
121
+ type: CreateTranslationLoadBalancerType
122
+
123
+ models: List[CreateTranslationLoadBalancerModels]
124
+
125
+
126
+ CreateTranslationLoadBalancerTypedDict = CreateTranslationLoadBalancer1TypedDict
127
+ r"""Load balancer configuration for the request."""
128
+
129
+
130
+ CreateTranslationLoadBalancer = CreateTranslationLoadBalancer1
131
+ r"""Load balancer configuration for the request."""
132
+
133
+
134
+ class CreateTranslationTimeoutTypedDict(TypedDict):
135
+ 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."""
136
+
137
+ call_timeout: float
138
+ r"""Timeout value in milliseconds"""
139
+
140
+
141
+ class CreateTranslationTimeout(BaseModel):
142
+ 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."""
143
+
144
+ call_timeout: float
145
+ r"""Timeout value in milliseconds"""
146
+
147
+
148
+ class CreateTranslationRouterAudioTranslationsFallbacksTypedDict(TypedDict):
149
+ model: str
150
+ r"""Fallback model identifier"""
151
+
152
+
153
+ class CreateTranslationRouterAudioTranslationsFallbacks(BaseModel):
154
+ model: str
155
+ r"""Fallback model identifier"""
156
+
157
+
158
+ class CreateTranslationRouterAudioTranslationsRetryTypedDict(TypedDict):
159
+ r"""Retry configuration for the request"""
160
+
161
+ count: NotRequired[float]
162
+ r"""Number of retry attempts (1-5)"""
163
+ on_codes: NotRequired[List[float]]
164
+ r"""HTTP status codes that trigger retry logic"""
165
+
166
+
167
+ class CreateTranslationRouterAudioTranslationsRetry(BaseModel):
168
+ r"""Retry configuration for the request"""
169
+
170
+ count: Optional[float] = 3
171
+ r"""Number of retry attempts (1-5)"""
172
+
173
+ on_codes: Optional[List[float]] = None
174
+ r"""HTTP status codes that trigger retry logic"""
175
+
176
+ @model_serializer(mode="wrap")
177
+ def serialize_model(self, handler):
178
+ optional_fields = set(["count", "on_codes"])
179
+ serialized = handler(self)
180
+ m = {}
181
+
182
+ for n, f in type(self).model_fields.items():
183
+ k = f.alias or n
184
+ val = serialized.get(k)
185
+
186
+ if val != UNSET_SENTINEL:
187
+ if val is not None or k not in optional_fields:
188
+ m[k] = val
189
+
190
+ return m
191
+
192
+
193
+ CreateTranslationLoadBalancerRouterAudioTranslationsType = Literal["weight_based",]
194
+
195
+
196
+ class CreateTranslationLoadBalancerRouterAudioTranslationsModelsTypedDict(TypedDict):
197
+ model: str
198
+ r"""Model identifier for load balancing"""
199
+ weight: NotRequired[float]
200
+ r"""Weight assigned to this model for load balancing"""
201
+
202
+
203
+ class CreateTranslationLoadBalancerRouterAudioTranslationsModels(BaseModel):
204
+ model: str
205
+ r"""Model identifier for load balancing"""
206
+
207
+ weight: Optional[float] = 0.5
208
+ r"""Weight assigned to this model for load balancing"""
209
+
210
+ @model_serializer(mode="wrap")
211
+ def serialize_model(self, handler):
212
+ optional_fields = set(["weight"])
213
+ serialized = handler(self)
214
+ m = {}
215
+
216
+ for n, f in type(self).model_fields.items():
217
+ k = f.alias or n
218
+ val = serialized.get(k)
219
+
220
+ if val != UNSET_SENTINEL:
221
+ if val is not None or k not in optional_fields:
222
+ m[k] = val
223
+
224
+ return m
225
+
226
+
227
+ class CreateTranslationLoadBalancerRouterAudioTranslations1TypedDict(TypedDict):
228
+ type: CreateTranslationLoadBalancerRouterAudioTranslationsType
229
+ models: List[CreateTranslationLoadBalancerRouterAudioTranslationsModelsTypedDict]
230
+
231
+
232
+ class CreateTranslationLoadBalancerRouterAudioTranslations1(BaseModel):
233
+ type: CreateTranslationLoadBalancerRouterAudioTranslationsType
234
+
235
+ models: List[CreateTranslationLoadBalancerRouterAudioTranslationsModels]
236
+
237
+
238
+ CreateTranslationRouterAudioTranslationsLoadBalancerTypedDict = (
239
+ CreateTranslationLoadBalancerRouterAudioTranslations1TypedDict
240
+ )
241
+ r"""Array of models with weights for load balancing requests"""
242
+
243
+
244
+ CreateTranslationRouterAudioTranslationsLoadBalancer = (
245
+ CreateTranslationLoadBalancerRouterAudioTranslations1
246
+ )
247
+ r"""Array of models with weights for load balancing requests"""
248
+
249
+
250
+ class CreateTranslationRouterAudioTranslationsTimeoutTypedDict(TypedDict):
251
+ 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."""
252
+
253
+ call_timeout: float
254
+ r"""Timeout value in milliseconds"""
255
+
256
+
257
+ class CreateTranslationRouterAudioTranslationsTimeout(BaseModel):
258
+ 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."""
259
+
260
+ call_timeout: float
261
+ r"""Timeout value in milliseconds"""
262
+
263
+
264
+ class CreateTranslationOrqTypedDict(TypedDict):
265
+ name: NotRequired[str]
266
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
267
+ fallbacks: NotRequired[
268
+ List[CreateTranslationRouterAudioTranslationsFallbacksTypedDict]
269
+ ]
270
+ r"""Array of fallback models to use if primary model fails"""
271
+ retry: NotRequired[CreateTranslationRouterAudioTranslationsRetryTypedDict]
272
+ r"""Retry configuration for the request"""
273
+ identity: NotRequired[PublicIdentityTypedDict]
274
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
275
+ contact: NotRequired[PublicContactTypedDict]
276
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
277
+ load_balancer: NotRequired[
278
+ CreateTranslationRouterAudioTranslationsLoadBalancerTypedDict
279
+ ]
280
+ r"""Array of models with weights for load balancing requests"""
281
+ timeout: NotRequired[CreateTranslationRouterAudioTranslationsTimeoutTypedDict]
282
+ 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."""
283
+
284
+
285
+ class CreateTranslationOrq(BaseModel):
286
+ name: Optional[str] = None
287
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
288
+
289
+ fallbacks: Optional[List[CreateTranslationRouterAudioTranslationsFallbacks]] = None
290
+ r"""Array of fallback models to use if primary model fails"""
291
+
292
+ retry: Optional[CreateTranslationRouterAudioTranslationsRetry] = None
293
+ r"""Retry configuration for the request"""
294
+
295
+ identity: Optional[PublicIdentity] = None
296
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
297
+
298
+ contact: Annotated[
299
+ Optional[PublicContact],
300
+ pydantic.Field(
301
+ deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
302
+ ),
303
+ ] = None
304
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
305
+
306
+ load_balancer: Optional[CreateTranslationRouterAudioTranslationsLoadBalancer] = None
307
+ r"""Array of models with weights for load balancing requests"""
308
+
309
+ timeout: Optional[CreateTranslationRouterAudioTranslationsTimeout] = None
310
+ 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."""
311
+
312
+ @model_serializer(mode="wrap")
313
+ def serialize_model(self, handler):
314
+ optional_fields = set(
315
+ [
316
+ "name",
317
+ "fallbacks",
318
+ "retry",
319
+ "identity",
320
+ "contact",
321
+ "load_balancer",
322
+ "timeout",
323
+ ]
324
+ )
325
+ serialized = handler(self)
326
+ m = {}
327
+
328
+ for n, f in type(self).model_fields.items():
329
+ k = f.alias or n
330
+ val = serialized.get(k)
331
+
332
+ if val != UNSET_SENTINEL:
333
+ if val is not None or k not in optional_fields:
334
+ m[k] = val
335
+
336
+ return m
337
+
338
+
339
+ class CreateTranslationFileTypedDict(TypedDict):
340
+ file_name: str
341
+ content: Union[bytes, IO[bytes], io.BufferedReader]
342
+ content_type: NotRequired[str]
343
+
344
+
345
+ class CreateTranslationFile(BaseModel):
346
+ file_name: Annotated[
347
+ str, pydantic.Field(alias="fileName"), FieldMetadata(multipart=True)
348
+ ]
349
+
350
+ content: Annotated[
351
+ Union[bytes, IO[bytes], io.BufferedReader],
352
+ pydantic.Field(alias=""),
353
+ FieldMetadata(multipart=MultipartFormMetadata(content=True)),
354
+ ]
355
+
356
+ content_type: Annotated[
357
+ Optional[str],
358
+ pydantic.Field(alias="Content-Type"),
359
+ FieldMetadata(multipart=True),
360
+ ] = None
361
+
362
+ @model_serializer(mode="wrap")
363
+ def serialize_model(self, handler):
364
+ optional_fields = set(["contentType"])
365
+ serialized = handler(self)
366
+ m = {}
367
+
368
+ for n, f in type(self).model_fields.items():
369
+ k = f.alias or n
370
+ val = serialized.get(k)
371
+
372
+ if val != UNSET_SENTINEL:
373
+ if val is not None or k not in optional_fields:
374
+ m[k] = val
375
+
376
+ return m
377
+
378
+
379
+ class CreateTranslationRequestBodyTypedDict(TypedDict):
380
+ r"""Translates audio into English."""
381
+
382
+ model: str
383
+ r"""ID of the model to use"""
384
+ prompt: NotRequired[str]
385
+ r"""An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language."""
386
+ enable_logging: NotRequired[bool]
387
+ r"""When enable_logging is set to false, zero retention mode is used. This disables history features like request stitching and is only available to enterprise customers."""
388
+ diarize: NotRequired[bool]
389
+ r"""Whether to annotate which speaker is currently talking in the uploaded file."""
390
+ response_format: NotRequired[CreateTranslationResponseFormat]
391
+ r"""The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt."""
392
+ tag_audio_events: NotRequired[bool]
393
+ r"""Whether to tag audio events like (laughter), (footsteps), etc. in the transcription."""
394
+ num_speakers: NotRequired[float]
395
+ r"""The maximum amount of speakers talking in the uploaded file. Helps with predicting who speaks when, the maximum is 32."""
396
+ timestamps_granularity: NotRequired[CreateTranslationTimestampsGranularity]
397
+ r"""The granularity of the timestamps in the transcription. Word provides word-level timestamps and character provides character-level timestamps per word."""
398
+ temperature: NotRequired[float]
399
+ r"""The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit."""
400
+ name: NotRequired[str]
401
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
402
+ fallbacks: NotRequired[List[CreateTranslationFallbacksTypedDict]]
403
+ r"""Array of fallback models to use if primary model fails"""
404
+ retry: NotRequired[CreateTranslationRetryTypedDict]
405
+ r"""Retry configuration for the request"""
406
+ load_balancer: NotRequired[CreateTranslationLoadBalancerTypedDict]
407
+ r"""Load balancer configuration for the request."""
408
+ timeout: NotRequired[CreateTranslationTimeoutTypedDict]
409
+ 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."""
410
+ orq: NotRequired[CreateTranslationOrqTypedDict]
411
+ file: NotRequired[CreateTranslationFileTypedDict]
412
+ r"""The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm."""
413
+
414
+
415
+ class CreateTranslationRequestBody(BaseModel):
416
+ r"""Translates audio into English."""
417
+
418
+ model: Annotated[str, FieldMetadata(multipart=True)]
419
+ r"""ID of the model to use"""
420
+
421
+ prompt: Annotated[Optional[str], FieldMetadata(multipart=True)] = None
422
+ r"""An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language."""
423
+
424
+ enable_logging: Annotated[Optional[bool], FieldMetadata(multipart=True)] = True
425
+ r"""When enable_logging is set to false, zero retention mode is used. This disables history features like request stitching and is only available to enterprise customers."""
426
+
427
+ diarize: Annotated[Optional[bool], FieldMetadata(multipart=True)] = False
428
+ r"""Whether to annotate which speaker is currently talking in the uploaded file."""
429
+
430
+ response_format: Annotated[
431
+ Optional[CreateTranslationResponseFormat], FieldMetadata(multipart=True)
432
+ ] = None
433
+ r"""The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt."""
434
+
435
+ tag_audio_events: Annotated[Optional[bool], FieldMetadata(multipart=True)] = True
436
+ r"""Whether to tag audio events like (laughter), (footsteps), etc. in the transcription."""
437
+
438
+ num_speakers: Annotated[Optional[float], FieldMetadata(multipart=True)] = None
439
+ r"""The maximum amount of speakers talking in the uploaded file. Helps with predicting who speaks when, the maximum is 32."""
440
+
441
+ timestamps_granularity: Annotated[
442
+ Optional[CreateTranslationTimestampsGranularity], FieldMetadata(multipart=True)
443
+ ] = "word"
444
+ r"""The granularity of the timestamps in the transcription. Word provides word-level timestamps and character provides character-level timestamps per word."""
445
+
446
+ temperature: Annotated[Optional[float], FieldMetadata(multipart=True)] = None
447
+ r"""The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit."""
448
+
449
+ name: Annotated[Optional[str], FieldMetadata(multipart=True)] = None
450
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
451
+
452
+ fallbacks: Annotated[
453
+ Optional[List[CreateTranslationFallbacks]],
454
+ FieldMetadata(multipart=MultipartFormMetadata(json=True)),
455
+ ] = None
456
+ r"""Array of fallback models to use if primary model fails"""
457
+
458
+ retry: Annotated[
459
+ Optional[CreateTranslationRetry],
460
+ FieldMetadata(multipart=MultipartFormMetadata(json=True)),
461
+ ] = None
462
+ r"""Retry configuration for the request"""
463
+
464
+ load_balancer: Annotated[
465
+ Optional[CreateTranslationLoadBalancer],
466
+ FieldMetadata(multipart=MultipartFormMetadata(json=True)),
467
+ ] = None
468
+ r"""Load balancer configuration for the request."""
469
+
470
+ timeout: Annotated[
471
+ Optional[CreateTranslationTimeout],
472
+ FieldMetadata(multipart=MultipartFormMetadata(json=True)),
473
+ ] = None
474
+ 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."""
475
+
476
+ orq: Annotated[
477
+ Optional[CreateTranslationOrq],
478
+ FieldMetadata(multipart=MultipartFormMetadata(json=True)),
479
+ ] = None
480
+
481
+ file: Annotated[
482
+ Optional[CreateTranslationFile],
483
+ FieldMetadata(multipart=MultipartFormMetadata(file=True)),
484
+ ] = None
485
+ r"""The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm."""
486
+
487
+ @model_serializer(mode="wrap")
488
+ def serialize_model(self, handler):
489
+ optional_fields = set(
490
+ [
491
+ "prompt",
492
+ "enable_logging",
493
+ "diarize",
494
+ "response_format",
495
+ "tag_audio_events",
496
+ "num_speakers",
497
+ "timestamps_granularity",
498
+ "temperature",
499
+ "name",
500
+ "fallbacks",
501
+ "retry",
502
+ "load_balancer",
503
+ "timeout",
504
+ "orq",
505
+ "file",
506
+ ]
507
+ )
508
+ serialized = handler(self)
509
+ m = {}
510
+
511
+ for n, f in type(self).model_fields.items():
512
+ k = f.alias or n
513
+ val = serialized.get(k)
514
+
515
+ if val != UNSET_SENTINEL:
516
+ if val is not None or k not in optional_fields:
517
+ m[k] = val
518
+
519
+ return m
520
+
521
+
522
+ class CreateTranslationErrorTypedDict(TypedDict):
523
+ message: str
524
+ type: str
525
+ param: Nullable[str]
526
+ code: str
527
+
528
+
529
+ class CreateTranslationError(BaseModel):
530
+ message: str
531
+
532
+ type: str
533
+
534
+ param: Nullable[str]
535
+
536
+ code: str
537
+
538
+ @model_serializer(mode="wrap")
539
+ def serialize_model(self, handler):
540
+ serialized = handler(self)
541
+ m = {}
542
+
543
+ for n, f in type(self).model_fields.items():
544
+ k = f.alias or n
545
+ val = serialized.get(k)
546
+
547
+ if val != UNSET_SENTINEL:
548
+ m[k] = val
549
+
550
+ return m
551
+
552
+
553
+ class CreateTranslationRouterAudioTranslationsResponseBodyData(BaseModel):
554
+ error: CreateTranslationError
555
+
556
+
557
+ @dataclass(unsafe_hash=True)
558
+ class CreateTranslationRouterAudioTranslationsResponseBody(OrqError):
559
+ r"""Returns validation error"""
560
+
561
+ data: CreateTranslationRouterAudioTranslationsResponseBodyData = field(hash=False)
562
+
563
+ def __init__(
564
+ self,
565
+ data: CreateTranslationRouterAudioTranslationsResponseBodyData,
566
+ raw_response: httpx.Response,
567
+ body: Optional[str] = None,
568
+ ):
569
+ fallback = body or raw_response.text
570
+ message = str(data.error.message) or fallback
571
+ super().__init__(message, raw_response, body)
572
+ object.__setattr__(self, "data", data)
573
+
574
+
575
+ class ResponseBodyWordsTypedDict(TypedDict):
576
+ word: NotRequired[str]
577
+ start: NotRequired[float]
578
+ end: NotRequired[float]
579
+
580
+
581
+ class ResponseBodyWords(BaseModel):
582
+ word: Optional[str] = None
583
+
584
+ start: Optional[float] = None
585
+
586
+ end: Optional[float] = None
587
+
588
+ @model_serializer(mode="wrap")
589
+ def serialize_model(self, handler):
590
+ optional_fields = set(["word", "start", "end"])
591
+ serialized = handler(self)
592
+ m = {}
593
+
594
+ for n, f in type(self).model_fields.items():
595
+ k = f.alias or n
596
+ val = serialized.get(k)
597
+
598
+ if val != UNSET_SENTINEL:
599
+ if val is not None or k not in optional_fields:
600
+ m[k] = val
601
+
602
+ return m
603
+
604
+
605
+ class ResponseBodySegmentsTypedDict(TypedDict):
606
+ id: float
607
+ seek: float
608
+ start: float
609
+ end: float
610
+ text: str
611
+ tokens: List[float]
612
+ temperature: float
613
+ avg_logprob: float
614
+ compression_ratio: float
615
+ no_speech_prob: float
616
+
617
+
618
+ class ResponseBodySegments(BaseModel):
619
+ id: float
620
+
621
+ seek: float
622
+
623
+ start: float
624
+
625
+ end: float
626
+
627
+ text: str
628
+
629
+ tokens: List[float]
630
+
631
+ temperature: float
632
+
633
+ avg_logprob: float
634
+
635
+ compression_ratio: float
636
+
637
+ no_speech_prob: float
638
+
639
+
640
+ class CreateTranslationResponseBody2TypedDict(TypedDict):
641
+ text: str
642
+ task: NotRequired[str]
643
+ language: NotRequired[str]
644
+ duration: NotRequired[float]
645
+ words: NotRequired[List[ResponseBodyWordsTypedDict]]
646
+ segments: NotRequired[List[ResponseBodySegmentsTypedDict]]
647
+
648
+
649
+ class CreateTranslationResponseBody2(BaseModel):
650
+ text: str
651
+
652
+ task: Optional[str] = None
653
+
654
+ language: Optional[str] = None
655
+
656
+ duration: Optional[float] = None
657
+
658
+ words: Optional[List[ResponseBodyWords]] = None
659
+
660
+ segments: Optional[List[ResponseBodySegments]] = None
661
+
662
+ @model_serializer(mode="wrap")
663
+ def serialize_model(self, handler):
664
+ optional_fields = set(["task", "language", "duration", "words", "segments"])
665
+ serialized = handler(self)
666
+ m = {}
667
+
668
+ for n, f in type(self).model_fields.items():
669
+ k = f.alias or n
670
+ val = serialized.get(k)
671
+
672
+ if val != UNSET_SENTINEL:
673
+ if val is not None or k not in optional_fields:
674
+ m[k] = val
675
+
676
+ return m
677
+
678
+
679
+ class CreateTranslationResponseBody1TypedDict(TypedDict):
680
+ text: str
681
+
682
+
683
+ class CreateTranslationResponseBody1(BaseModel):
684
+ text: str
685
+
686
+
687
+ CreateTranslationResponseBodyTypedDict = TypeAliasType(
688
+ "CreateTranslationResponseBodyTypedDict",
689
+ Union[
690
+ CreateTranslationResponseBody1TypedDict,
691
+ CreateTranslationResponseBody2TypedDict,
692
+ str,
693
+ ],
694
+ )
695
+ r"""Returns the translated text"""
696
+
697
+
698
+ CreateTranslationResponseBody = TypeAliasType(
699
+ "CreateTranslationResponseBody",
700
+ Union[CreateTranslationResponseBody1, CreateTranslationResponseBody2, str],
701
+ )
702
+ r"""Returns the translated text"""