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

# AI OCR and Document Extraction

> Extract text from images, receipts, and invoices using DeepSeek OCR, olmOCR, and PaddleOCR. Vision-based document processing with curl and Python examples.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Extract structured text from images, scanned documents, receipts, and invoices using vision-language models purpose-built for OCR. No preprocessing, no bounding boxes — send an image and get text back.

## Available OCR models

| Model                            | Parameters | Strengths                                             |
| -------------------------------- | ---------- | ----------------------------------------------------- |
| `deepseek-ai/DeepSeek-OCR`       | —          | High accuracy on complex layouts, tables, handwriting |
| `allenai/olmOCR-2-7B-1025`       | 2.7B       | Fast, lightweight, good for bulk processing           |
| `PaddlePaddle/PaddleOCR-VL-0.9B` | 0.9B       | Ultra-lightweight, edge-deployable                    |

***

## Extract text from an image

<CodeGroup>
  ```bash curl theme={"theme":"github-dark"}
  curl https://api.runcrate.ai/v1/chat/completions \
    -H "Authorization: Bearer rc_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "deepseek-ai/DeepSeek-OCR",
      "messages": [
        {
          "role": "user",
          "content": [
            {"type": "text", "text": "Extract all text from this document image. Preserve the layout and formatting."},
            {"type": "image_url", "image_url": {"url": "https://example.com/invoice.png"}}
          ]
        }
      ],
      "max_tokens": 2048
    }'
  ```

  ```python Python theme={"theme":"github-dark"}
  from openai import OpenAI
  import base64
  from pathlib import Path

  client = OpenAI(
      base_url="https://api.runcrate.ai/v1",
      api_key="rc_live_YOUR_API_KEY",
  )

  # Load a local image
  image_data = base64.b64encode(Path("invoice.png").read_bytes()).decode()

  response = client.chat.completions.create(
      model="deepseek-ai/DeepSeek-OCR",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "Extract all text from this document image. Preserve the layout and formatting."},
                  {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image_data}"}},
              ],
          }
      ],
      max_tokens=2048,
  )
  print(response.choices[0].message.content)
  ```
</CodeGroup>

***

## Receipt parsing with structured output

Extract specific fields from a receipt photo:

```python theme={"theme":"github-dark"}
from openai import OpenAI
import base64, json
from pathlib import Path

client = OpenAI(
    base_url="https://api.runcrate.ai/v1",
    api_key="rc_live_YOUR_API_KEY",
)

image_data = base64.b64encode(Path("receipt.jpg").read_bytes()).decode()

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-OCR",
    messages=[
        {
            "role": "system",
            "content": "Extract receipt data as JSON with keys: merchant, date, items (array of {name, quantity, price}), subtotal, tax, total. Use null for missing fields.",
        },
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Parse this receipt."},
                {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_data}"}},
            ],
        },
    ],
    max_tokens=1024,
)

receipt = json.loads(response.choices[0].message.content)
print(f"Merchant: {receipt['merchant']}")
print(f"Total: ${receipt['total']}")
for item in receipt["items"]:
    print(f"  - {item['name']}: ${item['price']}")
```

***

## Next steps

* [AI Vision API](/examples/vision-api) — analyze images beyond OCR: scene understanding, chart reading, visual Q\&A.
* [Extract structured data](/examples/structured-output) — combine OCR output with schema-based extraction for production pipelines.
* [Model catalog](/models/model-catalog) — browse all available vision and OCR models.
