title | titleSuffix | description | author | manager | ms.service | ms.custom | ms.topic | ms.date | ms.author | monikerRange | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Document Intelligence (formerly Form Recognizer) SDK target REST API 2022–08–31 (GA) |
Azure AI services |
Document Intelligence 2022–08–31 (GA) software development kits (SDKs) expose Document Intelligence models, features and capabilities, using C#, Java, JavaScript, and Python programming language. |
laujan |
nitinme |
azure-ai-document-intelligence |
|
conceptual |
05/23/2024 |
lajanuar |
doc-intel-3.0.0 |
REST API version 2022–08–31 (GA)
Azure AI Document Intelligence is a cloud service that uses machine learning to analyze text and structured data from documents. The Document Intelligence software development kit (SDK) is a set of libraries and tools that enable you to easily integrate Document Intelligence models and capabilities into your applications. Document Intelligence SDK is available across platforms in C#/.NET, Java, JavaScript, and Python programming languages.
Document Intelligence SDK supports the following languages and platforms:
Language → Document Intelligence SDK version | Package | Supported API version | Platform support |
---|---|---|---|
.NET/C# → 4.0.0 (GA) | NuGet | v3.0 | Windows, macOS, Linux, Docker |
Java → 4.0.6 (GA) | Maven repository | v3.0 | Windows, macOS, Linux |
JavaScript → 4.0.0 (GA) | npm | v3.0 | Browser, Windows, macOS, Linux |
Python → 3.2.0 (GA) | PyPI | v3.0 | Windows, macOS, Linux |
For more information on other SDK versions, see:
Language | SDK version | API version | Supported clients |
---|---|---|---|
.NET/C# Java JavaScript |
4.0.0 (GA) | v3.0:2022-08-31 (default) | DocumentAnalysisClient DocumentModelAdministrationClient |
.NET/C# Java JavaScript |
3.1.x | v2.1 (default) v2.0 |
FormRecognizerClient FormTrainingClient |
.NET/C# Java JavaScript |
3.0.x | v2.0 | FormRecognizerClient FormTrainingClient |
Python | 3.2.x (GA) | v3.0:2022-08-31 (default) | DocumentAnalysisClient DocumentModelAdministrationClient |
Python | 3.1.x | v2.1 (default) v2.0 |
FormRecognizerClient FormTrainingClient |
Python | 3.0.0 | v2.0 | FormRecognizerClient FormTrainingClient |
The Document Intelligence SDK enables the use and management of the Document Intelligence service in your application. The SDK builds on the underlying Document Intelligence REST API allowing you to easily use those APIs within your programming language paradigm. Here's how you use the Document Intelligence SDK for your preferred language:
dotnet add package Azure.AI.FormRecognizer --version 4.0.0
Install-Package Azure.AI.FormRecognizer -Version 4.0.0
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-formrecognizer</artifactId>
<version>4.0.6</version>
</dependency>
implementation("com.azure:azure-ai-formrecognizer:4.0.6")
npm i @azure/ai-form-recognizer@4.0.0
pip install azure-ai-formrecognizer==3.2.0
using Azure;
using Azure.AI.FormRecognizer.DocumentAnalysis;
import com.azure.ai.formrecognizer.*;
import com.azure.ai.formrecognizer.models.*;
import com.azure.ai.formrecognizer.DocumentAnalysisClient.*;
import com.azure.core.credential.AzureKeyCredential;
const { AzureKeyCredential, DocumentAnalysisClient } = require("@azure/ai-form-recognizer");
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.core.credentials import AzureKeyCredential
There are two supported methods for authentication:
-
Use a Document Intelligence API key with AzureKeyCredential from azure.core.credentials.
-
Use a token credential from azure-identity to authenticate with Microsoft Entra ID.
Here's where to find your Document Intelligence API key in the Azure portal:
:::image type="content" source="media/containers/keys-and-endpoint.png" alt-text="Screenshot of the keys and endpoint location in the Azure portal.":::
//set `<your-endpoint>` and `<your-key>` variables with the values from the Azure portal to create your `AzureKeyCredential` and `DocumentAnalysisClient` instance
string key = "<your-key>";
string endpoint = "<your-endpoint>";
AzureKeyCredential credential = new AzureKeyCredential(key);
DocumentAnalysisClient client = new DocumentAnalysisClient(new Uri(endpoint), credential);
// create your `DocumentAnalysisClient` instance and `AzureKeyCredential` variable
DocumentAnalysisClient client = new DocumentAnalysisClientBuilder()
.credential(new AzureKeyCredential("<your-key>"))
.endpoint("<your-endpoint>")
.buildClient();
// create your `DocumentAnalysisClient` instance and `AzureKeyCredential` variable
async function main() {
const client = new DocumentAnalysisClient("<your-endpoint>", new AzureKeyCredential("<your-key>"));
# create your `DocumentAnalysisClient` instance and `AzureKeyCredential` variable
document_analysis_client = DocumentAnalysisClient(endpoint="<your-endpoint>", credential=AzureKeyCredential("<your-key>"))
Note
Regional endpoints do not support Microsoft Entra authentication. Create a custom subdomain for your resource in order to use this type of authentication.
Authorization is easiest using the DefaultAzureCredential
. It provides a default token credential, based upon the running environment, capable of handling most Azure authentication scenarios.
Here's how to acquire and use the DefaultAzureCredential for .NET applications:
-
Install the Azure Identity library for .NET:
dotnet add package Azure.Identity
Install-Package Azure.Identity
-
Register a Microsoft Entra application and create a new service principal.
-
Grant access to Document Intelligence by assigning the
Cognitive Services User
role to your service principal. -
Set the values of the client ID, tenant ID, and client secret in the Microsoft Entra application as environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
, respectively. -
Create your
DocumentAnalysisClient
instance including theDefaultAzureCredential
:string endpoint = "<your-endpoint>"; var client = new DocumentAnalysisClient(new Uri(endpoint), new DefaultAzureCredential());
For more information, see Authenticate the client.
Here's how to acquire and use the DefaultAzureCredential for Java applications:
-
Install the Azure Identity library for Java:
<dependency> <groupId>com.azure</groupId> <artifactId>azure-identity</artifactId> <version>1.5.3</version> </dependency>
-
Register a Microsoft Entra application and create a new service principal.
-
Grant access to Document Intelligence by assigning the
Cognitive Services User
role to your service principal. -
Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra application as environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
, respectively. -
Create your
DocumentAnalysisClient
instance andTokenCredential
variable:TokenCredential credential = new DefaultAzureCredentialBuilder().build(); DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder() .endpoint("{your-endpoint}") .credential(credential) .buildClient();
For more information, see Authenticate the client.
Here's how to acquire and use the DefaultAzureCredential for JavaScript applications:
-
Install the Azure Identity library for JavaScript:
npm install @azure/identity
-
Register a Microsoft Entra application and create a new service principal.
-
Grant access to Document Intelligence by assigning the
Cognitive Services User
role to your service principal. -
Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra application as environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
, respectively. -
Create your
DocumentAnalysisClient
instance including theDefaultAzureCredential
:const { DocumentAnalysisClient } = require("@azure/ai-form-recognizer"); const { DefaultAzureCredential } = require("@azure/identity"); const client = new DocumentAnalysisClient("<your-endpoint>", new DefaultAzureCredential());
For more information, see Create and authenticate a client.
Here's how to acquire and use the DefaultAzureCredential for Python applications.
-
Install the Azure Identity library for Python:
pip install azure-identity
-
Register a Microsoft Entra application and create a new service principal.
-
Grant access to Document Intelligence by assigning the
Cognitive Services User
role to your service principal. -
Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra application as environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
, respectively. -
Create your
DocumentAnalysisClient
instance including theDefaultAzureCredential
:from azure.identity import DefaultAzureCredential from azure.ai.formrecognizer import DocumentAnalysisClient credential = DefaultAzureCredential() document_analysis_client = DocumentAnalysisClient( endpoint="https://<my-custom-subdomain>.cognitiveservices.azure.com/", credential=credential )
For more information, see Authenticate the client.
Create a client object to interact with the Document Intelligence SDK, and then call methods on that client object to interact with the service. The SDKs provide both synchronous and asynchronous methods. For more insight, try a quickstart in a language of your choice.
The Microsoft Q & A and Stack Overflow forums are available for the developer community to ask and answer questions about Azure AI Document Intelligence and other services. Microsoft monitors the forums and replies to questions that the community has yet to answer. To make sure that we see your question, tag it with azure-form-recognizer
.
[!div class="nextstepaction"] Explore Document Intelligence REST API v3.0
[!div class="nextstepaction"] Try a Document Intelligence quickstart