OCR a document or image (Document AI)
Relays to https://api.mistral.ai/v1/ocr, injecting the Authorization: Bearer credential.
Extracts the selected pages of a PDF (or a single image) as per-page markdown, optionally
with structured annotations pulled from the same pass. This is the only mounted Mistral
route — every other Mistral path answers the gateway’s own 404, this one included under any
other method or with a trailing slash.
Unlike the transparent routes in this spec, the body is a closed allow-set and the forwarded request is rebuilt from it:
modelis pinned tomistral-ocr-4-0. Send it or omit it; any other value — including themistral-ocr-latestalias — is a400.documentmust be adocument_urlchunk (optionally with adocument_name) or animage_urlchunk, carrying a publichttpsURL. Mistral’sfile_idchunk is denied: the shared account key behind this route would make one client’s uploaded file readable by all.pagesis required and selects at most 100 unique, zero-based page indices — an integer array, or a string of comma-separated indices andstart-endranges. It is the cost basis the balance preflight prices, which is why the route asks for it up front instead of defaulting to the whole document.include_blocksandinclude_image_base64are always forwarded asfalse; asking fortrueis a400, as areimage_limitandimage_min_size, and so is any field the policy doesn’t recognize.- Adding
document_annotation_formatorbbox_annotation_formatprices the whole call at the Document AI rate (4.22 per 1,000 pages), both with the gateway’s 5.5% fee included; the two rates never stack, anddocument_annotation_promptalone does not change the rate.
Mistral’s answer comes back exactly as it arrived — status, headers, and body bytes — and the
charge is settled from the usage_info.pages_processed it reports. There is no retry: a
second attempt is yours to make, as a separate, separately billed request.
Authentication
Your per-client bearer token — the API key the gateway issued to you. Present it in
Authorization: Bearer <token> form. A token that is missing, unknown, or revoked draws a
401. Before the call is sent upstream the token is removed (stripped, or swapped for the
upstream’s own credential); it never makes it past the gateway.
Request
The OCR request. A closed allow-set: document and pages are required, every other field
below is optional, and anything not listed is rejected with a 400 before Mistral is called.
What to read — one of the two admitted URL chunks. Mistral’s third chunk type, a file_id handle to a file on the account, is denied.
Which pages to read — required, and the basis for both the balance preflight and the
charge. Zero-based, at most 100 unique pages per request, and each index at most 9999. A
repeated or overlapping selection is refused rather than deduplicated, so a request always
costs what it looks like it costs. Either spelling works: an integer array, or a string of
comma-separated indices and ascending start-end ranges.
Pinned. Optional to send, but no other value — including the mistral-ocr-latest alias — is accepted, because an alias can re-point to a model at a different price.
How tables come back in the page markdown. null leaves Mistral’s own default in place.
Ask for per-page confidence scores. Only page (or null) is admitted; Mistral’s word granularity is denied, since a score per word multiplies the response size without changing what is metered.
Always forwarded as false. Sending true is rejected rather than silently rewritten.
Always forwarded as false. Sending true is rejected rather than silently rewritten — extracted image bytes are neither metered nor buffered here.
Mistral’s json_schema response format, at most 8,192 bytes serialized. Used for both
document_annotation_format (fields drawn from the whole document) and
bbox_annotation_format (labels for each detected figure); either one prices the call at the
Document AI rate.
Mistral’s json_schema response format, at most 8,192 bytes serialized. Used for both
document_annotation_format (fields drawn from the whole document) and
bbox_annotation_format (labels for each detected figure); either one prices the call at the
Document AI rate.
Plain-language instructions for the annotation pass. On its own it does not change the rate — only an annotation format does.
Response
Mistral’s own OCR result, relayed byte-for-byte — one entry per processed page, plus the
usage_info.pages_processed count the charge is settled from. Fields the request asked for
(document_annotation, per-image image_annotation) appear alongside; image_base64 is
always null, since the gateway forwards include_image_base64: false.
The model that ran — always the pinned OCR model.
The whole-document annotation when document_annotation_format was sent, null otherwise.

