chat/completions, so
authentication, billing, and metering behave identically.
Authentication follows the same tiers as the REST API. See
Authentication and Rate Limits.
Tools
The server exposes one read tool per modality plus a model-discovery tool. Everyread_* tool takes a url and returns the extracted text.
url
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.
response_format
response_format selects how the result is serialized:
- The native form (
markdownfor documents,textfor audio and video) returns a plain string. jsonreturns the structured envelope.
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:
Errors
A rejected or unsupported model returns a clean, actionable message plus a next step (for example, “call thelist_models tool”) rather than a raw error
envelope, so the agent can recover on its own.
Page selection with pages
read_document accepts a pages argument to read only specific PDF pages
instead of the whole document, saving cost and latency.
- Pages are 0-indexed. Pass a list whose items are single page indices and/or
[start, stop]half-open ranges (numpy-style:startinclusive,stopexclusive). Negative indices count from the end. - Only the selected pages are rasterized and read. They are re-numbered from 0 in the response.
Page selection is specific to the
read_document MCP tool. The REST
chat/completions API reads
every page (up to document_max_pages).Video encoding with encoder
read_video encodes a video into image(s) before dispatch so image-only models
can read it. Control this with encoder and encoder_params:
encoderdefaults tomosaic(sampled keyframes tiled into a single grid image).framesandkeyframesare also available.encoder_paramstunes the encoder (for exampletile_cols,tile_rows,num_frames).
video_encoder and video_encoder_params.
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 tools above 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.End-to-end example
Once connected, the agent calls the read tools on its own. Ask a question about a document and it will fetch, OCR, and answer, all through the gateway: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.
Explore the server
Point the MCP Inspector at the gateway to list tools and call them interactively before wiring up an agent:https://gateway.vlm.run/mcp, and add an Authorization: Bearer <VLMRUN_API_KEY>
header. Start with list_models to see what the gateway currently serves and
which read tool each model fits.
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.