Integration guide
apifare for Mastra
Give Mastra one prepaid key for every API it needs. There is no separate provider account or provider API key for eligible capabilities, and it all runs under hard caps and a kill switch.
1 · Get a key
Create an account at /start: email in, token out (shown once). Save the token somewhere safe.
2 · Add apifare to Mastra
In your Mastra project, connect with MCPClient from @mastra/mcp and give its tools to an agent. The token is read from the APIPAY_TOKEN environment variable and sent as an Authorization header.
npm install @mastra/mcp@latestimport { MCPClient } from '@mastra/mcp';
import { Agent } from '@mastra/core/agent';
const mcpClient = new MCPClient({
id: 'apifare',
servers: {
apifare: {
url: new URL('https://apifare.com/mcp'),
requestInit: {
headers: { Authorization: `Bearer ${process.env.APIPAY_TOKEN}` },
},
},
},
});
const agent = new Agent({
id: 'assistant',
name: 'Assistant',
instructions: 'Use the available MCP tools to answer questions.',
model: 'openai/gpt-5.6-sol',
tools: await mcpClient.listTools(),
});
const response = await agent.generate("What's the weather in London?");
console.log(response.text);
await mcpClient.disconnect();Set APIPAY_TOKEN, then run it. Mastra prefixes tool names with the server name, so the tools appear as apifare_….
3 · Try it
Ask your Mastra agent to search the web for X, then to fetch a URL, then what's the weather in London. Every call is debited from your balance and lands on your signed, exportable audit chain.
4 · Stay in control
Set daily or monthly caps per agent, and keep the kill switch ready. Both are checked before a call is dispatched. When the balance runs out, your agent gets an HTTP 402 with a top-up link it can hand you; the error catalog lists every stop and what unblocks it.
What Mastra can call
Everything on the key: search, filings, registries, weather, and ready-to-run tools, plus any provider key you vault yourself. Exact per-call prices are on /capabilities.
Config checked against Mastra's MCP docs on 2026-09-13. Markdown version: /integrations/mastra.md.
More integrations
Claude Code · Claude Desktop · Cursor · Windsurf · Zed · Cline · GitHub Copilot (VS Code) · OpenAI Codex CLI · Gemini CLI · Hermes Agent · Kimi CLI · Qwen Code · JetBrains (Junie) · Warp · Raycast · n8n · Dify · LangChain · LangGraph · CrewAI · Vercel AI SDK · LobeHub · AnythingLLM · OpenClaw · OpenAI Agents SDK · LlamaIndex · Goose · LibreChat
Model guides
Calling a model's API directly instead? Give it apifare tools with a plain tool loop: DeepSeek · Kimi · Qwen · OpenAI GPT · Gemini.