chat/completions, so
authentication, billing, and metering behave identically.
Authentication follows the same tiers as the REST API. See
Authentication and Rate Limits.
What is MCP?
MCP is an open standard for connecting AI applications to external systems: data sources, tools, and workflows. A server publishes a typed catalog of its tools and their arguments, and can declare the shape of what each one returns, so a client discovers them at run time instead of carrying a hand-written integration per capability. Clients as different as Claude, ChatGPT, VS Code, and Cursor all speak it, so one server reaches all of them. Here the catalog is five tools. Point any MCP client athttps://gateway.vlm.run/mcp and those five sit alongside the agent’s own. The
model hands one of them a URL, gets text back, and reasons over it. You write no
extraction schema and no glue code.
When to use MCP
Use the MCP server when you want an agent to read a document, an image, or a video, then answer questions about it or act on the text it returns. It is the recommended way to reach the Gateway: the agent discovers the read tools, picks the one a task calls for, and invokes it with a URL, so nothing in your code has to know which capability a given file needs. It fits wherever an agent is already in the loop:- Answering questions about a scanned invoice or contract, where
read_documentreturns Markdown with the tables intact andpagesnarrows a long file to the part that matters. - Reading a chart, a diagram, or a UI screenshot with
read_image, where the answer is what the picture shows rather than the text printed on it. - Summarizing a screen recording, or pulling its on-screen text, with
read_video. - Checking
list_modelsfirst, so the agent runs a model the Gateway serves today instead of one pinned in your code.
Quickstart
Start here to inspect the server’s response 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 the agent to parse a document
read_document on its own.3
Inspect the response
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: one URL, one bearer header. Set your key once:- Hosted HTTP
- Pydantic AI
- LangChain
- Mastra
- OpenAI Agents SDK
- Claude Code
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
One read tool per modality, plus a model-discovery tool. Everyread_* tool
takes a url, returns the extracted text, and carries a model argument 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 read_* tool takes json_mode. Left false, it 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, the tool returns the same text blocks as the REST API: one
A page that failed OCR is self-closing, with
<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.
Fitting a tool is not the same as being selectable through it: outside
read_document, each tool’s model argument accepts a single id, so treat
tools as what the gateway can route rather than as a menu.
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 when the method’s full payload only
arrives parsed under json_mode. A method that carries document_markdown or
text_extraction still returns that text as a plain string.
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 completes the handshake, 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.