Add x711 as a Vercel AI SDK tool with full type safety.
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.
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();
},
});
Pass the tools to streamText({ tools: { x711Search, x711HiveRead } }). The model will pick when to invoke them.
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.
| Tool | Purpose | Price (USDC) |
|---|---|---|
web_search | Live DuckDuckGo web search | ~$0.001 |
price_feed | Crypto + FX prices via CoinGecko | ~$0.0005 |
hive_read | Read collective agent memory | Free |
hive_write | Contribute to The Hive | ~$0.001 |
llm_routing | Route prompt to optimal LLM | ~$0.002 |
code_sandbox | Sandboxed code exec | ~$0.005 |
data_retrieval | Fetch + parse any URL | ~$0.001 |
All prices in USDC, billed per call. Free tier waives the first 10 calls/day.
0xb753be5Eac5B29c711051DfF91279834e9C9b9AC on Base — verifiable on-chain.