sarvamai 0.1.22a4__py3-none-any.whl → 0.1.22a8__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 (76) hide show
  1. sarvamai/__init__.py +62 -3
  2. sarvamai/client.py +3 -0
  3. sarvamai/core/client_wrapper.py +2 -2
  4. sarvamai/doc_digitization_job/__init__.py +4 -0
  5. sarvamai/doc_digitization_job/client.py +775 -0
  6. sarvamai/doc_digitization_job/job.py +496 -0
  7. sarvamai/doc_digitization_job/raw_client.py +1176 -0
  8. sarvamai/requests/__init__.py +20 -0
  9. sarvamai/requests/audio_data.py +0 -6
  10. sarvamai/requests/configure_connection.py +4 -0
  11. sarvamai/requests/configure_connection_data.py +40 -11
  12. sarvamai/requests/doc_digitization_create_job_response.py +25 -0
  13. sarvamai/requests/doc_digitization_download_files_response.py +37 -0
  14. sarvamai/requests/doc_digitization_error_details.py +21 -0
  15. sarvamai/requests/doc_digitization_error_message.py +11 -0
  16. sarvamai/requests/doc_digitization_job_detail.py +64 -0
  17. sarvamai/requests/doc_digitization_job_parameters.py +21 -0
  18. sarvamai/requests/doc_digitization_job_status_response.py +65 -0
  19. sarvamai/requests/doc_digitization_page_error.py +24 -0
  20. sarvamai/requests/doc_digitization_upload_files_response.py +34 -0
  21. sarvamai/requests/doc_digitization_webhook_callback.py +19 -0
  22. sarvamai/requests/speech_to_text_job_parameters.py +43 -2
  23. sarvamai/requests/speech_to_text_translate_job_parameters.py +4 -1
  24. sarvamai/speech_to_text/client.py +95 -10
  25. sarvamai/speech_to_text/raw_client.py +95 -10
  26. sarvamai/speech_to_text_job/client.py +60 -15
  27. sarvamai/speech_to_text_streaming/__init__.py +4 -0
  28. sarvamai/speech_to_text_streaming/client.py +102 -18
  29. sarvamai/speech_to_text_streaming/raw_client.py +102 -18
  30. sarvamai/speech_to_text_streaming/types/__init__.py +4 -0
  31. sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_input_audio_codec.py +1 -27
  32. sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_mode.py +7 -0
  33. sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +5 -0
  34. sarvamai/speech_to_text_translate_streaming/client.py +20 -12
  35. sarvamai/speech_to_text_translate_streaming/raw_client.py +20 -12
  36. sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_input_audio_codec.py +1 -27
  37. sarvamai/text/client.py +0 -12
  38. sarvamai/text/raw_client.py +0 -12
  39. sarvamai/text_to_speech/client.py +116 -14
  40. sarvamai/text_to_speech/raw_client.py +116 -14
  41. sarvamai/text_to_speech_streaming/__init__.py +2 -2
  42. sarvamai/text_to_speech_streaming/client.py +19 -6
  43. sarvamai/text_to_speech_streaming/raw_client.py +19 -6
  44. sarvamai/text_to_speech_streaming/types/__init__.py +2 -1
  45. sarvamai/text_to_speech_streaming/types/text_to_speech_streaming_model.py +5 -0
  46. sarvamai/types/__init__.py +34 -2
  47. sarvamai/types/audio_data.py +0 -6
  48. sarvamai/types/configure_connection.py +4 -0
  49. sarvamai/types/configure_connection_data.py +40 -11
  50. sarvamai/types/configure_connection_data_model.py +5 -0
  51. sarvamai/types/configure_connection_data_speaker.py +35 -1
  52. sarvamai/types/doc_digitization_create_job_response.py +37 -0
  53. sarvamai/types/doc_digitization_download_files_response.py +47 -0
  54. sarvamai/types/doc_digitization_error_code.py +15 -0
  55. sarvamai/types/doc_digitization_error_details.py +33 -0
  56. sarvamai/types/doc_digitization_error_message.py +23 -0
  57. sarvamai/types/doc_digitization_job_detail.py +74 -0
  58. sarvamai/types/doc_digitization_job_detail_state.py +7 -0
  59. sarvamai/types/doc_digitization_job_parameters.py +33 -0
  60. sarvamai/types/doc_digitization_job_state.py +7 -0
  61. sarvamai/types/doc_digitization_job_status_response.py +75 -0
  62. sarvamai/types/doc_digitization_output_format.py +5 -0
  63. sarvamai/types/doc_digitization_page_error.py +36 -0
  64. sarvamai/types/doc_digitization_supported_language.py +32 -0
  65. sarvamai/types/doc_digitization_upload_files_response.py +44 -0
  66. sarvamai/types/doc_digitization_webhook_callback.py +31 -0
  67. sarvamai/types/mode.py +5 -0
  68. sarvamai/types/speech_to_text_job_parameters.py +43 -2
  69. sarvamai/types/speech_to_text_model.py +1 -1
  70. sarvamai/types/speech_to_text_translate_job_parameters.py +4 -1
  71. sarvamai/types/text_to_speech_model.py +1 -1
  72. sarvamai/types/text_to_speech_speaker.py +35 -1
  73. {sarvamai-0.1.22a4.dist-info → sarvamai-0.1.22a8.dist-info}/METADATA +1 -1
  74. {sarvamai-0.1.22a4.dist-info → sarvamai-0.1.22a8.dist-info}/RECORD +75 -42
  75. sarvamai/types/audio_data_input_audio_codec.py +0 -33
  76. {sarvamai-0.1.22a4.dist-info → sarvamai-0.1.22a8.dist-info}/WHEEL +0 -0
@@ -0,0 +1,775 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from ..requests.doc_digitization_job_parameters import (
8
+ DocDigitizationJobParametersParams,
9
+ )
10
+ from ..requests.doc_digitization_webhook_callback import (
11
+ DocDigitizationWebhookCallbackParams,
12
+ )
13
+ from ..types.doc_digitization_create_job_response import (
14
+ DocDigitizationCreateJobResponse,
15
+ )
16
+ from ..types.doc_digitization_download_files_response import (
17
+ DocDigitizationDownloadFilesResponse,
18
+ )
19
+ from ..types.doc_digitization_job_status_response import (
20
+ DocDigitizationJobStatusResponse,
21
+ )
22
+ from ..types.doc_digitization_upload_files_response import (
23
+ DocDigitizationUploadFilesResponse,
24
+ )
25
+ from ..types.doc_digitization_supported_language import DocDigitizationSupportedLanguage
26
+ from ..types.doc_digitization_output_format import DocDigitizationOutputFormat
27
+ from .raw_client import AsyncRawDocDigitizationJobClient, RawDocDigitizationJobClient
28
+ from .job import DocDigitizationJob, AsyncDocDigitizationJob
29
+
30
+ # this is used as the default value for optional parameters
31
+ OMIT = typing.cast(typing.Any, ...)
32
+
33
+
34
+ class DocDigitizationJobClient:
35
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
36
+ self._raw_client = RawDocDigitizationJobClient(client_wrapper=client_wrapper)
37
+
38
+ @property
39
+ def with_raw_response(self) -> RawDocDigitizationJobClient:
40
+ """
41
+ Retrieves a raw implementation of this client that returns raw responses.
42
+
43
+ Returns
44
+ -------
45
+ RawDocDigitizationJobClient
46
+ """
47
+ return self._raw_client
48
+
49
+ def initialise(
50
+ self,
51
+ *,
52
+ job_parameters: typing.Optional[DocDigitizationJobParametersParams] = OMIT,
53
+ callback: typing.Optional[DocDigitizationWebhookCallbackParams] = OMIT,
54
+ request_options: typing.Optional[RequestOptions] = None,
55
+ ) -> DocDigitizationCreateJobResponse:
56
+ """
57
+ Creates a new document digitization job.
58
+
59
+ **Supported Languages:**
60
+ - `hi`: Hindi
61
+ - `en`: English
62
+ - `bn`: Bengali
63
+ - `gu`: Gujarati
64
+ - `kn`: Kannada
65
+ - `ml`: Malayalam
66
+ - `mr`: Marathi
67
+ - `or`: Odia
68
+ - `pa`: Punjabi
69
+ - `ta`: Tamil
70
+ - `te`: Telugu
71
+ - `ur`: Urdu
72
+ - `as`: Assamese
73
+ - `bodo`: Bodo
74
+ - `doi`: Dogri
75
+ - `ks`: Kashmiri
76
+ - `kok`: Konkani
77
+ - `mai`: Maithili
78
+ - `mni`: Manipuri
79
+ - `ne`: Nepali
80
+ - `sa`: Sanskrit
81
+ - `sat`: Santali
82
+ - `sd`: Sindhi
83
+
84
+ **Output Formats:**
85
+ - `html`: Structured HTML with layout preservation (default)
86
+ - `md`: Markdown format
87
+
88
+ **Webhook Callback:**
89
+ Optionally provide a callback URL to receive notification when processing completes.
90
+
91
+ Parameters
92
+ ----------
93
+ job_parameters : typing.Optional[DocDigitizationJobParametersParams]
94
+ Job configuration parameters. Omit the request body to use defaults.
95
+
96
+ callback : typing.Optional[DocDigitizationWebhookCallbackParams]
97
+ Optional webhook for completion notification
98
+
99
+ request_options : typing.Optional[RequestOptions]
100
+ Request-specific configuration.
101
+
102
+ Returns
103
+ -------
104
+ DocDigitizationCreateJobResponse
105
+ Successful Response
106
+
107
+ Examples
108
+ --------
109
+ from sarvamai import SarvamAI
110
+
111
+ client = SarvamAI(
112
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
113
+ )
114
+ client.doc_digitization_job.initialise()
115
+ """
116
+ _response = self._raw_client.initialise(
117
+ job_parameters=job_parameters,
118
+ callback=callback,
119
+ request_options=request_options,
120
+ )
121
+ return _response.data
122
+
123
+ def get_upload_links(
124
+ self,
125
+ *,
126
+ job_id: str,
127
+ files: typing.Sequence[str],
128
+ request_options: typing.Optional[RequestOptions] = None,
129
+ ) -> DocDigitizationUploadFilesResponse:
130
+ """
131
+ Returns presigned URLs for uploading input files.
132
+
133
+ **File Constraints:**
134
+ - Exactly one file required (PDF or ZIP)
135
+ - PDF files: `.pdf` extension
136
+ - ZIP files: `.zip` extension
137
+
138
+ Parameters
139
+ ----------
140
+ job_id : str
141
+ Job identifier returned from Create Job
142
+
143
+ files : typing.Sequence[str]
144
+ List of filenames to upload (exactly 1 file: PDF or ZIP)
145
+
146
+ request_options : typing.Optional[RequestOptions]
147
+ Request-specific configuration.
148
+
149
+ Returns
150
+ -------
151
+ DocDigitizationUploadFilesResponse
152
+ Successful Response
153
+
154
+ Examples
155
+ --------
156
+ from sarvamai import SarvamAI
157
+
158
+ client = SarvamAI(
159
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
160
+ )
161
+ client.doc_digitization_job.get_upload_links(
162
+ job_id="job_id",
163
+ files=["files"],
164
+ )
165
+ """
166
+ _response = self._raw_client.get_upload_links(
167
+ job_id=job_id, files=files, request_options=request_options
168
+ )
169
+ return _response.data
170
+
171
+ def start(
172
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
173
+ ) -> DocDigitizationJobStatusResponse:
174
+ """
175
+ Validates the uploaded file and starts processing.
176
+
177
+ **Validation Checks:**
178
+ - File must be uploaded before starting
179
+ - File size must not exceed 200 MB
180
+ - PDF must be parseable by the PDF parser
181
+ - ZIP must contain only JPEG/PNG images
182
+ - ZIP must be flat (no nested folders beyond one level)
183
+ - ZIP must contain at least one valid image
184
+ - Page/image count must not exceed 500
185
+ - User must have sufficient credits
186
+
187
+ **Processing:**
188
+ Job runs asynchronously. Poll the status endpoint or use webhook callback for completion notification.
189
+
190
+ Parameters
191
+ ----------
192
+ job_id : str
193
+ The unique identifier of the job
194
+
195
+ request_options : typing.Optional[RequestOptions]
196
+ Request-specific configuration.
197
+
198
+ Returns
199
+ -------
200
+ DocDigitizationJobStatusResponse
201
+ Successful Response
202
+
203
+ Examples
204
+ --------
205
+ from sarvamai import SarvamAI
206
+
207
+ client = SarvamAI(
208
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
209
+ )
210
+ client.doc_digitization_job.start(
211
+ job_id="job_id",
212
+ )
213
+ """
214
+ _response = self._raw_client.start(job_id, request_options=request_options)
215
+ return _response.data
216
+
217
+ def get_status(
218
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
219
+ ) -> DocDigitizationJobStatusResponse:
220
+ """
221
+ Returns the current status of a job with page-level metrics.
222
+
223
+ **Job States:**
224
+ - `Accepted`: Job created, awaiting file upload
225
+ - `Pending`: File uploaded, waiting to start
226
+ - `Running`: Processing in progress
227
+ - `Completed`: All pages processed successfully
228
+ - `PartiallyCompleted`: Some pages succeeded, some failed
229
+ - `Failed`: All pages failed or job-level error
230
+
231
+ **Page Metrics:**
232
+ Response includes detailed progress: total pages, pages processed, succeeded, failed, and per-page errors.
233
+
234
+ Parameters
235
+ ----------
236
+ job_id : str
237
+ The unique identifier of the job
238
+
239
+ request_options : typing.Optional[RequestOptions]
240
+ Request-specific configuration.
241
+
242
+ Returns
243
+ -------
244
+ DocDigitizationJobStatusResponse
245
+ Successful Response
246
+
247
+ Examples
248
+ --------
249
+ from sarvamai import SarvamAI
250
+
251
+ client = SarvamAI(
252
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
253
+ )
254
+ client.doc_digitization_job.get_status(
255
+ job_id="job_id",
256
+ )
257
+ """
258
+ _response = self._raw_client.get_status(job_id, request_options=request_options)
259
+ return _response.data
260
+
261
+ def get_download_links(
262
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
263
+ ) -> DocDigitizationDownloadFilesResponse:
264
+ """
265
+ Returns presigned URLs for downloading output files.
266
+
267
+ **Prerequisites:**
268
+ - Job must be in `Completed` or `PartiallyCompleted` state
269
+ - Failed jobs have no output available
270
+
271
+ Parameters
272
+ ----------
273
+ job_id : str
274
+ The unique identifier of the job
275
+
276
+ request_options : typing.Optional[RequestOptions]
277
+ Request-specific configuration.
278
+
279
+ Returns
280
+ -------
281
+ DocDigitizationDownloadFilesResponse
282
+ Successful Response
283
+
284
+ Examples
285
+ --------
286
+ from sarvamai import SarvamAI
287
+
288
+ client = SarvamAI(
289
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
290
+ )
291
+ client.doc_digitization_job.get_download_links(
292
+ job_id="job_id",
293
+ )
294
+ """
295
+ _response = self._raw_client.get_download_links(
296
+ job_id, request_options=request_options
297
+ )
298
+ return _response.data
299
+
300
+ def create_job(
301
+ self,
302
+ language: DocDigitizationSupportedLanguage = "hi",
303
+ output_format: DocDigitizationOutputFormat = "html",
304
+ callback: typing.Optional[DocDigitizationWebhookCallbackParams] = OMIT,
305
+ request_options: typing.Optional[RequestOptions] = None,
306
+ ) -> DocDigitizationJob:
307
+ """
308
+ Create a new Document Digitization job.
309
+
310
+ Parameters
311
+ ----------
312
+ language : DocDigitizationSupportedLanguage, default="hi"
313
+ ISO language code for the document.
314
+
315
+ output_format : DocDigitizationOutputFormat, default="html"
316
+ Output format: "html" for structured HTML or "md" for Markdown.
317
+
318
+ callback : typing.Optional[DocDigitizationWebhookCallbackParams], default=OMIT
319
+ Optional webhook configuration for job completion notification.
320
+
321
+ request_options : typing.Optional[RequestOptions], default=None
322
+ Request-specific configuration.
323
+
324
+ Returns
325
+ -------
326
+ DocDigitizationJob
327
+ A handle to the newly created Document Digitization job.
328
+
329
+ Examples
330
+ --------
331
+ from sarvamai import SarvamAI
332
+
333
+ client = SarvamAI(api_subscription_key="YOUR_API_SUBSCRIPTION_KEY")
334
+
335
+ # Create job and get handle
336
+ job = client.doc_digitization_job.create_job(language="hi", output_format="md")
337
+
338
+ # Upload PDF, start, wait, download
339
+ job.upload_file("/path/to/document.pdf")
340
+ job.start()
341
+ job.wait_until_complete()
342
+ job.download_output("./output.md")
343
+ """
344
+ response = self.initialise(
345
+ job_parameters=DocDigitizationJobParametersParams(
346
+ language=language,
347
+ output_format=output_format,
348
+ ),
349
+ callback=callback,
350
+ request_options=request_options,
351
+ )
352
+ return DocDigitizationJob(job_id=response.job_id, client=self)
353
+
354
+ def get_job(self, job_id: str) -> DocDigitizationJob:
355
+ """
356
+ Get an existing Document Digitization job handle by job ID.
357
+
358
+ Parameters
359
+ ----------
360
+ job_id : str
361
+ The job ID of a previously created Document Digitization job.
362
+
363
+ Returns
364
+ -------
365
+ DocDigitizationJob
366
+ A job handle which can be used to check status, upload files, or download results.
367
+
368
+ Examples
369
+ --------
370
+ from sarvamai import SarvamAI
371
+
372
+ client = SarvamAI(api_subscription_key="YOUR_API_SUBSCRIPTION_KEY")
373
+
374
+ # Get existing job
375
+ job = client.doc_digitization_job.get_job(job_id="your-job-uuid")
376
+ status = job.get_status()
377
+ """
378
+ return DocDigitizationJob(job_id=job_id, client=self)
379
+
380
+
381
+ class AsyncDocDigitizationJobClient:
382
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
383
+ self._raw_client = AsyncRawDocDigitizationJobClient(
384
+ client_wrapper=client_wrapper
385
+ )
386
+
387
+ @property
388
+ def with_raw_response(self) -> AsyncRawDocDigitizationJobClient:
389
+ """
390
+ Retrieves a raw implementation of this client that returns raw responses.
391
+
392
+ Returns
393
+ -------
394
+ AsyncRawDocDigitizationJobClient
395
+ """
396
+ return self._raw_client
397
+
398
+ async def initialise(
399
+ self,
400
+ *,
401
+ job_parameters: typing.Optional[DocDigitizationJobParametersParams] = OMIT,
402
+ callback: typing.Optional[DocDigitizationWebhookCallbackParams] = OMIT,
403
+ request_options: typing.Optional[RequestOptions] = None,
404
+ ) -> DocDigitizationCreateJobResponse:
405
+ """
406
+ Creates a new document digitization job.
407
+
408
+ **Supported Languages:**
409
+ - `hi`: Hindi
410
+ - `en`: English
411
+ - `bn`: Bengali
412
+ - `gu`: Gujarati
413
+ - `kn`: Kannada
414
+ - `ml`: Malayalam
415
+ - `mr`: Marathi
416
+ - `or`: Odia
417
+ - `pa`: Punjabi
418
+ - `ta`: Tamil
419
+ - `te`: Telugu
420
+ - `ur`: Urdu
421
+ - `as`: Assamese
422
+ - `bodo`: Bodo
423
+ - `doi`: Dogri
424
+ - `ks`: Kashmiri
425
+ - `kok`: Konkani
426
+ - `mai`: Maithili
427
+ - `mni`: Manipuri
428
+ - `ne`: Nepali
429
+ - `sa`: Sanskrit
430
+ - `sat`: Santali
431
+ - `sd`: Sindhi
432
+
433
+ **Output Formats:**
434
+ - `html`: Structured HTML with layout preservation (default)
435
+ - `md`: Markdown format
436
+
437
+ **Webhook Callback:**
438
+ Optionally provide a callback URL to receive notification when processing completes.
439
+
440
+ Parameters
441
+ ----------
442
+ job_parameters : typing.Optional[DocDigitizationJobParametersParams]
443
+ Job configuration parameters. Omit the request body to use defaults.
444
+
445
+ callback : typing.Optional[DocDigitizationWebhookCallbackParams]
446
+ Optional webhook for completion notification
447
+
448
+ request_options : typing.Optional[RequestOptions]
449
+ Request-specific configuration.
450
+
451
+ Returns
452
+ -------
453
+ DocDigitizationCreateJobResponse
454
+ Successful Response
455
+
456
+ Examples
457
+ --------
458
+ import asyncio
459
+
460
+ from sarvamai import AsyncSarvamAI
461
+
462
+ client = AsyncSarvamAI(
463
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
464
+ )
465
+
466
+
467
+ async def main() -> None:
468
+ await client.doc_digitization_job.initialise()
469
+
470
+
471
+ asyncio.run(main())
472
+ """
473
+ _response = await self._raw_client.initialise(
474
+ job_parameters=job_parameters,
475
+ callback=callback,
476
+ request_options=request_options,
477
+ )
478
+ return _response.data
479
+
480
+ async def get_upload_links(
481
+ self,
482
+ *,
483
+ job_id: str,
484
+ files: typing.Sequence[str],
485
+ request_options: typing.Optional[RequestOptions] = None,
486
+ ) -> DocDigitizationUploadFilesResponse:
487
+ """
488
+ Returns presigned URLs for uploading input files.
489
+
490
+ **File Constraints:**
491
+ - Exactly one file required (PDF or ZIP)
492
+ - PDF files: `.pdf` extension
493
+ - ZIP files: `.zip` extension
494
+
495
+ Parameters
496
+ ----------
497
+ job_id : str
498
+ Job identifier returned from Create Job
499
+
500
+ files : typing.Sequence[str]
501
+ List of filenames to upload (exactly 1 file: PDF or ZIP)
502
+
503
+ request_options : typing.Optional[RequestOptions]
504
+ Request-specific configuration.
505
+
506
+ Returns
507
+ -------
508
+ DocDigitizationUploadFilesResponse
509
+ Successful Response
510
+
511
+ Examples
512
+ --------
513
+ import asyncio
514
+
515
+ from sarvamai import AsyncSarvamAI
516
+
517
+ client = AsyncSarvamAI(
518
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
519
+ )
520
+
521
+
522
+ async def main() -> None:
523
+ await client.doc_digitization_job.get_upload_links(
524
+ job_id="job_id",
525
+ files=["files"],
526
+ )
527
+
528
+
529
+ asyncio.run(main())
530
+ """
531
+ _response = await self._raw_client.get_upload_links(
532
+ job_id=job_id, files=files, request_options=request_options
533
+ )
534
+ return _response.data
535
+
536
+ async def start(
537
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
538
+ ) -> DocDigitizationJobStatusResponse:
539
+ """
540
+ Validates the uploaded file and starts processing.
541
+
542
+ **Validation Checks:**
543
+ - File must be uploaded before starting
544
+ - File size must not exceed 200 MB
545
+ - PDF must be parseable by the PDF parser
546
+ - ZIP must contain only JPEG/PNG images
547
+ - ZIP must be flat (no nested folders beyond one level)
548
+ - ZIP must contain at least one valid image
549
+ - Page/image count must not exceed 500
550
+ - User must have sufficient credits
551
+
552
+ **Processing:**
553
+ Job runs asynchronously. Poll the status endpoint or use webhook callback for completion notification.
554
+
555
+ Parameters
556
+ ----------
557
+ job_id : str
558
+ The unique identifier of the job
559
+
560
+ request_options : typing.Optional[RequestOptions]
561
+ Request-specific configuration.
562
+
563
+ Returns
564
+ -------
565
+ DocDigitizationJobStatusResponse
566
+ Successful Response
567
+
568
+ Examples
569
+ --------
570
+ import asyncio
571
+
572
+ from sarvamai import AsyncSarvamAI
573
+
574
+ client = AsyncSarvamAI(
575
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
576
+ )
577
+
578
+
579
+ async def main() -> None:
580
+ await client.doc_digitization_job.start(
581
+ job_id="job_id",
582
+ )
583
+
584
+
585
+ asyncio.run(main())
586
+ """
587
+ _response = await self._raw_client.start(
588
+ job_id, request_options=request_options
589
+ )
590
+ return _response.data
591
+
592
+ async def get_status(
593
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
594
+ ) -> DocDigitizationJobStatusResponse:
595
+ """
596
+ Returns the current status of a job with page-level metrics.
597
+
598
+ **Job States:**
599
+ - `Accepted`: Job created, awaiting file upload
600
+ - `Pending`: File uploaded, waiting to start
601
+ - `Running`: Processing in progress
602
+ - `Completed`: All pages processed successfully
603
+ - `PartiallyCompleted`: Some pages succeeded, some failed
604
+ - `Failed`: All pages failed or job-level error
605
+
606
+ **Page Metrics:**
607
+ Response includes detailed progress: total pages, pages processed, succeeded, failed, and per-page errors.
608
+
609
+ Parameters
610
+ ----------
611
+ job_id : str
612
+ The unique identifier of the job
613
+
614
+ request_options : typing.Optional[RequestOptions]
615
+ Request-specific configuration.
616
+
617
+ Returns
618
+ -------
619
+ DocDigitizationJobStatusResponse
620
+ Successful Response
621
+
622
+ Examples
623
+ --------
624
+ import asyncio
625
+
626
+ from sarvamai import AsyncSarvamAI
627
+
628
+ client = AsyncSarvamAI(
629
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
630
+ )
631
+
632
+
633
+ async def main() -> None:
634
+ await client.doc_digitization_job.get_status(
635
+ job_id="job_id",
636
+ )
637
+
638
+
639
+ asyncio.run(main())
640
+ """
641
+ _response = await self._raw_client.get_status(
642
+ job_id, request_options=request_options
643
+ )
644
+ return _response.data
645
+
646
+ async def get_download_links(
647
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
648
+ ) -> DocDigitizationDownloadFilesResponse:
649
+ """
650
+ Returns presigned URLs for downloading output files.
651
+
652
+ **Prerequisites:**
653
+ - Job must be in `Completed` or `PartiallyCompleted` state
654
+ - Failed jobs have no output available
655
+
656
+ Parameters
657
+ ----------
658
+ job_id : str
659
+ The unique identifier of the job
660
+
661
+ request_options : typing.Optional[RequestOptions]
662
+ Request-specific configuration.
663
+
664
+ Returns
665
+ -------
666
+ DocDigitizationDownloadFilesResponse
667
+ Successful Response
668
+
669
+ Examples
670
+ --------
671
+ import asyncio
672
+
673
+ from sarvamai import AsyncSarvamAI
674
+
675
+ client = AsyncSarvamAI(
676
+ api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
677
+ )
678
+
679
+
680
+ async def main() -> None:
681
+ await client.doc_digitization_job.get_download_links(
682
+ job_id="job_id",
683
+ )
684
+
685
+
686
+ asyncio.run(main())
687
+ """
688
+ _response = await self._raw_client.get_download_links(
689
+ job_id, request_options=request_options
690
+ )
691
+ return _response.data
692
+
693
+ async def create_job(
694
+ self,
695
+ language: DocDigitizationSupportedLanguage = "hi",
696
+ output_format: DocDigitizationOutputFormat = "html",
697
+ callback: typing.Optional[DocDigitizationWebhookCallbackParams] = OMIT,
698
+ request_options: typing.Optional[RequestOptions] = None,
699
+ ) -> AsyncDocDigitizationJob:
700
+ """
701
+ Create a new Document Digitization job.
702
+
703
+ Parameters
704
+ ----------
705
+ language : DocDigitizationSupportedLanguage, default="hi"
706
+ ISO language code for the document.
707
+
708
+ output_format : DocDigitizationOutputFormat, default="html"
709
+ Output format: "html" for structured HTML or "md" for Markdown.
710
+
711
+ callback : typing.Optional[DocDigitizationWebhookCallbackParams], default=OMIT
712
+ Optional webhook configuration for job completion notification.
713
+
714
+ request_options : typing.Optional[RequestOptions], default=None
715
+ Request-specific configuration.
716
+
717
+ Returns
718
+ -------
719
+ AsyncDocDigitizationJob
720
+ A handle to the newly created Document Digitization job.
721
+
722
+ Examples
723
+ --------
724
+ import asyncio
725
+ from sarvamai import AsyncSarvamAI
726
+
727
+ client = AsyncSarvamAI(api_subscription_key="YOUR_API_SUBSCRIPTION_KEY")
728
+
729
+ async def main():
730
+ job = await client.doc_digitization_job.create_job(language="hi", output_format="md")
731
+ await job.upload_file("/path/to/document.pdf")
732
+ await job.start()
733
+ await job.wait_until_complete()
734
+ await job.download_output("./output.md")
735
+
736
+ asyncio.run(main())
737
+ """
738
+ response = await self.initialise(
739
+ job_parameters=DocDigitizationJobParametersParams(
740
+ language=language,
741
+ output_format=output_format,
742
+ ),
743
+ callback=callback,
744
+ request_options=request_options,
745
+ )
746
+ return AsyncDocDigitizationJob(job_id=response.job_id, client=self)
747
+
748
+ def get_job(self, job_id: str) -> AsyncDocDigitizationJob:
749
+ """
750
+ Get an existing Document Digitization job handle by job ID.
751
+
752
+ Parameters
753
+ ----------
754
+ job_id : str
755
+ The job ID of a previously created Document Digitization job.
756
+
757
+ Returns
758
+ -------
759
+ AsyncDocDigitizationJob
760
+ A job handle which can be used to check status, upload files, or download results.
761
+
762
+ Examples
763
+ --------
764
+ import asyncio
765
+ from sarvamai import AsyncSarvamAI
766
+
767
+ client = AsyncSarvamAI(api_subscription_key="YOUR_API_SUBSCRIPTION_KEY")
768
+
769
+ async def main():
770
+ job = client.doc_digitization_job.get_job(job_id="your-job-uuid")
771
+ status = await job.get_status()
772
+
773
+ asyncio.run(main())
774
+ """
775
+ return AsyncDocDigitizationJob(job_id=job_id, client=self)