---
title: "Create Ocr"
method: POST
path: "/v1/ocr"
tags: ["OCR"]
---

# Create Ocr

`POST /v1/ocr`

## Request

- The document declares no server URL.
- Auth: HTTP bearer

Extracts text from files using Mistral Document AI pipeline

## Request body

- CreateOCRBody
  - `document` union, required: Document to run OCR on.
    - DocumentURLChunk
      - `document_name` string, nullable: The filename of the document.
      - `document_url` string, required: The URL of the document.
      - `type` 'document_url': The type of the document.
    - ImageURLChunk
      - `image_url` union, required: The URL of the image to OCR.
        - ImageURL
          - `detail` string, nullable: The detail of the image.
          - `url` string, required: The URL of the image.
        - string
      - `type` 'image_url': The type of the image.
  - `document_annotation_prompt` string, nullable: Optional prompt to guide the model in extracting structured output from the entire document. A document_annotation_format must be provided.
  - `model` string, required: The model to use for the OCR, call `/v1/models` endpoint to get the list of available models, only `image-to-text` model type is supported.

## Response `200`

Successful Response

- OCRResponse
  - `document_annotation` string, nullable: Formatted response in the request_format if provided in json str
  - `id` string, nullable: The ID of the OCR request.
  - `model` string, nullable: The model used to generate the OCR.
  - `pages` OCRPageObject[], required: List of OCR info for pages.
    - `dimensions` OCRPageDimensions
      - `dpi` integer, required: Dots per inch of the page-image
      - `height` integer, required: Height of the image in pixels
      - `width` integer, required: Width of the image in pixels
    - `footer` string, nullable: The footer of the page, returned when extract_footer is enabled
    - `header` string, nullable: The header of the page, returned when extract_header is enabled
    - `hyperlinks` string[]: The hyperlinks extracted from the page.
    - `images` OCRImageObject[], required: List of all extracted images in the page.
      - `bottom_right_x` integer, nullable: X coordinate of bottom-right corner of the extracted image
      - `bottom_right_y` integer, nullable: Y coordinate of bottom-right corner of the extracted image
      - `id` string, required: Image ID for extracted image in a page
      - `image_annotation` string, nullable: Annotation of the extracted image in json str
      - `image_base64` string, nullable: Base64 string of the extracted image
      - `top_left_x` integer, nullable: X coordinate of top-left corner of the extracted image
      - `top_left_y` integer, nullable: Y coordinate of top-left corner of the extracted image
    - `index` integer, required: The page index in a pdf document starting from 0
    - `markdown` string, nullable: The markdown string response of the page
    - `tables` OCRTableObject[]: The tables extracted from the page, in the requested table_format.
      - `content` string, nullable: The content of the extracted table, in the requested table format
      - `format` string, nullable: The format of the extracted table: 'markdown' or 'html'
      - `id` string, nullable: Table ID for the extracted table in a page
  - `usage` Usage
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `total_tokens` integer
    - `prompt_tokens_details` PromptTokensDetails
      - `cached_tokens` integer
    - `cost` number
    - `impacts` ApiDomainUsageEntitiesEnvironmentalImpacts
      - `kWh` number
      - `kgCO2eq` number
  - `usage_info` OCRUsage
    - `doc_size_bytes` integer, nullable: Document size in bytes
    - `pages_processed` integer, required: Number of pages processed

## Other responses

- `400`: Insufficient budget.
- `401`: Invalid authentication scheme.<br>Invalid API key.
- `403`: Your account has expired. Please contact support to renew your account.
- `404`: Model {name} not found.
- `422`: Model has wrong type. Expected: {expected_type}. Actual: {actual_type}.
- `429`: Token/request limit per minute/day exceeded.
- `503`: Model is too busy, please try again later.

## Changes

- **2026-09-29** `2f7a4a0aac8f`: 1 info
  - endpoint added
- **2026-09-29** `da70d9cd1957`: 1 breaking
  - api path removed without deprecation
- **2026-09-21** `5fdbd3614b8c`: 2 info
  - added `#/components/schemas/Usage` to the `usage` response property `anyOf` list for the response status `200`
  - removed `#/components/schemas/api__domain__usage__entities__Usage` from the `usage` response property `anyOf` list for the response status `200`
- **2026-08-20** `0db3023472ef`: 21 breaking, 1 warning, 28 info
  - removed `#/components/schemas/ImageURL` from the `document/anyOf[subschema #2: ImageURLChunk]/image_url` request property `anyOf` list
  - the response property `headers` became optional for the status `404`
  - the response property `headers` became optional for the status `422`
  - the response property `headers` became optional for the status `503`
  - …46 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/betagouv/apis/opengatellm/changes/v1/ocr/post.md)

---

[API](https://skmtc.dev/betagouv/apis/opengatellm.md) - [All operations](https://skmtc.dev/betagouv/apis/opengatellm/llms.txt) - [OpenAPI document](https://skmtc.dev/betagouv/apis/opengatellm/revisions/2f7a4a0aac8f?raw)
