chat/completions, so
authentication, billing, and metering behave identically.
Authentication follows the same tiers as the REST API. See
Authentication and Rate Limits.
Quickstart
Start here to see the server answer before you wire an agent to it.1
Add the server
npx @modelcontextprotocol/inspector, set the
transport to Streamable HTTP, and point it at the same URL.2
Ask for a document
read_document on its own. You write no extraction schema
and no glue code.3
Read what came back
read_* tool answers with text like this, plus the typed
ReadResult that carries the model that ran and its cost.Connect an agent
Every MCP-aware client connects the same way: point it athttps://gateway.vlm.run/mcp with a bearer token, and the four read
tools plus list_models show up alongside the agent’s other tools. Set
your key once:
- Pydantic AI
- LangChain
- Mastra
- OpenAI Agents SDK
- Claude Code
native=False (the default) runs the MCP client locally: Pydantic AI
connects to the gateway and calls the tools. native=True advertises the
URL to the model provider (OpenAI Responses, Anthropic, xAI) so the provider
connects to the server directly.read_document, receives the Markdown OCR plus the ReadResult
payload (including the model that ran and its cost), and reasons over the text to
answer, no extraction schema or glue code required.
The initialize handshake returns server instructions that name each tool and
its use, and most clients inject them as the system message. When your client
does that, keep your own steering in the user turn, because a second system
message breaks strict OpenAI-compatible endpoints.
Tools
The server exposes one read tool per modality plus a model-discovery tool. Everyread_* tool takes a url, returns the extracted text, and accepts a model
plus per-modality knobs.
read_document and read_image split by intent, not by file type. Both accept a
JPEG or a PNG. Use read_document for the text printed on a page, which it OCRs
into Markdown with headings, lists, and tables preserved. Use read_image for what a
picture depicts, such as a photo, a chart, or a screenshot.
url is always an http(s) URL, a data: URI, or a bare base64 string. It is
never a local filesystem path. Host the file or inline it as base64 before
calling a read tool.
Every tool takes json_mode. Left false, a tool returns the native form as a
plain string (Markdown for documents, text for audio and video); true returns
the structured envelope, parsed under data.
Pick a method by what you need
Everyread_document method returns a different thing from the same page.
list_models tags each one with a capability, so you can choose without reading
a model card. Ask for the capability, then use the method that carries it.
For example,
rednote-hilab/dots.mocr carries document_markdown on markdown
and text_citations on parse_layout, and paddleocr/pp-ocrv6 carries
text_citations on ocr and text_extraction on text.
read_document
OCR a PDF or image into clean Markdown (or structured JSON). Use it for invoices,
forms, reports, slide decks, screenshots, and scanned pages.
Page Selection
[0, 2, 4]reads pages 0, 2, and 4[[0, 3]]reads pages 0-2[[0, 3], [5, 7], -1]reads pages 0, 1, 2, 5, 6 and the last page
One call reads at most 128 pages. For a longer document, call the tool once per
range and combine the results. The error names the exact ranges to use.
JSON Mode
- json_mode: false
- json_mode: true
Left unset, A page that failed OCR is self-closing, with
json_mode returns the same text blocks as the REST API: one
<document> block per PDF, wrapping one <page> block per page, in reading order.status="error" and no body. A single
image returns the Markdown alone, with no wrapper.read_image
Send one still image to a vision-language model and get its answer back. Use it for
photos, charts, diagrams, product shots, and UI screenshots, where the value is in
what the picture depicts.
The
read_image menu carries no OCR model on purpose. An image whose value is its
printed text belongs to read_document, which accepts an image URL and returns
the Markdown alone, with no wrapper, for a single image.read_audio
Transcribe a speech audio file (wav, mp3, m4a, flac, ogg, …) into text.
read_video
Describe or transcribe a video. Frames are sampled and encoded into image(s) so
image-capable models can read them, then a vision-language model produces the text.
On the REST API,
encoder and encoder_params map to
video_encoder and video_encoder_params.
list_models
List the models the gateway currently serves and which read tool each one fits.
Call it before passing a non-default model.
Each entry is
{id, modality, tool, tools, aliases, methods, default_method, method_details}. Pass id verbatim as the model argument to the matching
tool. tools lists every read tool the model fits, because one model can serve
several: a Qwen vision model fits read_image and read_video. modality and
tool name the primary one, and a modality filter matches on any fitting tool.
method_details is the per-method answer to “what do I get back”: one record per
method, with its capabilities, default: true on the model’s
default, and requires_json_mode: true on every method that carries more than
plain text_extraction.
Return shape (ReadResult)
Each read_* tool returns the clean text as the tool’s content and a typed
structured payload, so an agent gets usable text directly while still being able
to read which model actually ran and what it cost:
Very large output is trimmed before it reaches the agent so one document cannot
flood the context: past roughly 60,000 characters the text is cut and a
[truncated: …] note is appended telling the agent to narrow the request (for
example, fewer pages) or process in sections.
Errors
An error names the next step, so the agent recovers on its own. A method the chosen model does not advertise is refused before the call, and the message lists the methods it does advertise:Call it without a framework
Three requests reach a tool over plain HTTP.initialize returns the
mcp-session-id header, notifications/initialized opens the session, and every
later request carries the header. Send
Accept: application/json, text/event-stream, because the reply is a
Server-Sent Events stream.
Related
Chat Completions API
The REST surface behind the same gateway pipeline.
List models
Query the live model catalog and capabilities.
Authentication
Bearer tokens, tiers, and anonymous access.
Multimodal Inputs
Content part types, document limits, and video knobs.