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_idparameter. - Returns both Haystack Documents and raw Azure API responses.
Configuration
- Drag the
AzureDocumentIntelligenceConvertercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Set the
endpointto your Azure Document Intelligence resource endpoint URL. - Create a secret with your Azure Document Intelligence API key. Use
AZURE_DI_API_KEYas the environment variable name. For instructions, see Create Secrets.
- Set the
- Go to the Advanced tab to configure
model_idandstore_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
| Parameter | Type | Description |
|---|---|---|
sources | List[Union[str, Path, ByteStream]] | A list of file paths, Path objects, or ByteStream objects to convert. |
meta | Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] | Metadata to add to all documents, or a list of metadata dicts (one per source). |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | The extracted text as Haystack Documents in Markdown format. |
raw_azure_response | List[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:
| Parameter | Type | Default | Description |
|---|---|---|---|
endpoint | str | (required) | The endpoint URL of your Azure Document Intelligence resource (for example, https://my-resource.cognitiveservices.azure.com/). |
api_key | Secret | Secret.from_env_var("AZURE_DI_API_KEY") | The API key for your Azure Document Intelligence resource. |
model_id | str | prebuilt-document | The Azure Document Intelligence model to use. Common values are prebuilt-document, prebuilt-layout, prebuilt-read, and prebuilt-invoice. |
store_full_path | bool | False | Whether 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
sources | List[Union[str, Path, ByteStream]] | A list of file paths or streams to convert. | |
meta | Optional[Union[Dict, List[Dict]]] | None | Metadata to add to the resulting documents. |
Related Information
Was this page helpful?