---
title: "OCR"
method: POST
path: "/v1/ocr"
---

# OCR

`POST /v1/ocr`

Extract text and structure from a document or image as markdown using an OCR model.

## Request body

- object
  - `model` string, required — ID of the OCR model to use.
  - `document` union, required — The document or image to run OCR on.
    - object
      - `type` 'document_url', required
      - `document_url` string, required — URL or data URL of the PDF/document to process.
      - `document_name` string
    - object
      - `type` 'image_url', required
      - `image_url` union, required — URL or data URL of the image to process, or an object with a `url` field.
        - string
        - object
          - `url` string, required
  - `id` string
  - `pages` union — Specific pages to process, as a list of page indices or a range string (e.g. '0-5').
    - integer[]
    - string
  - `include_image_base64` boolean — Whether to return extracted images as base64 in the response.
  - `image_limit` integer
  - `image_min_size` integer
  - `bbox_annotation_format` object
  - `document_annotation_format` object

## Response `200`

OCR response.

- object — OCR response payload returned by the upstream provider.
  - `pages` object[]
    - `index` integer
    - `markdown` string
    - `images` object[]
    - `dimensions` object, nullable
  - `model` string
  - `document_annotation` string, nullable
  - `usage_info` object
    - `pages_processed` integer
    - `doc_size_bytes` integer, nullable

## Other responses

- `400` — Invalid request body or parameters.
- `401` — Unauthorized request.
- `402` — Payment required / insufficient credits.
- `403` — Forbidden upstream response.
- `404` — Not found upstream response.
- `410` — Archived or unavailable project.
- `429` — Rate limited upstream response.
- `500` — Internal server error.
- `502` — Failed to connect to the upstream provider.
- `503` — Service unavailable upstream response.
- `504` — Upstream provider timeout.

---

[API](https://skmtc.dev/llmgateway/apis/llmgateway-api.md) · [All operations](https://skmtc.dev/llmgateway/apis/llmgateway-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/llmgateway/llmgateway-api/revisions/aaf167e3d8cc/schema)
