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, andzod
Configure Mastra with Orion-2
Use the OpenAI-compatible chat endpoint and an Orion-2 model id: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.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.720, with no client tool calls.
3. Document understanding with code execution
Orion-2 can summarize and extract from PDFs and images throughexecute_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).
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:Related
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