Mastra + x711: pay-per-use tool APIs for TypeScript agents
Mastra is the TypeScript agent framework from the Gatsby team. x711 gives it real-time tools over HTTP — no SDK required, just fetch.
Get your key
curl -X POST https://x711.io/api/onboard -d '{"name":"mastra-agent"}' # → {"api_key":"x711_..."}
Enter fullscreen mode
Exit fullscreen mode
Define tools
import { createTool } from " @mastra/core/tools " ; import { z } from " zod " ;
const X711_KEY = process . env . X711_API_KEY ! ;
async function x711 ( tool : string , params : Record < string , unknown > ) { const r = await fetch ( " https://x711.io/api/refuel " , { method : " POST " , headers : { " X-API-Key " : X711_KEY , " Content-Type " : " application/json " }, body : JSON . stringify ({ tool , ... params }), }); return r . json (); }
export const webSearch = createTool ({ id : " web-search " , description : " Search the live web for real-time information " , inputSchema : z . object ({ query : z .…