Skip to main content
The VLM Run Gateway exposes a Model Context Protocol (MCP) server so any MCP-aware agent framework (Pydantic AI, LangChain, Mastra, OpenAI Agents SDK, Claude Code) can read documents, audio, and video through the same gateway pipeline as the REST API. It is a FastMCP server served over Streamable HTTP, and it re-enters the same ingress as 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. Every read_* 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 (markdown for documents, text for audio and video) returns a plain string.
  • json returns 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 the list_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: start inclusive, stop exclusive). 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:
  • encoder defaults to mosaic (sampled keyframes tiled into a single grid image). frames and keyframes are also available.
  • encoder_params tunes the encoder (for example tile_cols, tile_rows, num_frames).
On the REST API these map to video_encoder and video_encoder_params.

Connect an agent

Every MCP-aware client connects the same way: point it at https://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:
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:
The agent picks 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:
Set the transport to Streamable HTTP, the URL to 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.

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.