DocumentModelAdministrationClient Class

DocumentModelAdministrationClient is the Form Recognizer interface to use for building and managing models.

It provides methods for building models and classifiers, as well as methods for viewing and deleting models and classifiers, viewing model and classifier operations, accessing account information, copying models to another Form Recognizer resource, and composing a new model from a collection of existing models.

Note

DocumentModelAdministrationClient should be used with API versions

2022-08-31 and up. To use API versions <=v2.1, instantiate a FormTrainingClient.

New in version 2022-08-31: The DocumentModelAdministrationClient and its client methods.

Inheritance
azure.ai.formrecognizer.aio._form_base_client_async.FormRecognizerClientBaseAsync
DocumentModelAdministrationClient

Constructor

DocumentModelAdministrationClient(endpoint: str, credential: AzureKeyCredential | AsyncTokenCredential, **kwargs: Any)

Parameters

Name Description
endpoint
Required
str

Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).

credential
Required

Credentials needed for the client to connect to Azure. This is an instance of AzureKeyCredential if using an API key or a token credential from identity.

Keyword-Only Parameters

Name Description
api_version

The API version of the service to use for requests. It defaults to the latest service version. Setting to an older version may result in reduced feature compatibility. To use API versions <=v2.1, instantiate a FormTrainingClient.

Examples

Creating the DocumentModelAdministrationClient with an endpoint and API key.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint, AzureKeyCredential(key)
   )

Creating the DocumentModelAdministrationClient with a token credential.


   """DefaultAzureCredential will use the values from these environment
   variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
   """
   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient
   from azure.identity.aio import DefaultAzureCredential

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   credential = DefaultAzureCredential()

   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint, credential
   )

Methods

begin_build_document_classifier

Build a document classifier. For more information on how to build and train a custom classifier model, see https://aka.ms/azsdk/formrecognizer/buildclassifiermodel.

New in version 2023-07-31: The begin_build_document_classifier client method.

begin_build_document_model

Build a custom document model.

The request must include a blob_container_url keyword parameter that is an externally accessible Azure storage blob container URI (preferably a Shared Access Signature URI). Note that a container URI (without SAS) is accepted only when the container is public or has a managed identity configured, see more about configuring managed identities to work with Form Recognizer here: https://docs.microsoft.com/azure/applied-ai-services/form-recognizer/managed-identities. Models are built using documents that are of the following content type - 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'image/bmp', or 'image/heif'. Other types of content in the container is ignored.

New in version 2023-07-31: The file_list keyword argument.

begin_compose_document_model

Creates a composed document model from a collection of existing models.

A composed model allows multiple models to be called with a single model ID. When a document is submitted to be analyzed with a composed model ID, a classification step is first performed to route it to the correct custom model.

begin_copy_document_model_to

Copy a document model stored in this resource (the source) to the user specified target Form Recognizer resource.

This should be called with the source Form Recognizer resource (with the model that is intended to be copied). The target parameter should be supplied from the target resource's output from calling the get_copy_authorization method.

close

Close the DocumentModelAdministrationClient session.

delete_document_classifier

Delete a document classifier.

New in version 2023-07-31: The delete_document_classifier client method.

delete_document_model

Delete a custom document model.

get_copy_authorization

Generate authorization for copying a custom model into the target Form Recognizer resource.

This should be called by the target resource (where the model will be copied to) and the output can be passed as the target parameter into begin_copy_document_model_to.

get_document_analysis_client

Get an instance of a DocumentAnalysisClient from DocumentModelAdministrationClient.

get_document_classifier

Get a document classifier by its ID.

New in version 2023-07-31: The get_document_classifier client method.

get_document_model

Get a document model by its ID.

get_operation

Get an operation by its ID.

Get an operation associated with the Form Recognizer resource. Note that operation information only persists for 24 hours. If the document model operation was successful, the model can be accessed using the get_document_model or list_document_models APIs.

get_resource_details

Get information about the models under the Form Recognizer resource.

list_document_classifiers

List information for each document classifier, including its classifier ID, description, and when it was created.

New in version 2023-07-31: The list_document_classifiers client method.

list_document_models

List information for each model, including its model ID, description, and when it was created.

list_operations

List information for each operation.

Lists all operations associated with the Form Recognizer resource. Note that operation information only persists for 24 hours. If the document model operation was successful, the document model can be accessed using the get_document_model or list_document_models APIs.

send_request

Runs a network request using the client's existing pipeline.

The request URL can be relative to the base URL. The service API version used for the request is the same as the client's unless otherwise specified. Overriding the client's configured API version in relative URL is supported on client with API version 2022-08-31 and later. Overriding in absolute URL supported on client with any API version. This method does not raise if the response is an error; to raise an exception, call raise_for_status() on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request.

begin_build_document_classifier

Build a document classifier. For more information on how to build and train a custom classifier model, see https://aka.ms/azsdk/formrecognizer/buildclassifiermodel.

New in version 2023-07-31: The begin_build_document_classifier client method.

async begin_build_document_classifier(doc_types: Mapping[str, ClassifierDocumentTypeDetails], *, classifier_id: str | None = None, description: str | None = None, **kwargs: Any) -> AsyncDocumentModelAdministrationLROPoller[DocumentClassifierDetails]

Parameters

Name Description
doc_types
Required

Mapping of document types to classify against.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

An instance of an AsyncDocumentModelAdministrationLROPoller. Call result() on the poller object to return a DocumentClassifierDetails.

Exceptions

Type Description

Examples

Build a document classifier.


   import os
   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient
   from azure.ai.formrecognizer import (
       ClassifierDocumentTypeDetails,
       BlobSource,
       BlobFileListSource,
   )
   from azure.core.credentials import AzureKeyCredential

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]
   container_sas_url = os.environ["CLASSIFIER_CONTAINER_SAS_URL"]

   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )

   async with document_model_admin_client:
       poller = await document_model_admin_client.begin_build_document_classifier(
           doc_types={
               "IRS-1040-A": ClassifierDocumentTypeDetails(
                   source=BlobSource(
                       container_url=container_sas_url, prefix="IRS-1040-A/train"
                   )
               ),
               "IRS-1040-D": ClassifierDocumentTypeDetails(
                   source=BlobFileListSource(
                       container_url=container_sas_url, file_list="IRS-1040-D.jsonl"
                   )
               ),
           },
           description="IRS document classifier",
       )
       result = await poller.result()
       print(f"Classifier ID: {result.classifier_id}")
       print(f"API version used to build the classifier model: {result.api_version}")
       print(f"Classifier description: {result.description}")
       print(f"Document classes used for training the model:")
       for doc_type, details in result.doc_types.items():
           print(f"Document type: {doc_type}")
           print(f"Container source: {details.source.container_url}\n")

begin_build_document_model

Build a custom document model.

The request must include a blob_container_url keyword parameter that is an externally accessible Azure storage blob container URI (preferably a Shared Access Signature URI). Note that a container URI (without SAS) is accepted only when the container is public or has a managed identity configured, see more about configuring managed identities to work with Form Recognizer here: https://docs.microsoft.com/azure/applied-ai-services/form-recognizer/managed-identities. Models are built using documents that are of the following content type - 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'image/bmp', or 'image/heif'. Other types of content in the container is ignored.

New in version 2023-07-31: The file_list keyword argument.

async begin_build_document_model(build_mode: str | ModelBuildMode, *, blob_container_url: str, prefix: str | None = None, model_id: str | None = None, description: str | None = None, tags: Mapping[str, str] | None = None, **kwargs: Any) -> AsyncDocumentModelAdministrationLROPoller[DocumentModelDetails]

Parameters

Name Description
build_mode
Required

The custom model build mode. Possible values include: "template", "neural". For more information about build modes, see: https://aka.ms/azsdk/formrecognizer/buildmode.

Keyword-Only Parameters

Name Description
blob_container_url
str

An Azure Storage blob container's SAS URI. A container URI (without SAS) can be used if the container is public or has a managed identity configured. For more information on setting up a training data set, see: https://aka.ms/azsdk/formrecognizer/buildtrainingset.

model_id
str

A unique ID for your model. If not specified, a model ID will be created for you.

description
str

An optional description to add to the model.

prefix
str

A case-sensitive prefix string to filter documents in the blob container url path. For example, when using an Azure storage blob URI, use the prefix to restrict sub folders. prefix should end in '/' to avoid cases where filenames share the same prefix.

file_list
str

Path to a JSONL file within the container specifying a subset of documents for training.

tags

List of user defined key-value tag attributes associated with the model.

Returns

Type Description

An instance of an AsyncDocumentModelAdministrationLROPoller. Call result() on the poller object to return a DocumentModelDetails.

Exceptions

Type Description

Examples

Building a model from training files.


   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient
   from azure.ai.formrecognizer import ModelBuildMode
   from azure.core.credentials import AzureKeyCredential

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]
   container_sas_url = os.environ["CONTAINER_SAS_URL"]

   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint, AzureKeyCredential(key)
   )
   async with document_model_admin_client:
       poller = await document_model_admin_client.begin_build_document_model(
           ModelBuildMode.TEMPLATE,
           blob_container_url=container_sas_url,
           description="my model description",
       )
       model = await poller.result()

   print(f"Model ID: {model.model_id}")
   print(f"Description: {model.description}")
   print(f"Model created on: {model.created_on}")
   print(f"Model expires on: {model.expires_on}")
   print("Doc types the model can recognize:")
   for name, doc_type in model.doc_types.items():
       print(
           f"Doc Type: '{name}' built with '{doc_type.build_mode}' mode which has the following fields:"
       )
       for field_name, field in doc_type.field_schema.items():
           print(
               f"Field: '{field_name}' has type '{field['type']}' and confidence score "
               f"{doc_type.field_confidence[field_name]}"
           )

begin_compose_document_model

Creates a composed document model from a collection of existing models.

A composed model allows multiple models to be called with a single model ID. When a document is submitted to be analyzed with a composed model ID, a classification step is first performed to route it to the correct custom model.

async begin_compose_document_model(component_model_ids: List[str], **kwargs: Any) -> AsyncDocumentModelAdministrationLROPoller[DocumentModelDetails]

Parameters

Name Description
component_model_ids
Required

List of model IDs to use in the composed model.

Keyword-Only Parameters

Name Description
model_id
str

A unique ID for your composed model. If not specified, a model ID will be created for you.

description
str

An optional description to add to the model.

tags

List of user defined key-value tag attributes associated with the model.

Returns

Type Description

An instance of an AsyncDocumentModelAdministrationLROPoller. Call result() on the poller object to return a DocumentModelDetails.

Exceptions

Type Description

Examples

Creating a composed model with existing models.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient
   from azure.ai.formrecognizer import ModelBuildMode

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]
   po_supplies = os.environ["PURCHASE_ORDER_OFFICE_SUPPLIES_SAS_URL"]
   po_equipment = os.environ["PURCHASE_ORDER_OFFICE_EQUIPMENT_SAS_URL"]
   po_furniture = os.environ["PURCHASE_ORDER_OFFICE_FURNITURE_SAS_URL"]
   po_cleaning_supplies = os.environ["PURCHASE_ORDER_OFFICE_CLEANING_SUPPLIES_SAS_URL"]

   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )
   async with document_model_admin_client:
       supplies_poller = await document_model_admin_client.begin_build_document_model(
           ModelBuildMode.TEMPLATE,
           blob_container_url=po_supplies,
           description="Purchase order-Office supplies",
       )
       equipment_poller = await document_model_admin_client.begin_build_document_model(
           ModelBuildMode.TEMPLATE,
           blob_container_url=po_equipment,
           description="Purchase order-Office Equipment",
       )
       furniture_poller = await document_model_admin_client.begin_build_document_model(
           ModelBuildMode.TEMPLATE,
           blob_container_url=po_furniture,
           description="Purchase order-Furniture",
       )
       cleaning_supplies_poller = (
           await document_model_admin_client.begin_build_document_model(
               ModelBuildMode.TEMPLATE,
               blob_container_url=po_cleaning_supplies,
               description="Purchase order-Cleaning Supplies",
           )
       )
       supplies_model = await supplies_poller.result()
       equipment_model = await equipment_poller.result()
       furniture_model = await furniture_poller.result()
       cleaning_supplies_model = await cleaning_supplies_poller.result()

       purchase_order_models = [
           supplies_model.model_id,
           equipment_model.model_id,
           furniture_model.model_id,
           cleaning_supplies_model.model_id,
       ]

       poller = await document_model_admin_client.begin_compose_document_model(
           purchase_order_models, description="Office Supplies Composed Model"
       )
       model = await poller.result()

   print("Office Supplies Composed Model Info:")
   print(f"Model ID: {model.model_id}")
   print(f"Description: {model.description}")
   print(f"Model created on: {model.created_on}")
   print(f"Model expires on: {model.expires_on}")
   print("Doc types the model can recognize:")
   for name, doc_type in model.doc_types.items():
       print(f"Doc Type: '{name}' which has the following fields:")
       for field_name, field in doc_type.field_schema.items():
           print(
               f"Field: '{field_name}' has type '{field['type']}' and confidence score "
               f"{doc_type.field_confidence[field_name]}"
           )

begin_copy_document_model_to

Copy a document model stored in this resource (the source) to the user specified target Form Recognizer resource.

This should be called with the source Form Recognizer resource (with the model that is intended to be copied). The target parameter should be supplied from the target resource's output from calling the get_copy_authorization method.

async begin_copy_document_model_to(model_id: str, target: TargetAuthorization, **kwargs: Any) -> AsyncDocumentModelAdministrationLROPoller[DocumentModelDetails]

Parameters

Name Description
model_id
Required
str

Model identifier of the model to copy to target resource.

target
Required
<xref:azure.ai.formrecognizer.TargetAuthorization>

The copy authorization generated from the target resource's call to get_copy_authorization.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

An instance of a AsyncDocumentModelAdministrationLROPoller. Call result() on the poller object to return a DocumentModelDetails.

Exceptions

Type Description

Examples

Copy a model from the source resource to the target resource


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient

   source_endpoint = os.environ["AZURE_FORM_RECOGNIZER_SOURCE_ENDPOINT"]
   source_key = os.environ["AZURE_FORM_RECOGNIZER_SOURCE_KEY"]
   target_endpoint = os.environ["AZURE_FORM_RECOGNIZER_TARGET_ENDPOINT"]
   target_key = os.environ["AZURE_FORM_RECOGNIZER_TARGET_KEY"]
   source_model_id = os.getenv("AZURE_SOURCE_MODEL_ID", custom_model_id)

   target_client = DocumentModelAdministrationClient(
       endpoint=target_endpoint, credential=AzureKeyCredential(target_key)
   )
   async with target_client:
       target = await target_client.get_copy_authorization(
           description="model copied from other resource"
       )

   source_client = DocumentModelAdministrationClient(
       endpoint=source_endpoint, credential=AzureKeyCredential(source_key)
   )
   async with source_client:
       poller = await source_client.begin_copy_document_model_to(
           model_id=source_model_id,
           target=target,  # output from target client's call to get_copy_authorization()
       )
       copied_over_model = await poller.result()

   print(f"Model ID: {copied_over_model.model_id}")
   print(f"Description: {copied_over_model.description}")
   print(f"Model created on: {copied_over_model.created_on}")
   print(f"Model expires on: {copied_over_model.expires_on}")
   print("Doc types the model can recognize:")
   for name, doc_type in copied_over_model.doc_types.items():
       print(f"Doc Type: '{name}' which has the following fields:")
       for field_name, field in doc_type.field_schema.items():
           print(
               f"Field: '{field_name}' has type '{field['type']}' and confidence score "
               f"{doc_type.field_confidence[field_name]}"
           )

close

Close the DocumentModelAdministrationClient session.

async close() -> None

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Exceptions

Type Description

delete_document_classifier

Delete a document classifier.

New in version 2023-07-31: The delete_document_classifier client method.

async delete_document_classifier(classifier_id: str, **kwargs: Any) -> None

Parameters

Name Description
classifier_id
Required
str

Classifier identifier.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

None

Exceptions

Type Description

Examples

Delete a classifier.


   await document_model_admin_client.delete_document_classifier(
       classifier_id=my_classifier.classifier_id
   )

   try:
       await document_model_admin_client.get_document_classifier(
           classifier_id=my_classifier.classifier_id
       )
   except ResourceNotFoundError:
       print(
           f"Successfully deleted classifier with ID {my_classifier.classifier_id}"
       )

delete_document_model

Delete a custom document model.

async delete_document_model(model_id: str, **kwargs: Any) -> None

Parameters

Name Description
model_id
Required
str

Model identifier.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

None

Exceptions

Type Description

Examples

Delete a model.


   await document_model_admin_client.delete_document_model(
       model_id=my_model.model_id
   )

   try:
       await document_model_admin_client.get_document_model(
           model_id=my_model.model_id
       )
   except ResourceNotFoundError:
       print(f"Successfully deleted model with ID {my_model.model_id}")

get_copy_authorization

Generate authorization for copying a custom model into the target Form Recognizer resource.

This should be called by the target resource (where the model will be copied to) and the output can be passed as the target parameter into begin_copy_document_model_to.

async get_copy_authorization(**kwargs: Any) -> TargetAuthorization

Keyword-Only Parameters

Name Description
model_id
str

A unique ID for your copied model. If not specified, a model ID will be created for you.

description
str

An optional description to add to the model.

tags

List of user defined key-value tag attributes associated with the model.

Returns

Type Description
<xref:azure.ai.formrecognizer.TargetAuthorization>

A dictionary with values necessary for the copy authorization.

Exceptions

Type Description

get_document_analysis_client

Get an instance of a DocumentAnalysisClient from DocumentModelAdministrationClient.

get_document_analysis_client(**kwargs: Any) -> DocumentAnalysisClient

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

A DocumentAnalysisClient

Exceptions

Type Description

get_document_classifier

Get a document classifier by its ID.

New in version 2023-07-31: The get_document_classifier client method.

async get_document_classifier(classifier_id: str, **kwargs: Any) -> DocumentClassifierDetails

Parameters

Name Description
classifier_id
Required
str

Classifier identifier.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

DocumentClassifierDetails

Exceptions

Type Description

Examples

Get a classifier by its ID.


   my_classifier = await document_model_admin_client.get_document_classifier(
       classifier_id=classifier_model.classifier_id
   )
   print(f"\nClassifier ID: {my_classifier.classifier_id}")
   print(f"Description: {my_classifier.description}")
   print(f"Classifier created on: {my_classifier.created_on}")

get_document_model

Get a document model by its ID.

async get_document_model(model_id: str, **kwargs: Any) -> DocumentModelDetails

Parameters

Name Description
model_id
Required
str

Model identifier.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

DocumentModelDetails

Exceptions

Type Description

Examples

Get a model by its ID.


   my_model = await document_model_admin_client.get_document_model(
       model_id=model.model_id
   )
   print(f"\nModel ID: {my_model.model_id}")
   print(f"Description: {my_model.description}")
   print(f"Model created on: {my_model.created_on}")
   print(f"Model expires on: {my_model.expires_on}")

get_operation

Get an operation by its ID.

Get an operation associated with the Form Recognizer resource. Note that operation information only persists for 24 hours. If the document model operation was successful, the model can be accessed using the get_document_model or list_document_models APIs.

async get_operation(operation_id: str, **kwargs: Any) -> OperationDetails

Parameters

Name Description
operation_id
Required
str

The operation ID.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

OperationDetails

Exceptions

Type Description

Examples

Get a document model operation by its ID.


   # Get an operation by ID
   try:
       first_operation = await operations.__anext__()

       print(f"\nGetting operation info by ID: {first_operation.operation_id}")
       operation_info = await document_model_admin_client.get_operation(
           first_operation.operation_id
       )
       if operation_info.status == "succeeded":
           print(f"My {operation_info.kind} operation is completed.")
           result = operation_info.result
           if result is not None:
               if operation_info.kind == "documentClassifierBuild":
                   print(f"Classifier ID: {result.classifier_id}")
               else:
                   print(f"Model ID: {result.model_id}")
       elif operation_info.status == "failed":
           print(f"My {operation_info.kind} operation failed.")
           error = operation_info.error
           if error is not None:
               print(f"{error.code}: {error.message}")
       else:
           print(f"My operation status is {operation_info.status}")
   except StopAsyncIteration:
       print("No operations found.")

get_resource_details

Get information about the models under the Form Recognizer resource.

async get_resource_details(**kwargs: Any) -> ResourceDetails

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

Summary of custom models under the resource - model count and limit.

Exceptions

Type Description

Examples

Get model counts and limits under the Form Recognizer resource.


   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )

   async with document_model_admin_client:
       account_details = await document_model_admin_client.get_resource_details()
       print(
           f"Our resource has {account_details.custom_document_models.count} custom models, "
           f"and we can have at most {account_details.custom_document_models.limit} custom models"
       )
       neural_models = account_details.neural_document_model_quota
       print(
           f"The quota limit for custom neural document models is {neural_models.quota} and the resource has"
           f"used {neural_models.used}. The resource quota will reset on {neural_models.quota_resets_on}"
       )

list_document_classifiers

List information for each document classifier, including its classifier ID, description, and when it was created.

New in version 2023-07-31: The list_document_classifiers client method.

list_document_classifiers(**kwargs: Any) -> AsyncItemPaged[DocumentClassifierDetails]

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

Pageable of DocumentClassifierDetails.

Exceptions

Type Description

Examples

List all classifiers that were built successfully under the Form Recognizer resource.


   classifiers = document_model_admin_client.list_document_classifiers()

   print("We have the following 'ready' models with IDs and descriptions:")
   async for classifier in classifiers:
       print(f"{classifier.classifier_id} | {classifier.description}")

list_document_models

List information for each model, including its model ID, description, and when it was created.

list_document_models(**kwargs: Any) -> AsyncItemPaged[DocumentModelSummary]

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

Pageable of DocumentModelSummary.

Exceptions

Type Description

Examples

List all models that were built successfully under the Form Recognizer resource.


   models = document_model_admin_client.list_document_models()

   print("We have the following 'ready' models with IDs and descriptions:")
   async for model in models:
       print(f"{model.model_id} | {model.description}")

list_operations

List information for each operation.

Lists all operations associated with the Form Recognizer resource. Note that operation information only persists for 24 hours. If the document model operation was successful, the document model can be accessed using the get_document_model or list_document_models APIs.

list_operations(**kwargs: Any) -> AsyncItemPaged[OperationSummary]

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

A pageable of OperationSummary.

Exceptions

Type Description

Examples

List all document model operations in the past 24 hours.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   document_model_admin_client = DocumentModelAdministrationClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )

   async with document_model_admin_client:
       operations = document_model_admin_client.list_operations()

       print("The following document model operations exist under my resource:")
       async for operation in operations:
           print(f"\nOperation ID: {operation.operation_id}")
           print(f"Operation kind: {operation.kind}")
           print(f"Operation status: {operation.status}")
           print(f"Operation percent completed: {operation.percent_completed}")
           print(f"Operation created on: {operation.created_on}")
           print(f"Operation last updated on: {operation.last_updated_on}")
           print(
               f"Resource location of successful operation: {operation.resource_location}"
           )

send_request

Runs a network request using the client's existing pipeline.

The request URL can be relative to the base URL. The service API version used for the request is the same as the client's unless otherwise specified. Overriding the client's configured API version in relative URL is supported on client with API version 2022-08-31 and later. Overriding in absolute URL supported on client with any API version. This method does not raise if the response is an error; to raise an exception, call raise_for_status() on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request.

async send_request(request: HttpRequest, *, stream: bool = False, **kwargs) -> AsyncHttpResponse

Parameters

Name Description
request
Required

The network request you want to make.

Keyword-Only Parameters

Name Description
classifier_id
str

Unique document classifier name. If not specified, a classifier ID will be created for you.

description
str

Document classifier description.

Returns

Type Description

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

Exceptions

Type Description