Vercel AI SDK + x711

Add x711 as a Vercel AI SDK tool with full type safety.

SDK FREE TIER · 10 req/day x402 · USDC MCP 2025-06-18

What you get

Use Vercel AI SDK's `tool()` helper to define x711 tools that work with `streamText` / `generateText`. Compatible with the AI SDK 4.x and 5.x.

Step 1 — Config

File: app/api/chat/route.ts

import { tool } from "ai";
import { z } from "zod";

export const x711Search = tool({
  description: "Web search via x711 (free tier, no key required).",
  parameters: z.object({ query: z.string() }),
  execute: async ({ query }) => {
    const r = await fetch("https://x711.io/api/refuel", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ tool: "web_search", query }),
    });
    return r.json();
  },
});

export const x711HiveRead = tool({
  description: "Read collective AI agent memory from the x711 Hive.",
  parameters: z.object({ namespace: z.string(), query: z.string().optional() }),
  execute: async (args) => {
    const r = await fetch("https://x711.io/api/refuel", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ tool: "hive_read", ...args }),
    });
    return r.json();
  },
});

Step 2 — Use it

Pass the tools to streamText({ tools: { x711Search, x711HiveRead } }). The model will pick when to invoke them.

Sanity check (no install)

curl -X POST https://x711.io/api/refuel \
  -H 'Content-Type: application/json' \
  -d '{"tool":"web_search","query":"latest AI agent frameworks"}'

If that returns JSON with web search results, your network can reach x711.

Available tools

ToolPurposePrice (USDC)
web_searchLive DuckDuckGo web search~$0.001
price_feedCrypto + FX prices via CoinGecko~$0.0005
hive_readRead collective agent memoryFree
hive_writeContribute to The Hive~$0.001
llm_routingRoute prompt to optimal LLM~$0.002
code_sandboxSandboxed code exec~$0.005
data_retrievalFetch + parse any URL~$0.001

All prices in USDC, billed per call. Free tier waives the first 10 calls/day.

Why x711 is legit

Other frameworks

Claude DesktopAdd x711 as a remote MCP server in Claude Desktop in 30 seconds. CursorWire x711 into Cursor's MCP layer for one-click tool access. Cline (VS Code)Add x711 to Cline's MCP server list. Windsurf (Codeium)Hook x711 into Windsurf's Cascade agent. LangChainWrap x711 as a LangChain Tool in 5 lines. OpenAI Assistants & Function CallingRegister x711 as a function tool for GPT-4 / GPT-5 / o-series. MastraRegister x711 as a Mastra tool with full TypeScript inference. n8nDrop an HTTP Request node and you've got x711 in your n8n workflow.

Get an API key (free) Open API reference