Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

AzureDocumentIntelligenceConverter

Convert files to Haystack Documents using Azure AI Document Intelligence, extracting structured text with tables, headings, and layout.

Key Features

  • Converts PDF, JPEG, PNG, BMP, TIFF, DOCX, XLSX, PPTX, and HTML files.
  • Outputs GitHub Flavored Markdown, preserving document structure for LLM and RAG applications.
  • Accurately preserves headings, tables (as Markdown tables), lists, and reading order.
  • Supports multiple Azure Document Intelligence models through the model_id parameter.
  • Returns both Haystack Documents and raw Azure API responses.

Configuration

  1. Drag the AzureDocumentIntelligenceConverter component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Set the endpoint to your Azure Document Intelligence resource endpoint URL.
    2. Create a secret with your Azure Document Intelligence API key. Use AZURE_DI_API_KEY as the environment variable name. For instructions, see Create Secrets.
  4. Go to the Advanced tab to configure model_id and store_full_path.

Connections

AzureDocumentIntelligenceConverter receives a list of file sources. It outputs a list of Document objects containing the extracted text and a list of raw Azure API responses.

Source Code

To check this component's source code, open converter.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  AzureDocumentIntelligenceConverter:
type: haystack_integrations.components.converters.azure_doc_intelligence.converter.AzureDocumentIntelligenceConverter
init_parameters:
endpoint: https://my-resource.cognitiveservices.azure.com/
api_key:
type: env_var
env_vars:
- AZURE_DI_API_KEY
strict: false
model_id: prebuilt-document

Using the Component in a Pipeline

# haystack-pipeline
components:
AzureDocumentIntelligenceConverter:
type: haystack_integrations.components.converters.azure_doc_intelligence.converter.AzureDocumentIntelligenceConverter
init_parameters:
endpoint: https://my-resource.cognitiveservices.azure.com/
api_key:
type: env_var
env_vars:
- AZURE_DI_API_KEY
strict: false
model_id: prebuilt-layout

document_splitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: word
split_length: 250
split_overlap: 30

connections:
- sender: AzureDocumentIntelligenceConverter.documents
receiver: document_splitter.documents

max_runs_per_component: 100

metadata: {}

Parameters

Inputs

ParameterTypeDescription
sourcesList[Union[str, Path, ByteStream]]A list of file paths, Path objects, or ByteStream objects to convert.
metaOptional[Union[Dict[str, Any], List[Dict[str, Any]]]]Metadata to add to all documents, or a list of metadata dicts (one per source).

Outputs

ParameterTypeDescription
documentsList[Document]The extracted text as Haystack Documents in Markdown format.
raw_azure_responseList[Dict]The raw API responses from Azure Document Intelligence for each input file.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
endpointstr(required)The endpoint URL of your Azure Document Intelligence resource (for example, https://my-resource.cognitiveservices.azure.com/).
api_keySecretSecret.from_env_var("AZURE_DI_API_KEY")The API key for your Azure Document Intelligence resource.
model_idstrprebuilt-documentThe Azure Document Intelligence model to use. Common values are prebuilt-document, prebuilt-layout, prebuilt-read, and prebuilt-invoice.
store_full_pathboolFalseWhether to store the full file path in document metadata, or just the filename.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
sourcesList[Union[str, Path, ByteStream]]A list of file paths or streams to convert.
metaOptional[Union[Dict, List[Dict]]]NoneMetadata to add to the resulting documents.