In this guide, you’ll go from zero to structured output in under 5 minutes using the Tensorlake SDK.
We’ll walk through uploading a PDF document, enabling signature detection, and printing structured JSON output.
Prerequisites
Step 1: Install the SDK
Step 2: Set Your API Key
Create a .env
file or export the variable:
export TENSORLAKE_API_KEY=your-api-key-here
Or in your Python script:
import os
os.environ["TENSORLAKE_API_KEY"] = "your-api-key-here"
Step 3: Upload and Parse a Document
Create a file called quickstart.py
:
from tensorlake.documentai import DocumentAI
from tensorlake.documentai.parse import ParsingOptions, SignatureDetectionMode
import os, json
api_key = os.getenv("TENSORLAKE_API_KEY")
doc_ai = DocumentAI(api_key=api_key)
# Upload the document
file_id = doc_ai.upload(path="Residential-Real-Estate-Purchase-Agreement-All-Signed.pdf")
# Configure parsing options
options = ParsingOptions(
page_number=1,
chunk_strategy=ChunkingStrategy.NONE,
table_parsing_strategy=TableParsingStrategy.TSR,
table_output_mode=TableOutputMode.MARKDOWN,
detect_signature=True,
extraction_options=ExtractionOptions(
schema="""{"properties":{"buyer":{"properties":{"buyer_name":{"type":"string"},"buyer_signature_date":{"description":"Date and time (if both are available) that the buyer signed.","type":"string"},"buyer_signed":{"description":"Determine if the buyer signed the agreement","type":"boolean"}},"type":"object"},"seller":{"properties":{"seller_name":{"type":"string"},"seller_signature_date":{"description":"Date and time (if both are available) that the seller signed.","type":"string"},"seller_signed":{"description":"Determine if the seller signed the agreement","type":"boolean"}},"type":"object"}},"title":"leasing_agreement","type":"object"}""",
skip_ocr=True,
),
)
# Parse
job = doc_ai.parse(file_id=file_id, options=options)
result = doc_ai.wait_for(job)
# Save + print result
with open("output.json", "w") as f:
json.dump(result.model_dump(), f, indent=2)
print("✅ Output saved to output.json")
Run it:
What You’ll See
- A file called
output.json
with structured data like:
{
"pages": [
{
"page_number": 1,
"json_result": {
"buyer": {
"buyer_name": "Nova Ellison",
"buyer_signature_date": "September 10, 2025",
"buyer_signed": true
},
"seller": {
"seller_name": "Juno Vega",
"seller_signature_date": "September 10, 2025",
"seller_signed": true
}
}
}
]
}
Next Steps
Need help? Join our Slack and say hi!