Azure AI Document Intelligence - Studio finds key-value pairs, but code has keyValuePairs as None - how do I enable this?

Daniel Cruz 0 Reputation points
2025-07-23T14:18:08.06+00:00

I have a bunch of files with the same format from which I'm trying to extract key:value pairs in batch. It appears that in the document intelligence studio I have to do this for every document separately, which is not feasible given the number of documents, so I've switched to using the python API. I'm trying to activate the keyValuePairs feature but despite my best efforts it isn't working. I found something that said it doesn't work with markdown output, which is why I'm specifying text here.

formPath = "path to my file"
with open(formPath, "rb") as f:
        base64_encoded_pdf = base64.b64encode(f.read()).decode("utf-8")
        
document_intelligence_client  = DocumentIntelligenceClient(
    endpoint=endpoint, credential=AzureKeyCredential(key),
    features = ['keyValuePairs'], #is this how to specify this? Can't find in documentation so this is copied from online somewhere.
    output_content_format=ContentFormat.TEXT
)
poller = document_intelligence_client.begin_analyze_document(
    "prebuilt-layout", AnalyzeDocumentRequest(bytes_source = base64_encoded_pdf)
)
result = poller.result()
Azure AI Document Intelligence
{count} votes

1 answer

Sort by: Most helpful
  1. Aryan Parashar 150 Reputation points Microsoft External Staff Moderator
    2025-08-05T09:14:05.1466667+00:00

    Hi Daniel,

    Currently only these models support key-value pair extraction.

    Feature Version Model ID
    Layout model with the optional query string parameter features=keyValuePairs enabled • v4: 2024-11-30
    • v3.1: 2023-07-31 (GA) prebuilt-layout
    General document model • v3.1: 2023-07-31 (GA) • v3.0: 2022-08-31 (GA) • v2.1 (GA) prebuilt-document

    Here is the supported documentation.
    https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/general-document?view=doc-intel-4.0.0&view%3C=doc-intel-3.1.0&preserve-view=true

    This is the documentation for all the functions needed to run the Azure Document Intelligence services using Python.
    https://learn.microsoft.com/en-us/python/api/azure-ai-documentintelligence/azure.ai.documentintelligence.documentintelligenceclient?view=azure-python#azure-ai-documentintelligence-documentintelligenceclient-begin-analyze-document

    Let me know if the issue still persists.
    Thank you for reaching Microsoft QNA Portal.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.