vlmrun gw chat runs an OCR or VLM model over one or more documents, images, or videos.
Inputs can be local paths, remote URLs, or a mix of both. See
gateway for shared options and configuration.
Response rule, with
the metering signals on the closing rule:
bbox_xywh and poly_xy are both normalized to the page, not pixels. Methods
that return prose rather than regions (markdown on zai-org/glm-ocr, say) put
the text straight in the <page> body with format="markdown".
The footer reads model, prompt / completion / total tokens, throughput, pages,
pages per second, latency, and cost. Segments drop out when the gateway does not
report them: tokens and throughput without usage, pages for non-paginated
replies, cost when none is returned. Token counts, pages and cost are
reproducible for a given document and DPI; throughput and latency vary. See
Pricing and Metering for the same signals.
Methods
Each model exposes one or more methods (ocr, detect, markdown) with a
default; vlmrun gw models <model> lists them. --method and --method-params
map to the gateway’s top-level method and method_params fields.
Video input
Video files and video URLs are sent asvideo_url content parts. Control frame
sampling with the gateway’s video_fps and video_max_frames fields, passed
through -e:
Extra completion kwargs
Forward extrachat.completions.create() kwargs as repeatable key=value pairs
(values are JSON-parsed). Known keys go through as real kwargs; unknown ones
route via extra_body to become top-level gateway request fields.
Streaming
gw chat streams by default: tokens print live, one chunk per page for
multi-page documents. -ns/--no-stream waits for the full reply and renders it
in a bordered panel instead.
JSON output vs JSON mode
Two different flags contain the word “json”, and they act on two different layers:-j replaces that output with an envelope of model, content, latency_s,
and usage, plus pages and pages_per_sec when the reply is paginated OCR
output:
usage is the gateway’s object passed through untouched: standard OpenAI
breakdown fields (often null for OCR models) plus the VLM Run cost
extension. Read usage.cost rather than recomputing from tokens.
Adding --json-mode gives JSON mode plus machine-readable metering, but the
result is double-encoded: content is a JSON string holding a JSON
document, so it needs a second parse (jq -r .content | jq .).
--response-format is the general form: text, json_object (alias json),
or a full object like '{"type":"json_schema", ...}'. --json-mode is exactly
--response-format json_object, and the two are mutually exclusive.
json_schema is a per-model capability (capabilities.supports_json_schema):
chat and frontier models constrain generation to it, while OCR and detection
models return a 400 capability_violation. Use json_object there.