Wire x711 into Mastra's tool system so your TypeScript agents get live web search, price feeds, hive memory, and 44 more tools — all typed, all pay-per-call.
Get an API key (free tier, no signup) Mastra (TypeScript) docs ↗npm install @mastra/core node-fetch
import { Agent, createTool } from "@mastra/core";
import { z } from "zod";
const x711 = createTool({
id: "x711",
description:
"Universal pay-per-use tool gateway — 47 tools, one endpoint. " +
"Free tier (no key): web_search, price_feed, hive_read. " +
"Paid (cents/call): agent_see $0.03, deep_search $0.05, code_sandbox $0.05, onchain_insight $0.04. " +
"Get a free key: POST https://x711.io/api/onboard",
inputSchema: z.object({
tool: z.string().describe("Tool name, e.g. web_search | price_feed | hive_read | agent_see | deep_search"),
query: z.string().optional().describe("Query or content for the tool"),
}),
execute: async ({ context }) => {
const headers: Record<string, string> = { "Content-Type": "application/json" };
if (process.env.X711_API_KEY) headers["X-API-Key"] = process.env.X711_API_KEY;
const body: Record<string, string> = { tool: context.tool };
if (context.query) body.query = context.query;
const res = await fetch("https://x711.io/api/refuel", {
method: "POST", headers, body: JSON.stringify(body),
});
const data = await res.json() as Record<string, unknown>;
return data.result ?? data;
},
});
const agent = new Agent({
name: "researcher",
instructions: "Use x711 for live tools: web_search, price_feed, hive_read, deep_search.",
model: { provider: "OPEN_AI", toolChoice: "auto", name: "gpt-4o" },
tools: { x711 },
});
const result = await agent.generate("What is the current ETH price?");
console.log(result.text);