Mistral OCR & Document Q&A
Turn invoices, contracts and scanned PDFs into clean Markdown with Mistral OCR: tables, headers and images come back page by page. Upload a file or point at a URL, choose the pages, then ask follow-up questions about the same document through Mistral chat with a document_url message.
Connect this API to an AI agent Browse all specs
What you can do with Mistral OCR & Document Q&A via MCP
Every endpoint below becomes a governed tool your AI agent (Claude, ChatGPT, or a customer-facing VX agent) can call — with scoped permissions, sandbox testing, and audit logs.
| Method | Path | Operation | Description |
|---|---|---|---|
| POST | /v1/ocr |
runOcr | Extract a document's text, tables and images as Markdown, page by page |
| POST | /v1/files |
uploadFile | Upload a PDF or image so OCR and chat can read it by file id |
| GET | /v1/files |
listFiles | List uploaded files, filtered by purpose, name or type |
| GET | /v1/files/{file_id} |
getFile | Get an uploaded file's name, size, purpose and creation time |
| GET | /v1/files/{file_id}/url |
getFileSignedUrl | Get a temporary download link for an uploaded file |
| POST | /v1/chat/completions |
askAboutDocument | Ask Mistral a question, optionally about a document passed as document_url |
| GET | /v1/models |
listModels | List the models this key can use, including the OCR models |
Authentication
ApiKey
Bearer token — sent as Authorization: Bearer <token>
Mistral API key, sent as Authorization: Bearer <key>.
How to get a credential
- Sign in to La Plateforme (https://console.mistral.ai).
- Pick a workspace and make sure it has a plan (the free Experiment plan works for testing; OCR is billed per page on paid plans).
- Open API Keys, click Create new key, name it and copy the value (it is shown once).
Permissions used
| Key access | Operations |
|---|---|
| Workspace API key | runOcr, uploadFile, listFiles, getFile, getFileSignedUrl, askAboutDocument, listModels |
Mistral API keys are not scoped: any key in the workspace can call every operation above.
Common errors
| Status | Meaning | Fix |
|---|---|---|
| 401 | Key missing, wrong or deleted | Create a new key in the console; new keys can take a minute to activate. |
| 403 | Plan or workspace does not allow the model | Check the workspace plan and billing. |
| 400 / 422 | Bad document or body | Use a public document_url (or a file_id from uploadFile) and a valid model such as mistral-ocr-latest. |
| 429 | Rate limit or monthly quota reached | Wait and retry; raise limits in the console. |
Store the key as a VX Agents credential (Bearer token).
Usage guide
Setup
- Add a Mistral API key from https://console.mistral.ai as a VX Agents Bearer credential.
- Pin
modelonrunOcrtomistral-ocr-latest, and onaskAboutDocumentto a chat model such asmistral-small-latest(checklistModelsfor what your key can use).
Read a document
- If the file is public, skip uploading. Otherwise confirm with the user, then
uploadFile(multipartfile,purpose: ocr) and keep the returnedid. runOcrwithmodelanddocument:- public PDF:
{"type": "document_url", "document_url": "https://..."} - uploaded file:
{"type": "file", "file_id": "<id>"} - image:
{"type": "image_url", "image_url": "https://..."}Optional:pages(e.g."0-2,5", first page is 0),table_format(markdownorhtml),extract_header/extract_footer,include_image_base64(only when images are needed: it makes the response large).
- public PDF:
- The response has
pages[]withindexandmarkdown, plustablesandimagesper page andusage_info(pages processed). Join the page markdown to quote or summarise the document. - For structured fields (invoice number, totals, parties), add
document_annotation_formatwith a JSON schema and readdocument_annotation.
Ask questions about a document
askAboutDocumentwithmodelandmessages, for example a user message whosecontentis[{"type": "text", "text": "What is the notice period?"}, {"type": "document_url", "document_url": "https://..."}]. An uploaded file works as{"type": "file", "file_id": "<id>"}.- For follow-ups, resend the earlier user messages (and the document chunk); the API keeps no history.
- Use
temperature0 to 0.3 for factual answers, andresponse_format{"type": "json_object"}when you need JSON.
Good to know
listFilesfilters bypurpose,search(file name) andmimetypes;getFileSignedUrlreturns a download link valid forexpiryhours (default 24, max 168).- OCR is billed per page: send
pageswhen only part of a long document matters. - Large PDFs give large responses; ask for a page range first, then continue.
- 429 means rate or quota limits; wait and retry.
- Deleting files is not part of this spec.
Source: Mistral AI API reference (https://docs.mistral.ai/api), checked 2026-10-20.
How to use this spec
- Create a free VX Agents account (sandbox tools included).
- Open the marketplace and connect “Mistral OCR & Document Q&A” to an agent.
- Expose it as an MCP server for Claude/ChatGPT, or chat with it directly.