OCRRouter

Claude API docs

How OCRRouter calls Claude, what the upstream returns field by field, and how that becomes Markdown and JSON blocks.

Overview

Claude is Anthropic's multimodal model family. OCRRouter sends the file with a fixed transcription prompt through the Messages API and gets Markdown back.

The model returns one text answer for the whole file. OCRRouter asks it to mark each page and splits on those marks.

Price and limits

Model ID
anthropic/claude
Price
25 credits / page ($25 per 1,000 pages)
Max pages per request
100
Inputs
PDF; Images; Sent inline as base64
Languages
50+ languages
Positions (bbox)
No, text only
  • Up to 100 pages per document in OCRRouter
  • Anthropic caps request size at 32 MB
  • Output capped at 32,000 tokens per request

You pay only for pages that succeed. A failed attempt that falls back to another model is not charged. See pricing.

How OCRRouter calls it

Endpoint
POST https://api.anthropic.com/v1/messages, anthropic-version 2023-06-01
Model
ANTHROPIC_OCR_MODEL, default claude-sonnet-5-5
Request
One user message: a document block (PDF) or image block with base64 source, then a text block with the OCR prompt
Fallback via AIHubMix
Same Messages API call at AIHubMix's base URL, model AIHUBMIX_ANTHROPIC_MODEL (default claude-sonnet-5-5)
Fallback via OpenRouter
Chat Completions, model OPENROUTER_ANTHROPIC_MODEL (default anthropic/claude-sonnet-5.5), PDFs passed to the model natively

Options

What OCRRouter sets on the upstream call. You choose the model, format and pages in your request; vendor-specific options are not passed through.

max_tokens
32000
Prompt
Fixed: transcribe every page exactly as Markdown, LaTeX for formulas, a <!-- page:N --> line before each page, no code fence
temperature
Not set on the Messages call (Anthropic default); 0 on the OpenRouter call
Client options
Clients cannot pass Claude-specific options through OCRRouter

Raw response fields

Every field the upstream documents, with its type and meaning taken from the vendor's own reference. Fields marked "read by OCRRouter" are the ones our connector uses; the rest are listed so you know what the engine produces.

Anthropic Messages API response

Message object from POST /v1/messages. Fields follow Anthropic's API reference and official TypeScript SDK types.

Source: Anthropic Messages API, retrieved 2026-11-19

idstring
Unique object ID; format may change.Example: "msg_013Zva2CMHLNnXjNJJKqJ2EF"
typestring
Always message.Example: "message"
rolestring
Always assistant.Example: "assistant"
contentContentBlock[], read by OCRRouter
Content generated by the model; each block's type sets its shape.
content[].typestring, read by OCRRouter
Block type; text for text output (also tool_use, thinking and others).Example: "text"
content[].textstring, read by OCRRouter
Text of a text block.
content[].citationsarray | null
Citations supporting a text block, such as page_location for PDFs.
modelstring
Model that handled the request.
stop_reasonstring | null
end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal or model_context_window_exceeded. Always set when not streaming.Example: "end_turn"
stop_sequencestring | null
Custom stop sequence that was generated, if any.
stop_detailsobject | null
Structured detail on the stop reason, such as a refusal.
containerobject | null
Container used, when a container tool such as code execution ran.
diagnosticsobject | null
Request diagnostics, when requested.
usage.input_tokensinteger
Input tokens used, excluding cache reads and writes.
usage.output_tokensinteger
Output tokens used.
usage.cache_creation_input_tokensinteger | null
Input tokens written to the prompt cache.
usage.cache_read_input_tokensinteger | null
Input tokens read from the prompt cache.
usage.cache_creationobject | null
Cache write tokens broken down by TTL.
usage.output_tokens_detailsobject | null
Breakdown of output tokens, such as reasoning.
usage.server_tool_useobject | null
Count of server tool requests.
usage.service_tierstring | null
standard, priority or batch.
usage.inference_geostring | null
Region where inference ran.
usage.speedstring | null
Inference speed mode, standard or fast.

Shape from Anthropic's Messages API reference example; text replaced with OCR output, values illustrative.

{"id": "msg_013Zva2CMHLNnXjNJJKqJ2EF","type": "message","role": "assistant","model": "claude-sonnet-5-5","content": [{"type": "text","text": "<!-- page:1 -->\n# Invoice 1042\n...","citations": null}],"stop_reason": "end_turn","stop_sequence": null,"usage": {"input_tokens": 2095,"output_tokens": 503,"cache_creation_input_tokens": 0,"cache_read_input_tokens": 0,"service_tier": "standard"}}

Gateway response: Chat Completions

Used only when there is no Anthropic key and the gateway is OpenRouter (AIHubMix uses the Messages API above). OCRRouter calls POST /chat/completions, which return OpenAI's chat completion object. Fields follow OpenAI's reference.

Source: OpenAI chat completion object, retrieved 2026-11-19

idstring
Unique ID of the chat completion.Example: "chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG"
objectstring
Always chat.completion.Example: "chat.completion"
createdinteger
Unix time in seconds when the completion was created.Example: 1741570283
modelstring
Model used for the completion.
choicesarray, read by OCRRouter
Completion choices; more than one only when n > 1.
choices[].indexinteger
Position of the choice in the list.Example: 0
choices[].message.rolestring
Role of the message author, assistant.Example: "assistant"
choices[].message.contentstring | null, read by OCRRouter
Text of the message.
choices[].message.refusalstring | null
Refusal message from the model, if any.
choices[].message.annotationsarray
Annotations such as web search citations, when applicable.
choices[].message.tool_callsarray
Tool calls generated by the model.
choices[].finish_reasonstring
Why generation stopped: stop, length, content_filter, tool_calls or function_call.Example: "stop"
choices[].logprobsobject | null
Log probability information for the choice.
usage.prompt_tokensinteger
Tokens in the prompt.
usage.completion_tokensinteger
Tokens in the generated completion.
usage.total_tokensinteger
Prompt plus completion tokens.
usage.prompt_tokens_detailsobject
Breakdown of prompt tokens, such as cached tokens.
usage.completion_tokens_detailsobject
Breakdown of completion tokens, such as reasoning tokens.
service_tierstring | null
Processing tier used for the request.
system_fingerprintstring
Backend configuration the model ran with.
errorobject, read by OCRRouter
Not part of OpenAI's object. Gateways may return an error object in a 200 body; OCRRouter treats it as a failure.

Shape from OpenAI's chat completion object example; content replaced with OCR output, values shortened.

{"id": "chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG","object": "chat.completion","created": 1741570283,"model": "MODEL","choices": [{"index": 0,"message": {"role": "assistant","content": "<!-- page:1 -->\n# Invoice 1042\n...","refusal": null,"annotations": []},"logprobs": null,"finish_reason": "stop"}],"usage": {"prompt_tokens": 1117,"completion_tokens": 46,"total_tokens": 1163,"prompt_tokens_details": { "cached_tokens": 0 },"completion_tokens_details": { "reasoning_tokens": 0 }},"service_tier": "default","system_fingerprint": "fp_fc9f1d7035"}

How it maps to OCRRouter output

content[] where type is text
Text blocks joined into one string (direct and AIHubMix paths)
choices[0].message.content
The text, string or array of text parts joined (OpenRouter path)
<!-- page:N --> markers
Text split into pages[]; a stray code fence is removed; no markers means one page; extra pages are merged into the last
Empty text
Request fails with "Provider returned no text"
Layout and confidence
None: no bbox or confidence from this model

The unified output is described in Response format.

Example request

curl https://api.ocrrouter.ai/v1/ocr \
  -H "Authorization: Bearer $OCRROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude",
    "file_url": "https://example.com/invoice.pdf",
    "format": "json"
  }'

Sources

Vendor documentation read on 2026-11-19.