import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import * as SarvamAI from "../../../index.js"; export declare namespace DocAiClient { type Options = BaseClientOptions; interface RequestOptions extends BaseRequestOptions { } } export declare class DocAiClient { protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options?: DocAiClient.Options); /** * Creates a direct-upload handle for a file to be processed later. * * **Flow:** * 1. Call this endpoint with the MIME type you will upload (e.g. `application/pdf`). * 2. Upload the file using the returned `method`, `url` and `headers` before `expires_at`. * 3. Pass the returned `upload_id` through the `upload_ids` field on a later parse or extract job request. * * When `content_type` is set, the upload's `Content-Type` header must match it. * * @param {SarvamAI.DocAiPresignUploadRequest} request * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.BadRequestError} * @throws {@link SarvamAI.PaymentRequiredError} * @throws {@link SarvamAI.ForbiddenError} * @throws {@link SarvamAI.TooManyRequestsError} * @throws {@link SarvamAI.ServiceUnavailableError} * * @example * await client.docAi.createUploadUrl() */ createUploadUrl(request?: SarvamAI.DocAiPresignUploadRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __createUploadUrl; /** * Creates and starts a parse job from files or pre-uploaded handles. Parse converts documents into structured HTML, Markdown, or JSON while preserving layout. * * **Input:** Exactly one of `file` and `upload_ids` must be provided. Use `POST /doc-ai/v1/job/upload` to obtain upload IDs. * * **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until a terminal status (`completed`, `partially_completed`, `failed`, `rejected`), then fetch output via the results or download-url endpoints. * * Parse JSON results include blocks with text, tag and bounding box. * * @param {SarvamAI.DocAiParseRequest} request * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.BadRequestError} * @throws {@link SarvamAI.PaymentRequiredError} * @throws {@link SarvamAI.ForbiddenError} * @throws {@link SarvamAI.ContentTooLargeError} * @throws {@link SarvamAI.TooManyRequestsError} * @throws {@link SarvamAI.ServiceUnavailableError} * * @example * import { createReadStream } from "fs"; * await client.docAi.parse({}) */ parse(request: SarvamAI.DocAiParseRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __parse; /** * Creates and starts an extract job from files or pre-uploaded handles. Extract pulls structured fields out of documents according to a schema. * * **Input:** Exactly one of `file` and `upload_ids` must be provided. * * **Schema:** exactly one of `schema` (inline JSON schema) and `config_id` (saved extraction configuration) is required. * * **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until a terminal status (`completed`, `partially_completed`, `failed`, `rejected`), then fetch output via the results or download-url endpoints. * * Extract results include `result`, plus `annotations` mirroring the result shape where every leaf has `confidence` and `sources`. * * @param {SarvamAI.DocAiExtractRequest} request * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.BadRequestError} * @throws {@link SarvamAI.PaymentRequiredError} * @throws {@link SarvamAI.ForbiddenError} * @throws {@link SarvamAI.ContentTooLargeError} * @throws {@link SarvamAI.TooManyRequestsError} * @throws {@link SarvamAI.ServiceUnavailableError} * * @example * import { createReadStream } from "fs"; * await client.docAi.extract({ * schema: "{\"type\":\"object\",\"properties\":{\"policy_number\":{\"type\":\"string\",\"description\":\"Insurance policy number\"},\"insured_name\":{\"type\":\"string\",\"description\":\"Name of the insured person\"},\"sum_insured\":{\"type\":\"number\",\"description\":\"Total sum insured, in INR\"}}}", * output_format: "json" * }) */ extract(request: SarvamAI.DocAiExtractRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __extract; /** * Creates a Classify job. Classify labels a document, or each page, against the categories you define, or suggests a document type when you supply none. * * **Input:** send `file` (PDF, PNG, JPEG or TIFF; repeat the field for up to 10 documents) or `upload_ids`, plus a JSON `request` with the options below. You can also send a JSON body with `input` set to `{"document_ref": "..."}` to classify a child document returned by Split. * * **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until it is `completed`, then fetch `GET /doc-ai/v1/job/{job_id}/results`. Add `?include=details` to the results for inspected pages, provenance and evidence. * * **Review:** `review_required` tells you whether a person should check the answer. `confidence` can be `null`; it is a token-based score, not a measured probability. * * @param {SarvamAI.DocAiClassifyRequest} request * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.BadRequestError} * @throws {@link SarvamAI.UnauthorizedError} * @throws {@link SarvamAI.NotFoundError} * @throws {@link SarvamAI.ConflictError} * @throws {@link SarvamAI.UnprocessableEntityError} * * @example * import { createReadStream } from "fs"; * await client.docAi.classify({ * request: {} * }) */ classify(request: SarvamAI.DocAiClassifyRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __classify; /** * Creates a Split job. Split divides a bundle of pages into separate child documents, each with its original page numbers and a `document_ref` you can reuse in other requests. * * **Methods:** `fixed_pages` (equal page groups), `page_ranges` (you give the boundaries), `triggers` (split at QR codes, barcodes, blank pages, text or photos) and `semantic` (the model finds the boundaries). * * **Input:** send `file` (PDF, PNG, JPEG or TIFF; repeat the field for up to 10 documents) or `upload_ids`, plus a JSON `request`. * * **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until it is `completed`, then fetch `GET /doc-ai/v1/job/{job_id}/results`. `completed` means processing finished, not that every segment passed review: check each segment's `review.required`. * * @param {SarvamAI.DocAiSplitRequest} request * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.BadRequestError} * @throws {@link SarvamAI.UnauthorizedError} * @throws {@link SarvamAI.NotFoundError} * @throws {@link SarvamAI.ConflictError} * @throws {@link SarvamAI.UnprocessableEntityError} * * @example * import { createReadStream } from "fs"; * await client.docAi.split({ * request: {} * }) */ split(request: SarvamAI.DocAiSplitRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __split; /** * Returns a job's status and page-level usage. * * **Terminal statuses:** `completed`, `partially_completed`, `failed`, `rejected`. Results and download URLs are only available after the job reaches a terminal status. * * @param {string} job_id - The unique identifier of the job * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.NotFoundError} * * @example * await client.docAi.getStatus("job_id") */ getStatus(job_id: string, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __getStatus; /** * Returns terminal job results. Results are never available while a job is running; requesting them before a terminal status returns `409`. * * **Parse results** include `job_id`, `type`, `status`, `usage` and `documents`. * * **Extract results** include `job_id`, `type`, `status`, `usage`, `result`, `annotations` and `version`. `annotations` mirrors the result shape; every leaf has `confidence` and `sources`. * * @param {string} job_id - The unique identifier of the job. * @param {SarvamAI.DocAiGetResultsRequest} request * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.NotFoundError} * @throws {@link SarvamAI.ConflictError} * * @example * await client.docAi.getResults("20260707_6eb74174-e2c3-490d-afe5-d2e7e9e2b6c7", { * format: "json" * }) * * @example * await client.docAi.getResults("20260707_9f1c2b3a-4d5e-6f70-8a9b-c0d1e2f3a4b5", { * format: "json" * }) * * @example * await client.docAi.getResults("01a17998-120b-73dc-ad42-5cd66e0fe0ff") * * @example * await client.docAi.getResults("01a17998-07ef-7040-800d-745a95140cf5") */ getResults(job_id: string, request?: SarvamAI.DocAiGetResultsRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __getResults; /** * Creates a download URL for a completed job's output. Download the output using the returned `method`, `url` and `headers` before `expires_at`. * * Requesting a download URL before the job reaches a terminal status returns `409`. * * @param {string} job_id - The unique identifier of the job * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.NotFoundError} * @throws {@link SarvamAI.ConflictError} * * @example * await client.docAi.getDownloadUrl("job_id") */ getDownloadUrl(job_id: string, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __getDownloadUrl; /** * Returns the Classify and Split features, input formats, limits and options enabled on this deployment. Check it before using options such as `reasoning_input` image modes or photo triggers. * * @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link SarvamAI.UnauthorizedError} * * @example * await client.docAi.getCapabilities() */ getCapabilities(requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise; private __getCapabilities; }