Analyze Document
Analyze a document by asking questions. Unlike /extract, this endpoint
can compute, reason, and derive values that aren’t explicitly written
in the document.
Upload a file (or provide a URL) along with a typed schema. Each field
must have a type and description.
Example schema:
{
"total_cost": {"type": "number", "description": "Sum all line item amounts"},
"is_auto_renew": {"type": "boolean", "description": "Does this contract auto-renew?"},
"risk_level": {"type": "string", "enum": ["low", "medium", "high"], "description": "Legal risk level"}
}
Supported types: string, number, integer, boolean, array, object
Every answer includes:
- The computed answer (type-enforced)
- Reasoning explaining how it was derived
- Source text snippets from the document
- Confidence level
Pricing: 2 credits/page (min 5) for documents, 10 credits for websites.
Headers
Body
JSON schema — keys are field names, values describe what to compute or answer
File to analyze
URL to fetch file from
JSON-encoded headers for URL auth
Include the agent's reasoning trace (tool calls) in each answer
Set to false to process asynchronously. Returns a task_id to poll.
URL to POST the result to when async processing completes.
Response
Successful Response
Response for document analysis — flat parallel dicts matching /extract.
Computed/derived values keyed by field name
Original filename or URL
Model used for analysis
Length of extracted text
Per-field confidence scores (0.0–1.0)
Per-field source text snippets from the document
Per-field step-by-step explanation of how the answer was derived
Per-field agent reasoning trace (tool calls). Empty unless include_steps=true.
Detected MIME type
Total pages in the document (0 for non-paginated files)
Credits consumed
Schema format: always 'typed'
typed