The post room is ankle-deep in letters, half of them in crayon. The toy list is due at the workshop by morning, and Sprocket has already uncapped a pen.
- Sprocket
Not one of these is typed! Fine. I'll type them all up myself by morning. How hard can crayon be?
- Mrs. Claus
Before anything leaves this room: who can see these letters? They carry children's names and home addresses.
- Tinsel
Whoever runs the model reads every page we send. So send the letter, not the envelope.
- Sprocket
And this one is just a crayon pony with an arrow. The arrow says THIS ONE. Underlined three times.
- Tinsel
Two desks, one key. Scans go to
/ocrand come back as markdown per page, and drawings go to a vision model as an image.
- clientYour appletter.pdf · drawing.png
- orq.aiAI Router/ocr · /chat/completions
- documentimageocrMistral OCR 4.1mistral-ocr-4-1visionClaude Sonnet 5.5claude-sonnet-5-5
- textMarkdown per pagepages[].markdownanswerWhat was drawnmessage.content
How it works
Tinsel’s two desks share one base URL and one API key. Pick the desk by what you want back.
- OCR endpoint.
POST /v3/router/ocrwith amodeland adocument. The document is either adocument_url(for example a PDF) or animage_url. - Pages and images.
pagesis a list of 0-based page indices. Omit it, or passnull, for all pages.ocr_settingscontrols how extracted images come back:include_image_base64returns them inline as base64, andmax_images_to_includeandimage_min_sizelimit which ones are included. - Markdown back. The response has the
model, apagesarray where each page carries itsindex,markdownandimages, and ausageobject counting pages or tokens. - Vision instead. To ask a question about the letter, put the image or PDF in the message
contentnext to your text, on/v3/router/responsesor/v3/router/chat/completions. The router converts it to the shape the provider expects.
Try it with curl
This sends the sample PDF from the docs. Swap in the URL of your own scan.
PDF="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf"
curl -s -X POST https://my.orq.ai/v3/router/ocr \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<EOF | jq -r '.pages[].markdown'
{
"model": "mistral/mistral-ocr-4-1",
"document": {
"type": "document_url",
"document_url": "$PDF/dummy.pdf",
"document_name": "letter-to-santa.pdf"
},
"pages": [0]
}
EOF
Or from the OpenAI SDK
For the drawing, send the image as a base64 data URI in a Chat Completions image_url part:
import base64
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ORQ_API_KEY"],
base_url="https://my.orq.ai/v3/router",
)
with open("drawing.png", "rb") as f:
b64 = base64.b64encode(f.read()).decode("utf-8")
response = client.chat.completions.create(
model="anthropic/claude-sonnet-5-5",
messages=[{
"role": "user",
"content": [
{"type": "text",
"text": "List every toy drawn on this letter."},
{"type": "image_url",
"image_url": {
"url": f"data:image/png;base64,{b64}",
"detail": "high",
}},
],
}],
)
print(response.choices[0].message.content)
detail takes low (512x512), high (full resolution) or auto, the default.
OCR or vision?
| You want | Send it to |
|---|---|
| The text, page by page, as markdown | /v3/router/ocr |
| An answer about a drawing or a form | An image or file part on a chat model |
| Both, from a messy scan | OCR first, then the markdown to a chat model |
The content part names differ per API:
| Image | Document | |
|---|---|---|
| Responses API | input_image |
input_file |
| Chat Completions | image_url |
file |
Which models read what
Image support and PDF support are separate. In the model catalog, anthropic/claude-sonnet-5-5 and google/gemini-4-neon list both image and PDF input. openai/gpt-6.2-sol lists image only.
A part a provider cannot accept may be dropped rather than rejected. The request succeeds and the model answers without seeing the file. On Chat Completions, OpenAI and OpenAI-compatible providers return 400 instead when the file is in the latest user message.
Limits and privacy
Each image can be up to 20MB, as JPEG, PNG, WebP or static GIF. Some models accept only one image per prompt. The provider that runs the model receives every page you send, so leave out what it does not need to read.
Nice list
- Check that a model reads PDFs before you send one. Image support and PDF support are separate capabilities.
- Default to a base64 data URI in a content part. The docs call it the safest choice: it works with every provider.
- Ask only for the pages you need with
pages. Indices start at 0, so the first page is[0].
Naughty list
- Sending a PDF to a model that only reads images. The part may be dropped, the request still succeeds, and the model answers about a letter it never saw.
- Sending a document
file_urlto an OpenAI model. It does not reach OpenAI. Send base64file_dataor an Orq.aifile_idinstead. - Leaving out
filenameon a document sent asfile_data. It is required there, unlike for images; only an uploadedfile_idcan skip it. - Adding your own fields to the OCR request body. Its schema does not allow unknown properties.
Elf's challenge
Did the post room bill Santa by the page or by the token? OCR only the first page of the docs' sample PDF, print the raw JSON, and read the page's index and the usage.type.
Stuck? Ask Tinsel for a hint
The page comes back with index 0, because page numbers start from 0. The usage object says what was counted: its type is pages with pages_processed, or tokens with tokens_processed.
Christmas crackerWhat carol does the OCR model sing while it types up Santa's post?Pull it for the punchline
"Markdown the halls", one page at a time.