Skip to main content
Version: 3.1

Using Mistral OCR

Mistral OCR is a second PDF-to-Markdown backend, alongside Azure Document Intelligence. It converts a PDF to Markdown through Mistral's /v1/ocr endpoint so your Reaktors can process the text with AI models. Both backends live in the @operaide/document package.

Use Mistral OCR when you already run against Mistral or prefer a Mistral API key over an Azure connection. The two backends are interchangeable at the call site: only the function name and the connection type differ.

PDF conversion requires a configured Connection of type mistral-ocr. See the administrator guide for connection setup, caching, and timeout configuration.

aktorConvertPDFToMarkdownMistral​

Converts a single PDF to Markdown. The PDF is passed as a URL or a base64 data string.

import { aktorConvertPDFToMarkdownMistral } from '@operaide/document';

const markdown = aktorConvertPDFToMarkdownMistral({
pdf,
connectionName,
});
ParameterTypeDescription
pdfstringThe PDF to convert, either a URL or a data:application/pdf;base64,... string
connectionNamestring (optional)Name of the Mistral OCR connection. Falls back to the system default when omitted. Use 'default' for the default connection.

Returns a string containing the Markdown representation of the PDF.

aktorConvertMultiplePDFsToMarkdownMistral​

Batch-converts an array of PDFs. Each PDF is converted through the same connection.

import { aktorConvertMultiplePDFsToMarkdownMistral } from '@operaide/document';

const markdowns = aktorConvertMultiplePDFsToMarkdownMistral({
pdfs,
connectionName,
});
ParameterTypeDescription
pdfsstring[]Array of PDF URLs or base64 strings
connectionNamestring (optional)Name of the Mistral OCR connection

Returns string[], one Markdown string per input PDF.

Example: Reaktor that converts a PDF​

This Reaktor takes a PDF and returns its Markdown. The connection name is exposed as an App Setting so operators can point it at their configured connection.

import { aktorSetting, createAktorComposition, registerReaktorDefinition } from '@operaide/aktor';
import { aktorConvertPDFToMarkdownMistral } from '@operaide/document';
import { z } from 'zod';

const aktorMistralOcr = createAktorComposition('aktorMistralOcr', ({ document }) => {
const connectionName = aktorSetting(z.string().describe('Mistral OCR connection name'), 'default', 'Connection');
return aktorConvertPDFToMarkdownMistral({ pdf: document, connectionName });
});

registerReaktorDefinition({
reaktorDefinitionId: 'mistral-ocr',
label: 'Mistral OCR Demo',
description: 'Convert a PDF document to Markdown using Mistral OCR',
aktor: aktorMistralOcr,
inputSchema: z.object({
document: z.string().url().openapi({ example: 'https://example.com/document.pdf' }),
}),
outputSchema: z.string(),
});

Mistral OCR or Azure Document Intelligence​

Both backends produce Markdown from a PDF and share the same call shape. Pick by the credentials you hold:

BackendFunctionConnection typeCredential
Azure Document IntelligenceaktorConvertPDFToMarkdowndocument-intelligenceAzure
Mistral OCRaktorConvertPDFToMarkdownMistralmistral-ocrMistral

Switching backends is a change of function name and connection, not of your surrounding pipeline.

Common mistakes​

  • Calling the function without a connection. Mistral OCR needs a configured mistral-ocr connection. Without one, conversion fails. Set up the connection first (see the administrator guide).
  • Mixing up the connection type. A document-intelligence connection does not work with the Mistral functions, and a mistral-ocr connection does not work with aktorConvertPDFToMarkdown. Match the function to its connection type.
  • Passing a single PDF to the batch function. aktorConvertMultiplePDFsToMarkdownMistral expects an array and returns an array. For one PDF, use aktorConvertPDFToMarkdownMistral.