Skip to content

Docs / All tools / Loop III: Assistant

doc.extract_text

Extract text and tables from PDFs, scans, Office files, or emails.

25 credits. Per document. 0 when nothing is read.

Example prompt

Send this to your AI app when Heelo is connected:

Extract the text from this PDF

Input fields

FieldTypeDescription
sourceRequiredobjectThe document: {data} as base64, or {asset_id} returned by doc.render_* for the same caller and end_user_id.
end_user_idstringWhich of your end users an asset_id belongs to; must match the one it was rendered for.
mode"auto" | "fast" | "accurate"auto routes by document class; fast stops at the cheapest tier; accurate may climb.
page_numbersarray of integerOnly return these 1-based pages. Extraction still runs over the document.
max_pagesintegerCap on pages returned (max 500).

Output fields

The fields in data when status is success.

FieldType
pagesarray of object
doc_kindstring
engine_usedstring
page_countinteger
classificationobject
cost_hintobject
untrustedboolean

Code

The call with the input fields that the tool needs. Replace each word in capitals, such as ASSET_ID. Set HEELO_API_KEY to your API key.

import os
import requests

response = requests.post(
    "https://toolsprimitives.uk/v1/tools/doc.extract_text/invoke",
    headers={"Authorization": f"Bearer {os.environ['HEELO_API_KEY']}"},
    json={"input": {
        "source": {"asset_id": "ASSET_ID"},
    }},
    timeout=120,
)
response.raise_for_status()
print(response.json())