Skip to main content
Orion-2 works with Mastra as a visual agent harness. Point a Mastra agent at the VLM Run OpenAI-compatible endpoint, enable hybrid tool execution, and Mastra can call your local tools while Orion-2 runs vision and document work through its code-execution sandbox.

What works

With Mastra as the orchestrator and Orion-2 as the model, the following are supported: Hybrid mode is required so Mastra executes client tools locally while Orion-2 keeps server tools such as execute_code.

Prerequisites

  • A VLM Run API key from the API Keys page
  • Node.js with @mastra/core, @ai-sdk/openai-compatible, and zod

Configure Mastra with Orion-2

Use the OpenAI-compatible chat endpoint and an Orion-2 model id:
Pass hybrid tool execution on each generate or stream call:
Use model: "vlmrun-orion-2:auto" for the default Orion-2 tier. Other tiers and pinned variants are listed in Code Execution.

Verified scenarios

These scenarios exercise the Mastra + Orion-2 harness end to end.

1. Client tool calling

Mastra receives Orion-2 tool calls and runs them locally.
Expected: get_weather runs once in Mastra, and the final text includes the tool result (for example 72 / sunny).

2. Server-side code execution

Orion-2 writes and runs Python in its sandbox. Mastra does not need a local code tool.
Expected: final text includes 720, with no client tool calls.

3. Document understanding with code execution

Orion-2 can summarize and extract from PDFs and images through execute_code while Mastra remains the orchestrator. Attach the document using the same OpenAI-compatible input shapes as the Agents API (for example file_url / image_url).
Expected: Orion-2 uses execute_code against the document and returns invoice fields (vendor, number, date, total). Client tools are not used for this path.

Hybrid tool execution

Always send a session_id (UUID) with hybrid requests so Orion-2 can keep workspace and artifact context for the turn. See Artifacts for retrieving generated files.

Streaming

Streaming works the same way as generate:

Code Execution

Orion-2 sandbox, libraries, and model variants

OpenAI Compatibility

Base URL, API key, and chat completions shape

Agent Inputs

Images, documents, and toolset selection

Gateway MCP + Mastra

Different path: load VLM Run tools into Mastra via MCP