Using document_intelligence_client.begin_analyze_document returns Session.request() got an unexpected keyword argument 'body'

Maxime Jack Raymond Jens Cara 0 Reputation points
2025-03-07T17:16:00.8233333+00:00

When I'm trying to use the following script:

  # Open local file in binary mode
    with open(file_path, "rb") as f:
        poller = document_intelligence_client.begin_analyze_document(
            model_id="prebuilt-layout",
            body=f
        )

I get the error:
Session.request() got an unexpected keyword argument 'body'

I've checked the version: Version: 1.0.0
and in case tried updating it with pip. It still returns the same error.
The key and endpoint are correct.

In essence, I want to use local PDF files and use document intelligence to retrieve the text and tables, maybe even figures later if I can figure this out first. I have a custom extraction model, but I'm just trying to test this first to see if everything is in order.

I've tried changing

body=f -> document=f

but the error just changes to

Session.request() got an unexpected keyword argument 'document'

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,958 questions
0 comments No comments
{count} votes

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.