Skip to main content

Signatures

Building an ImageInput

The constructors are exported as ImageInputs, plural. Every other SDK names this singular, so copied examples will not resolve.

From the image picker

base64 avoids a filesystem round trip, which matters on iOS where the picker hands you a sandboxed URI.

From the camera

Throttle it. A VLM pass costs far more than a camera frame interval, so run one at a time and drop frames that arrive while a pass is in flight. Without the inFlight guard the queue grows until the app runs out of memory.

Streaming

Buffer these on an interval rather than calling setState per token.

Options

vlm takes the same LlmOptions as llm, so maxOutputTokens, temperature, and systemPrompt all apply. Cap the output: a caption does not need 300 tokens.

Models

VLM runs on the llama.cpp backend, so the model must be a GGUF vision model with its projector. Install @runanywhere/llamacpp and pick a VLM entry from the catalog. Vision models are larger than text models of the same parameter count, because the projector ships alongside. Check the download size before offering one on cellular.