{"id":1804,"library":"azure-ai-documentintelligence","title":"Azure AI Document Intelligence","description":"Microsoft Azure AI Document Intelligence Client Library for Python. This library provides access to Azure AI Document Intelligence (formerly Form Recognizer) services for processing documents and extracting data. It follows the Azure SDK guidelines for Python, offering features like layout analysis, prebuilt models for common document types, custom model building, and document classification.","status":"active","version":"1.0.2","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/documentintelligence/azure-ai-documentintelligence","tags":["azure","ai","document intelligence","form recognizer","ocr","document processing","microsoft"],"install":[{"cmd":"pip install azure-ai-documentintelligence","lang":"bash","label":"Install stable version"},{"cmd":"pip install azure-ai-documentintelligence[aiohttp]","lang":"bash","label":"Install with async support"}],"dependencies":[{"reason":"Core functionalities for Azure SDK clients.","package":"azure-core","optional":false},{"reason":"Common utilities for Azure SDKs.","package":"azure-common","optional":false},{"reason":"Required for asynchronous client operations.","package":"aiohttp","optional":true}],"imports":[{"note":"The package and client names were rebranded from 'Form Recognizer' to 'Document Intelligence'.","wrong":"from azure.ai.formrecognizer import FormRecognizerClient","symbol":"DocumentIntelligenceClient","correct":"from azure.ai.documentintelligence import DocumentIntelligenceClient"},{"note":"The package and client names were rebranded from 'Form Recognizer' to 'Document Intelligence'.","wrong":"from azure.ai.formrecognizer import DocumentModelAdministrationClient","symbol":"DocumentIntelligenceAdministrationClient","correct":"from azure.ai.documentintelligence import DocumentIntelligenceAdministrationClient"},{"symbol":"AzureKeyCredential","correct":"from azure.core.credentials import AzureKeyCredential"}],"quickstart":{"code":"import os\nfrom azure.ai.documentintelligence import DocumentIntelligenceClient\nfrom azure.core.credentials import AzureKeyCredential\n\n# Set your Document Intelligence endpoint and key as environment variables\n# e.g., AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT and AZURE_DOCUMENT_INTELLIGENCE_KEY\nendpoint = os.environ.get(\"AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT\", \"<your-endpoint>\")\nkey = os.environ.get(\"AZURE_DOCUMENT_INTELLIGENCE_KEY\", \"<your-key>\")\n\nif endpoint == \"<your-endpoint>\" or key == \"<your-key>\":\n    print(\"Please set the AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT and AZURE_DOCUMENT_INTELLIGENCE_KEY environment variables.\")\n    print(\"You can find these in your Azure portal under your Document Intelligence resource's 'Keys and Endpoint' section.\")\nelse:\n    document_url = \"https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_forms/forms/Invoice_1.pdf\"\n\n    document_intelligence_client = DocumentIntelligenceClient(\n        endpoint=endpoint, credential=AzureKeyCredential(key)\n    )\n\n    print(f\"Analyzing document from URL: {document_url}\")\n    # Use 'prebuilt-invoice' for invoices, 'prebuilt-receipt' for receipts, etc.\n    # Or use your custom model_id for custom models\n    poller = document_intelligence_client.begin_analyze_document_from_url(\n        \"prebuilt-invoice\", document_url\n    )\n    result = poller.result()\n\n    if result.documents:\n        for idx, document in enumerate(result.documents):\n            print(f\"\\n--- Document {idx + 1} Analysis ---\")\n            if document.doc_type:\n                print(f\"  Document type: {document.doc_type}\")\n            if document.fields:\n                print(\"  Extracted Fields:\")\n                for name, field in document.fields.items():\n                    if field.content:\n                        print(f\"    {name}: {field.content} (Confidence: {field.confidence:.2f})\")\n    else:\n        print(\"No documents found in the analysis result.\")","lang":"python","description":"Demonstrates how to initialize a `DocumentIntelligenceClient` with an endpoint and API key, and then use it to analyze a document from a URL using a prebuilt model. It iterates through the extracted fields and prints their content and confidence."},"warnings":[{"fix":"Update your `pip install` command, change import statements, and update client instantiation to use the new names (e.g., `DocumentIntelligenceClient`). Refer to the official migration guide.","message":"The package and client library were rebranded from `azure-ai-formrecognizer` to `azure-ai-documentintelligence`. This requires updating package imports and client class names (e.g., `FormRecognizerClient` to `DocumentIntelligenceClient`, `DocumentModelAdministrationClient` to `DocumentIntelligenceAdministrationClient`).","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Refactor your code to iterate through `poller.result().documents` and then access `document.fields` to retrieve extracted key-value pairs or other information. Consult the latest quickstart examples for the new result parsing pattern.","message":"The structure of the `AnalyzeResult` object and how to access extracted data changed significantly in version 1.0.0 (aligned with service API 2024-11-30). Direct access to properties like `.forms` or `.receipts` is no longer available. Instead, results are accessed via `result.documents` which is a list of `Document` objects.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure `aiohttp` is installed for async use. When using async clients (`AsyncDocumentIntelligenceClient`), ensure all related operations (`await client.begin_analyze_document_from_url(...)`) are also `await`-ed within an `async` function.","message":"Asynchronous (async) client operations require the `aiohttp` package to be installed separately (`pip install azure-ai-documentintelligence[aiohttp]`). Mixing synchronous and asynchronous clients or methods can lead to runtime errors or unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify that your endpoint and key are correct and correspond to your Document Intelligence resource. For AAD authentication, use a custom subdomain. Always check the official documentation for the latest authentication recommendations.","message":"Authentication issues are common. Using a regional endpoint with Azure Active Directory (AAD) authentication is not supported; a custom subdomain name for your resource is required for AAD. Ensure `AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT` and `AZURE_DOCUMENT_INTELLIGENCE_KEY` environment variables are correctly set or provided to `DocumentIntelligenceClient` via `AzureKeyCredential`.","severity":"gotcha","affected_versions":"All"},{"fix":"Always use the latest stable SDK version. Refer to the Azure AI Document Intelligence documentation for the current recommended API version and models. Migrate any code using deprecated API versions or models as per the official migration guides.","message":"Older API versions and specific models are being deprecated. For example, the `2022-08-31` API version and the `prebuilt-document` model are deprecated in favor of newer API versions (e.g., `2024-11-30`) and models like `prebuilt-layout` with `features=keyValuePairs`.","severity":"deprecated","affected_versions":"<1.0.0 (for older APIs/models)"},{"fix":"Double-check that you are using the correct `model_id` obtained after training your custom model, usually found in the Azure portal or Document Intelligence Studio.","message":"When training and using custom models, remember to pass the `model_id` (an alphanumeric string or UUID), not the human-readable model name, to methods like `begin_analyze_document` or `begin_analyze_document_from_url`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}