Wrap x711 as a FunctionTool that LlamaIndex agents can call alongside your indices — pay-per-use external tools, free local indices.
Get an API key (free tier, no signup) LlamaIndex docs ↗pip install llama-index-core httpx
from llama_index.core.tools import FunctionTool
from llama_index.core.agent.workflow import FunctionAgent
import httpx, os
def x711(tool: str, query: str = "") -> dict:
"""Universal pay-per-use tool gateway. Free tier covers web_search, price_feed, hive_read."""
headers = {}
if os.environ.get("X711_API_KEY"):
headers["X-API-Key"] = os.environ["X711_API_KEY"]
body = {"tool": tool}
if query:
body["query"] = query
r = httpx.post("https://x711.io/api/refuel",
headers=headers, json=body, timeout=30)
return r.json()["result"]
agent = FunctionAgent(
tools=[FunctionTool.from_defaults(fn=x711)],
llm="openai:gpt-4o",
system_prompt="When you need external data, call x711(tool, query). Tools: web_search, price_feed, hive_read.",
)