OCRRouter

Qianfan OCR API docs

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

Overview

Qianfan-OCR is a 4B end-to-end document parsing model from Baidu's Qianfan team, Apache-2.0, with a Qwen3-4B language model.

OCRRouter calls it through AIHubMix without thinking mode and returns its Markdown per page. It gives no positions or scores.

Price and limits

Model ID
baidu/qianfan-ocr
Price
2 credits / page ($2 per 1,000 pages)
Max pages per request
200
Inputs
PDF (rendered to page images); PNG, JPEG and other images AIHubMix accepts as image_url
Languages
Chinese, English and more (192 languages per the model card)
Positions (bbox)
No, text only
  • Up to 200 pages per job in OCRRouter
  • Text only: no layout blocks, bbox or confidence
  • Thinking mode (layout boxes and reading order) is not used

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

Gateway
AIHubMix, OpenAI-compatible
Endpoint
POST https://aihubmix.com/v1/chat/completions
Upstream model
"qianfan-ocr"
Request
One user message per page: the page as a base64 data URL in an image_url part, then the prompt as a text part
PDFs
Rendered to PNG at 150 dpi with poppler pdftoppm, one request per page, 4 pages at a time
Images
Sent as is, one request

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.

model
"qianfan-ocr"
prompt
"Convert this document to Markdown."
temperature
0
PDF render
150 dpi PNG
Concurrency
4 pages at a time
Other parameters
None sent (no max_tokens, no stream, no response_format)
Client options
None. Callers cannot pass model options; OCRRouter fixes the request above.

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.

What OCRRouter receives (AIHubMix chat completion)

AIHubMix exposes qianfan-ocr through its OpenAI-compatible POST /v1/chat/completions endpoint. OCRRouter sends one request per page image and gets back a standard chat completion object. Field meanings from OpenAI's chat completion object reference and our test call on 2026-11-19; the field list below is every field in that response.

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

idstring
Unique identifier for the chat completion.Example: "as-yw2evcpvby"
objectstring
Object type, always "chat.completion".Example: "chat.completion"
createdinteger
Unix timestamp in seconds when the completion was created.Example: 1795106680
modelstring
Model that produced the completion.Example: "qianfan-ocr"
choices[]array, read by OCRRouter
List of completion choices. OCRRouter sends no n parameter, so there is one.
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 or null, read by OCRRouter
Text the model generated. For these OCR models this is the page transcription.Example: "## Quarterly Report\n\nSales grew 12 percent in the third quar..."
choices[].message.refusalstring or null
Refusal message if the model refused; null otherwise.Example: null
choices[].finish_reasonstring
Why generation stopped: "stop" for a natural end, "length" when the token limit was hit.Example: "stop"
choices[].logprobsobject or null
Log probabilities, only when requested. OCRRouter does not request them.Example: null
usage.prompt_tokensinteger
Tokens in the prompt, including the image.Example: 785
usage.completion_tokensinteger
Tokens in the generated output.Example: 95
usage.total_tokensinteger
Prompt plus completion tokens. AIHubMix bills per token.Example: 880

Real response captured 2026-11-19 by OCRRouter with the exact request shown under Options, on an 800x420 PNG with a heading, a paragraph and a 3x3 table. Nothing edited.

{"id": "as-yw2evcpvby","model": "qianfan-ocr","object": "chat.completion","created": 1795106680,"choices": [{"index": 0,"finish_reason": "stop","logprobs": null,"message": {"role": "assistant","content": "## Quarterly Report\n\nSales grew 12 percent in t…","refusal": null}}],"usage": {"prompt_tokens": 785,"completion_tokens": 95,"total_tokens": 880}}

Qianfan-OCR native output

The model returns one decoded string. Field meanings from the Qianfan-OCR model card (README.md), Baidu's official skill reference references/document-parsing.md and our test call on 2026-11-19. That reference defines the parsing output: Markdown only, tables as HTML wrapped in <table>, formulas as $...$ and $$...$$, images as ![label](<box>[[x1, y1, x2, y2]]</box>) with labels image, chart or seal and coordinates on a 0 to 1000 scale, and --- Page N --- between pages when several images go in one request. With thinking enabled the output is <think>...</think> layout analysis and then the Markdown (references/document-parsing-with-layout.md). OCRRouter sends "Convert this document to Markdown." without thinking, one page per request; our test got a ## heading, a paragraph and an HTML table, no image boxes and no think block.

Source: Qianfan-OCR skill references/document-parsing.md, retrieved 2026-11-19

message.contentstring, read by OCRRouter
Page transcription as Markdown. Tables are HTML <table> elements, formulas LaTeX.Example: "## Quarterly Report\n\nSales grew 12 percent..."
![label](<box>[[x1, y1, x2, y2]]</box>)Markdown image placeholder
Image, chart or seal region, corners on a 0 to 1000 scale of the page. Per Baidu's skill reference; not seen in our text-only test. OCRRouter passes it through as text.
<think>...</think>text span
Layout analysis written before the Markdown in thinking mode. OCRRouter does not enable thinking, so it does not appear.

The message.content string from the real response above, captured 2026-11-19.

## Quarterly Report

Sales grew 12 percent in the third quarter.

<table><tr><td>Region</td><td>Q2</td><td>Q3</td></tr><tr><td>North</td><td>120</td><td>134</td></tr><tr><td>South</td><td>98</td><td>110</td></tr></table>

How it maps to OCRRouter output

choices[0].message.content
Page text. A wrapping ```markdown fence is stripped.
HTML <table> in content
Rewritten as a GitHub-flavoured Markdown table (htmlTablesToMarkdown); the first row is the header
One response per page
pages[i] in OCRRouter output, in page order
Layout, bbox, confidence
Not returned. This model gives text only, so OCRRouter output has no layout blocks

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": "baidu/qianfan-ocr",
    "file_url": "https://example.com/invoice.pdf",
    "format": "json"
  }'

Sources

Vendor documentation read on 2026-11-19.