Give a Mastra agent every BlockRun model through an OpenAI-compatible provider
Point an OpenAI-compatible AI SDK provider at the blockrun-litellm sidecar and a Mastra agent runs on any catalog model, with typed tools for images and search.
How it works
Mastra builds agents, workflows and tools on the Vercel AI SDK's model abstraction, so anything that yields an AI SDK model works as an agent's brain. An OpenAI-compatible provider created with a base URL pointing at the blockrun-litellm sidecar does, and the sidecar signs an x402 payment for each request from the server's wallet.
For tools, the @blockrun/llm TypeScript client is the shorter path: a Mastra tool that generates an image, runs a neural search or reads a prediction market is a typed call on the client, paid the same way. Agents and tools can mix — a frontier model for the agent, cheap calls for the tools.
Behind it is the BlockRun catalog: 78 chat models plus image, video, music and speech generation, search, market data and multi-chain RPC, priced per call. 6 open-weight models are free and need no wallet.
Setup
1. Start the sidecar
pip install 'blockrun-litellm[proxy]'\nexport BLOCKRUN_WALLET_KEY=0x<base wallet key>\nblockrun-litellm-proxy --port 40012. An OpenAI-compatible provider for the agent
import { createOpenAI } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
const blockrun = createOpenAI({ baseURL: "http://127.0.0.1:4001/v1", apiKey: "dummy" });
export const agent = new Agent({ name: "researcher", instructions: "...", model: blockrun("openai/gpt-5.4") });Questions
- How do I use BlockRun models in a Mastra agent?
- Create an OpenAI-compatible AI SDK provider with the sidecar as its base URL and hand agent.model any catalog id, as in the setup. Mastra's agent loop, memory and workflows are unchanged.
- Can a Mastra tool call BlockRun for images or search?
- Yes. Call the @blockrun/llm client inside the tool's execute function; image, video, speech, neural search and market data are typed calls on the client.
- Does streaming work through the sidecar?
- Yes. The sidecar passes server-sent events through unchanged, so Mastra's streaming responses behave as they do against any OpenAI-compatible endpoint.
- Can different agents in one Mastra app use different models?
- Yes — each agent names its own catalog id through the same provider, and each call is priced for the model it used.
- Mastra on BlockRun vs Mastra with provider keys?
- Same framework. One wallet on the server replaces a key per provider, and a model switch is a string change rather than a new credential.
- What does a call cost through this integration?
- The provider's published token rate with no markup on tokens, plus a flat per-call fee, quoted in dollars in the 402 before the call runs. Image, video and speech calls are priced per unit the same way. The live rate card is on the models page.
- Do I need an API key or an account?
- No. On the pay-per-call door the request carries its own payment from a wallet the SDK or MCP server creates on first run; there is nothing to sign up for. Teams that prefer keys get an API key and a monthly invoice instead.
Two ways to run this
Get an API key
Sign in, get a key, and call the same endpoints with usage billed to your account. For teams that want one invoice instead of one wallet.
Get an API keyOr let your agent pay per call, in USDC
No account, no API key. Three steps, and the last one is the request this page is about.
- Point your agent at BlockRun
Install ClawRouter, or add the BlockRun MCP server to Claude Code, Cursor, Codex or OpenClaw. Any OpenAI-compatible client works too — change the base URL, nothing else.
curl -fsSL https://blockrun.ai/ClawRouter-update | bash - Fund a wallet with USDC
Send USDC to a wallet on Base or Solana. There is no account to create and no API key to issue: the wallet is the account, and it pays per call.
- Use BlockRun from Mastra
The first call returns HTTP 402 with the exact price, your agent signs it, and the answer comes back. Payment settles on-chain; nothing is charged if the call fails.
pip install 'blockrun-litellm[proxy]'\nexport BLOCKRUN_WALLET_KEY=0x<base wallet key>\nblockrun-litellm-proxy --port 4001
Explore everything on BlockRun
- GPT-6 Astra
- GPT-5.6 Sol
- GPT-5.6 Terra
- GPT-5.6 Luna
- GPT-5.6 Sol Pro
- GPT-5.6 Terra Pro
- GPT-5.6 Luna Pro
- GPT-5.5
- GPT-5.5 Pro
- ChatGPT Instant (GPT-5.5)
- GPT-5.4
- GPT-5.4 Pro
- GPT-5.1
- GPT-5.2
- GPT-5.4 Mini
- GPT-5 Mini
- GPT-5.4 Nano
- GPT-5.2 Pro
- GPT-5.3 Codex
- GPT-4.1
- GPT-4.1 Mini
- GPT-4.1 Nano
- GPT-4o
- GPT-4o Mini
- o1
- o3
- o3-mini
- o4-mini
- Claude Haiku 4.5
- Claude Sonnet 5
- All models →