talonic_to_markdown
Get OCR-converted markdown for a document. Accepts document_id (cheapest — no re-upload), file_data + filename, file_path, or file_url.
`talonic_to_markdown` converts a document's visual content into clean, structured markdown. Tables are rendered as markdown tables, headings are preserved, and the text is ordered to match the visual layout of the original document. This is the right tool when the user wants the full text of a document for summarisation, translation, or general analysis without needing structured field extraction.
If you have already ingested the document (via a previous talonic_extract or talonic_to_markdown call), pass the document_id to skip re-uploading. This is the cheapest and fastest path because the OCR has already been performed. For new documents, use file_data + filename in chat clients, file_path for local files, or file_url for remote files.
The returned markdown is suitable for feeding into an LLM's context window for downstream tasks. Because the conversion preserves table structure and heading hierarchy, the LLM can reason about the document's content without losing structural information that raw text extraction would discard.
| Parameter | Type | Description |
|---|---|---|
| document_id | string | ID of an already-ingested document (cheapest path). |
| file_data | string | Base64-encoded file bytes. Pair with `filename`. |
| filename | string | Original filename with extension. |
| file_path | string | Local file path. |
| file_url | string | Remote URL the API fetches server-side. |
talonic_extract with include_markdown: true instead of making two separate calls. This saves one upload and one processing cycle.Example
{
"document_id": "doc_8f3a1b2c-4d5e-6f7a-8b9c-0d1e2f3a4b5c"
}# Invoice INV-2026-001
**Meridian Energy AG**
Musterstraße 42, 10115 Berlin
| Item | Amount |
|-----------------------|------------|
| Consulting — April | €1,200.00 |
| Travel expenses | €300.00 |
| **Total** | **€1,500.00** |
Due date: 15 June 2026
Payment terms: Net 30Example: convert from URL
{
"file_url": "https://example.com/annual-report-2025.pdf"
}# Annual Report 2025
## Financial Highlights
| Metric | 2025 | 2024 | Change |
|---------------------|------------|------------|---------|
| Revenue | €12.4M | €9.8M | +26.5% |
| Net Income | €2.1M | €1.4M | +50.0% |
| Employees | 142 | 98 | +44.9% |
## Board of Directors
- **Chair**: Dr. Maria Fischer
- **CEO**: Thomas Bergmann
- **CFO**: Sarah LindqvistThe markdown output is designed to be LLM-friendly. Agents can feed the returned markdown directly into their context window for summarisation, translation, comparison, or question-answering tasks. Because the conversion preserves semantic structure (headings denote sections, tables retain rows and columns, lists maintain hierarchy), downstream LLM reasoning is significantly more accurate than working with raw OCR text that has lost all formatting cues.
For multi-page documents, the markdown includes page break indicators and preserves the reading order across pages. Headers, footers, and page numbers are typically stripped or de-duplicated to produce a clean reading experience. If the document contains images with embedded text (like scanned letterheads or stamps), the OCR engine extracts visible text from those regions as well, though image-only content without text is omitted from the markdown output.
When an agent needs to compare two versions of a document, talonic_to_markdown is the right starting point. Convert both documents to markdown, then use standard text diffing within the agent's context to identify changes. This is more reliable than visual comparison because the markdown normalises formatting differences and focuses on content. The stable document IDs make it easy to retrieve markdown for previously processed documents without re-uploading.