azure.ai.documentintelligence package

class azure.ai.documentintelligence.AnalyzeDocumentLROPoller(client: Any, initial_response: Any, deserialization_callback: Callable[[Any], PollingReturnType_co], polling_method: PollingMethod[PollingReturnType_co])[source]
add_done_callback(func: Callable) None

Add callback function to be run once the long running operation has completed - regardless of the status of the operation.

Parameters:

func (callable) – Callback function that takes at least one argument, a completed LongRunningOperation.

continuation_token() str

Return a continuation token that allows to restart the poller later.

Returns:

An opaque continuation token

Return type:

str

done() bool

Check status of the long running operation.

Returns:

‘True’ if the process has completed, else ‘False’.

Return type:

bool

classmethod from_continuation_token(polling_method: PollingMethod[PollingReturnType_co], continuation_token: str, **kwargs: Any) AnalyzeDocumentLROPoller[source]
polling_method() PollingMethod[PollingReturnType_co]

Return the polling method associated to this poller.

Returns:

The polling method

Return type:

PollingMethod

remove_done_callback(func: Callable) None

Remove a callback from the long running operation.

Parameters:

func (callable) – The function to be removed from the callbacks.

Raises:

ValueError – if the long running operation has already completed.

result(timeout: float | None = None) PollingReturnType_co

Return the result of the long running operation, or the result available after the specified timeout.

Parameters:

timeout (float) – Period of time to wait before getting back control.

Returns:

The deserialized resource of the long running operation, if one is available.

Return type:

any or None

Raises:

HttpResponseError – Server problem with the query.

status() str

Returns the current status string.

Returns:

The current status string

Return type:

str

wait(timeout: float | None = None) None

Wait on the long running operation for a specified length of time. You can check if this call as ended with timeout with the “done()” method.

Parameters:

timeout (float) – Period of time to wait for the long running operation to complete (in seconds).

Raises:

HttpResponseError – Server problem with the query.

property details: Mapping[str, Any]

Returns metadata associated with the long-running operation.

Returns:

Returns metadata associated with the long-running operation.

Return type:

Mapping[str, Any]

class azure.ai.documentintelligence.DocumentIntelligenceAdministrationClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, **kwargs: Any)[source]

DocumentIntelligenceAdministrationClient.

Parameters:
  • endpoint (str) – The Document Intelligence service endpoint. Required.

  • credential (AzureKeyCredential or TokenCredential) – Credential needed for the client to connect to Azure. Is either a AzureKeyCredential type or a TokenCredential type. Required.

Keyword Arguments:
  • api_version (str) – The API version to use for this operation. Default value is “2024-07-31-preview”. Note that overriding this default value may result in unsupported behavior.

  • polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.

authorize_classifier_copy(authorize_copy_request: AuthorizeClassifierCopyRequest | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) ClassifierCopyAuthorization

Generates authorization to copy a document classifier to this location with specified classifierId and optional description.

Parameters:

authorize_copy_request (AuthorizeClassifierCopyRequest or JSON or IO[bytes]) – Authorize copy request parameters. Is one of the following types: AuthorizeClassifierCopyRequest, JSON, IO[bytes] Required.

Returns:

ClassifierCopyAuthorization. The ClassifierCopyAuthorization is compatible with MutableMapping

Return type:

ClassifierCopyAuthorization

Raises:

HttpResponseError

authorize_model_copy(authorize_copy_request: AuthorizeCopyRequest | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) CopyAuthorization

Generates authorization to copy a document model to this location with specified modelId and optional description.

Parameters:

authorize_copy_request (AuthorizeCopyRequest or JSON or IO[bytes]) – Authorize copy request parameters. Is one of the following types: AuthorizeCopyRequest, JSON, IO[bytes] Required.

Returns:

CopyAuthorization. The CopyAuthorization is compatible with MutableMapping

Return type:

CopyAuthorization

Raises:

HttpResponseError

begin_build_classifier(build_request: BuildDocumentClassifierRequest | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) LROPoller[DocumentClassifierDetails]

Builds a custom document classifier.

Parameters:

build_request (BuildDocumentClassifierRequest or JSON or IO[bytes]) – Build request parameters. Is one of the following types: BuildDocumentClassifierRequest, JSON, IO[bytes] Required.

Returns:

An instance of LROPoller that returns DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping

Return type:

LROPoller[DocumentClassifierDetails]

Raises:

HttpResponseError

begin_build_document_model(build_request: BuildDocumentModelRequest | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) LROPoller[DocumentModelDetails]

Builds a custom document analysis model.

Parameters:

build_request (BuildDocumentModelRequest or JSON or IO[bytes]) – Build request parameters. Is one of the following types: BuildDocumentModelRequest, JSON, IO[bytes] Required.

Returns:

An instance of LROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping

Return type:

LROPoller[DocumentModelDetails]

Raises:

HttpResponseError

begin_compose_model(compose_request: ComposeDocumentModelRequest | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) LROPoller[DocumentModelDetails]

Creates a new document model from document types of existing document models.

Parameters:

compose_request (ComposeDocumentModelRequest or JSON or IO[bytes]) – Compose request parameters. Is one of the following types: ComposeDocumentModelRequest, JSON, IO[bytes] Required.

Returns:

An instance of LROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping

Return type:

LROPoller[DocumentModelDetails]

Raises:

HttpResponseError

begin_copy_classifier_to(classifier_id: str, copy_to_request: ClassifierCopyAuthorization | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) LROPoller[DocumentClassifierDetails]

Copies document classifier to the target resource, region, and classifierId.

Parameters:
  • classifier_id (str) – Unique document classifier name. Required.

  • copy_to_request (ClassifierCopyAuthorization or JSON or IO[bytes]) – Copy to request parameters. Is one of the following types: ClassifierCopyAuthorization, JSON, IO[bytes] Required.

Returns:

An instance of LROPoller that returns DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping

Return type:

LROPoller[DocumentClassifierDetails]

Raises:

HttpResponseError

begin_copy_model_to(model_id: str, copy_to_request: CopyAuthorization | MutableMapping[str, Any] | IO[bytes], **kwargs: Any) LROPoller[DocumentModelDetails]

Copies document model to the target resource, region, and modelId.

Parameters:
  • model_id (str) – Unique document model name. Required.

  • copy_to_request (CopyAuthorization or JSON or IO[bytes]) – Copy to request parameters. Is one of the following types: CopyAuthorization, JSON, IO[bytes] Required.

Returns:

An instance of LROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping

Return type:

LROPoller[DocumentModelDetails]

Raises:

HttpResponseError

close() None[source]
delete_classifier(classifier_id: str, **kwargs: Any) None

Deletes document classifier.

Parameters:

classifier_id (str) – Unique document classifier name. Required.

Returns:

None

Return type:

None

Raises:

HttpResponseError

delete_model(model_id: str, **kwargs: Any) None

Deletes document model.

Parameters:

model_id (str) – Unique document model name. Required.

Returns:

None

Return type:

None

Raises:

HttpResponseError

get_classifier(classifier_id: str, **kwargs: Any) DocumentClassifierDetails

Gets detailed document classifier information.

Parameters:

classifier_id (str) – Unique document classifier name. Required.

Returns:

DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping

Return type:

DocumentClassifierDetails

Raises:

HttpResponseError

get_model(model_id: str, **kwargs: Any) DocumentModelDetails

Gets detailed document model information.

Parameters:

model_id (str) – Unique document model name. Required.

Returns:

DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping

Return type:

DocumentModelDetails

Raises:

HttpResponseError

get_operation(operation_id: str, **kwargs: Any) OperationDetails

Gets operation info.

Parameters:

operation_id (str) – Operation ID. Required.

Returns:

OperationDetails. The OperationDetails is compatible with MutableMapping

Return type:

OperationDetails

Raises:

HttpResponseError

get_resource_info(**kwargs: Any) ResourceDetails

Return information about the current resource.

Returns:

ResourceDetails. The ResourceDetails is compatible with MutableMapping

Return type:

ResourceDetails

Raises:

HttpResponseError

list_classifiers(**kwargs: Any) Iterable[DocumentClassifierDetails]

List all document classifiers.

Returns:

An iterator like instance of DocumentClassifierDetails

Return type:

ItemPaged[DocumentClassifierDetails]

Raises:

HttpResponseError

list_models(**kwargs: Any) Iterable[DocumentModelDetails]

List all document models.

Returns:

An iterator like instance of DocumentModelDetails

Return type:

ItemPaged[DocumentModelDetails]

Raises:

HttpResponseError

list_operations(**kwargs: Any) Iterable[OperationDetails]

Lists all operations.

Returns:

An iterator like instance of OperationDetails

Return type:

ItemPaged[OperationDetails]

Raises:

HttpResponseError

send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) HttpResponse[source]

Runs the network request through the client’s chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

Parameters:

request (HttpRequest) – The network request you want to make. Required.

Keyword Arguments:

stream (bool) – Whether the response payload will be streamed. Defaults to False.

Returns:

The response of your network call. Does not do error handling on your response.

Return type:

HttpResponse

class azure.ai.documentintelligence.DocumentIntelligenceClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, **kwargs: Any)[source]

DocumentIntelligenceClient.

Parameters:
  • endpoint (str) – The Document Intelligence service endpoint. Required.

  • credential (AzureKeyCredential or TokenCredential) – Credential needed for the client to connect to Azure. Is either a AzureKeyCredential type or a TokenCredential type. Required.

Keyword Arguments:
  • api_version (str) – The API version to use for this operation. Default value is “2024-07-31-preview”. Note that overriding this default value may result in unsupported behavior.

  • polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.

begin_analyze_batch_documents(model_id: str, analyze_batch_request: AnalyzeBatchDocumentsRequest | MutableMapping[str, Any] | IO[bytes] | None = None, *, pages: str | None = None, locale: str | None = None, string_index_type: str | StringIndexType | None = None, features: List[str | DocumentAnalysisFeature] | None = None, query_fields: List[str] | None = None, output_content_format: str | ContentFormat | None = None, output: List[str | AnalyzeOutputOption] | None = None, **kwargs: Any) LROPoller[AnalyzeBatchResult]

Analyzes batch documents with document model.

Parameters:
  • model_id (str) – Unique document model name. Required.

  • analyze_batch_request (AnalyzeBatchDocumentsRequest or JSON or IO[bytes]) – Analyze batch request parameters. Is one of the following types: AnalyzeBatchDocumentsRequest, JSON, IO[bytes] Default value is None.

Keyword Arguments:
  • pages (str) – Range of 1-based page numbers to analyze. Ex. “1-3,5,7-9”. Default value is None.

  • locale (str) – Locale hint for text recognition and document analysis. Value may contain only the language code (ex. “en”, “fr”) or BCP 47 language tag (ex. “en-US”). Default value is None.

  • string_index_type (str or StringIndexType) – Method used to compute string offset and length. Known values are: “textElements”, “unicodeCodePoint”, and “utf16CodeUnit”. Default value is None.

  • features (list[str or DocumentAnalysisFeature]) – List of optional analysis features. Default value is None.

  • query_fields (list[str]) – List of additional fields to extract. Ex. “NumberOfGuests,StoreNumber”. Default value is None.

  • output_content_format (str or ContentFormat) – Format of the analyze result top-level content. Known values are: “text” and “markdown”. Default value is None.

  • output (list[str or AnalyzeOutputOption]) – Additional outputs to generate during analysis. Default value is None.

Returns:

An instance of LROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult is compatible with MutableMapping

Return type:

LROPoller[AnalyzeBatchResult]

Raises:

HttpResponseError

begin_analyze_document(model_id: str, analyze_request: AnalyzeDocumentRequest | MutableMapping[str, Any] | IO[bytes] | None = None, *, pages: str | None = None, locale: str | None = None, string_index_type: str | StringIndexType | None = None, features: List[str | DocumentAnalysisFeature] | None = None, query_fields: List[str] | None = None, output_content_format: str | ContentFormat | None = None, output: List[str | AnalyzeOutputOption] | None = None, **kwargs: Any) AnalyzeDocumentLROPoller[AnalyzeResult]

Analyzes document with document model.

Parameters:
  • model_id (str) – Unique document model name. Required.

  • analyze_request (AnalyzeDocumentRequest or JSON or IO[bytes]) – Analyze request parameters. Is one of the following types: AnalyzeDocumentRequest, JSON, IO[bytes] Default value is None.

Keyword Arguments:
  • pages (str) – Range of 1-based page numbers to analyze. Ex. “1-3,5,7-9”. Default value is None.

  • locale (str) – Locale hint for text recognition and document analysis. Value may contain only the language code (ex. “en”, “fr”) or BCP 47 language tag (ex. “en-US”). Default value is None.

  • string_index_type (str or StringIndexType) – Method used to compute string offset and length. Known values are: “textElements”, “unicodeCodePoint”, and “utf16CodeUnit”. Default value is None.

  • features (list[str or DocumentAnalysisFeature]) – List of optional analysis features. Default value is None.

  • query_fields (list[str]) – List of additional fields to extract. Ex. “NumberOfGuests,StoreNumber”. Default value is None.

  • output_content_format (str or ContentFormat) – Format of the analyze result top-level content. Known values are: “text” and “markdown”. Default value is None.

  • output (list[str or AnalyzeOutputOption]) – Additional outputs to generate during analysis. Default value is None.

Returns:

An instance of AnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is compatible with MutableMapping

Return type:

AnalyzeDocumentLROPoller[AnalyzeResult]

Raises:

HttpResponseError

begin_classify_document(classifier_id: str, classify_request: ClassifyDocumentRequest | MutableMapping[str, Any] | IO[bytes], *, string_index_type: str | StringIndexType | None = None, split: str | SplitMode | None = None, pages: str | None = None, **kwargs: Any) LROPoller[AnalyzeResult]

Classifies document with document classifier.

Parameters:
  • classifier_id (str) – Unique document classifier name. Required.

  • classify_request (ClassifyDocumentRequest or JSON or IO[bytes]) – Classify request parameters. Is one of the following types: ClassifyDocumentRequest, JSON, IO[bytes] Required.

Keyword Arguments:
  • string_index_type (str or StringIndexType) – Method used to compute string offset and length. Known values are: “textElements”, “unicodeCodePoint”, and “utf16CodeUnit”. Default value is None.

  • split (str or SplitMode) – Document splitting mode. Known values are: “auto”, “none”, and “perPage”. Default value is None.

  • pages (str) – Range of 1-based page numbers to analyze. Ex. “1-3,5,7-9”. Default value is None.

Returns:

An instance of LROPoller that returns AnalyzeResult. The AnalyzeResult is compatible with MutableMapping

Return type:

LROPoller[AnalyzeResult]

Raises:

HttpResponseError

close() None[source]
get_analyze_result_figure(model_id: str, result_id: str, figure_id: str, **kwargs: Any) Iterator[bytes]

Gets the generated cropped image of specified figure from document analysis.

Parameters:
  • model_id (str) – Unique document model name. Required.

  • result_id (str) – Analyze operation result ID. Required.

  • figure_id (str) – Figure ID. Required.

Returns:

Iterator[bytes]

Return type:

Iterator[bytes]

Raises:

HttpResponseError

get_analyze_result_pdf(model_id: str, result_id: str, **kwargs: Any) Iterator[bytes]

Gets the generated searchable PDF output from document analysis.

Parameters:
  • model_id (str) – Unique document model name. Required.

  • result_id (str) – Analyze operation result ID. Required.

Returns:

Iterator[bytes]

Return type:

Iterator[bytes]

Raises:

HttpResponseError

send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) HttpResponse[source]

Runs the network request through the client’s chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

Parameters:

request (HttpRequest) – The network request you want to make. Required.

Keyword Arguments:

stream (bool) – Whether the response payload will be streamed. Defaults to False.

Returns:

The response of your network call. Does not do error handling on your response.

Return type:

HttpResponse

Subpackages