> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dedaluslabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OCR

> Extract text from PDFs and images

## Overview

The OCR endpoint extracts text from documents and images, returning clean markdown. Powered by Mistral's OCR model.

**Supported formats:** PDF, PNG, JPEG, WebP

## Quick Start

<CodeGroup>
  ```bash CLI theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST https://api.dedaluslabs.ai/v1/ocr \
    -H "Authorization: Bearer $DEDALUS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "mistral-ocr-latest",
      "document": {
        "type": "document_url",
        "document_url": "https://arxiv.org/pdf/1706.03762"
      }
    }'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import httpx
  import os

  response = httpx.post(
      "https://api.dedaluslabs.ai/v1/ocr",
      headers={"Authorization": f"Bearer {os.environ['DEDALUS_API_KEY']}"},
      json={
          "model": "mistral-ocr-latest",
          "document": {
              "type": "document_url",
              "document_url": "https://arxiv.org/pdf/1706.03762"
          }
      },
      timeout=120.0
  )

  for page in response.json()["pages"]:
      print(f"Page {page['index']}:\n{page['markdown'][:200]}...")
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await fetch("https://api.dedaluslabs.ai/v1/ocr", {
  	method: "POST",
  	headers: {
  		Authorization: `Bearer ${process.env.DEDALUS_API_KEY}`,
  		"Content-Type": "application/json",
  	},
  	body: JSON.stringify({
  		model: "mistral-ocr-latest",
  		document: {
  			type: "document_url",
  			document_url: "https://arxiv.org/pdf/1706.03762",
  		},
  	}),
  });

  const data = await response.json();
  for (const page of data.pages) {
  	console.log(`Page ${page.index}:\n${page.markdown.slice(0, 200)}...`);
  }
  ```
</CodeGroup>

<Tip>
  For local files, encode as base64 data URI: `data:application/pdf;base64, 	{base64_data}`
</Tip>

## Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
	"pages": [
		{
			"index": 0,
			"markdown": "# Attention Is All You Need\n\nAshish Vaswani, Noam Shazeer...\n\n# Abstract\n\nThe dominant sequence transduction models..."
		},
		{
			"index": 1,
			"markdown": "## 1 Introduction\n\nRecurrent neural networks..."
		}
	],
	"model": "mistral-ocr-latest"
}
```

## Use Cases

### Invoice Processing

Extract line items, totals, and dates from invoices for automated bookkeeping.

### Receipt Scanning

Parse receipts for expense tracking—amounts, vendors, dates extracted as structured text.

### Document Digitization

Convert scanned documents to searchable, editable markdown while preserving tables and formatting.

## Parameters

| Parameter               | Type   | Required | Description                              |
| ----------------------- | ------ | -------- | ---------------------------------------- |
| `model`                 | string | No       | OCR model. Default: `mistral-ocr-latest` |
| `document.type`         | string | Yes      | Always `document_url`                    |
| `document.document_url` | string | Yes      | HTTPS URL or data URI                    |

## Limits

* **Max file size:** 50 MB
* **Max pages:** 1,000 per document
* **Timeout:** 120 seconds
