Amux AI

Document OCR

Last updated November 24, 2026

Synchronous document and image OCR endpoint accepting multipart/form-data uploads and returning per-page text or Markdown.

Unified synchronous document and image OCR endpoint routing by model (currently supporting DeepSeek OCR). Upload PDF, Office documents, or images via multipart/form-data and receive per-page plain text or layout-preserving Markdown.

For vision-chat OCR models such as Jina OCR v1, call Chat Completions (POST /v1/chat/completions) instead of this endpoint.

POSThttps://gateway.amux.ai/v1/tools/ocr

Authorization

header
AuthorizationstringRequired

Bearer <your Amux AI key> Amux AI API key created in the console.

Request

multipart/form-data
modelstringRequired

OCR model canonical ID or alias (for example deepseek/deepseek-ocr or deepseek-ocr).

purpose"text_recognition" | "rich_layout_recognition"Required

Recognition mode — text_recognition extracts text directly from Word/PowerPoint without images and processes other formats page-by-page; rich_layout_recognition recognizes every file page-by-page while preserving headings, tables, formulas, and layout structure.

filestringRequired

Document or image file to recognize. Supports PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, and TIFF (max 100 MiB, up to 1,000 pages).

Response

200response

Document OCR succeeded.

400response

Invalid multipart payload, missing required fields, file size exceeded, or model does not support OCR.

402response

Insufficient workspace balance.

Protocol overview

  • Supported formats and limits: Accepts PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, and TIFF up to 100 MiB and 1,000 pages per file.
  • Dual recognition modes: Set form field purpose to text_recognition (plain text) or rich_layout_recognition (Markdown preserving headings, tables, and math formulas).
  • Long-running resilience: For large multi-page files, leading keep-alive whitespace before the JSON payload is transparently stripped and validated by the gateway.
  • Billing: Billed strictly per recognized page (page_count); 0 pages or failed calls are free. Token counts in usage are informational only.

Error handling

Errors follow the standard OpenAI error schema. Non-multipart requests, invalid purpose, oversized files, or model mismatches return 400 invalid_request. See Errors and retries.

cURL
curl https://gateway.amux.ai/v1/tools/ocr \
  -H "Authorization: Bearer $AMUX_API_KEY" \
  -F "model=deepseek/deepseek-ocr" \
  -F "purpose=text_recognition" \
  -F "file=@/path/to/file.png"
{
  "id": "ocr-0196a1b2c3d4",
  "object": "ocr.result",
  "created": 1763900000,
  "model": "deepseek/deepseek-ocr",
  "purpose": "text_recognition",
  "page_count": 2,
  "pages": [
    {
      "index": 0,
      "text": "# Invoice #1024",
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "input_tokens": 512,
    "output_tokens": 128,
    "total_tokens": 640
  }
}