"""let your AI agent pay for its own tools — x711.io""" from crewai import Agent, Task, Crew from crewai_tools import tool import requests X711_KEY = "YOUR_X711_API_KEY" # free at x711.io/go @tool("x711_tool_call") def x711(tool_name: str, **kwargs) -> dict: """Call any x711 tool — payment handled automatically via x402.""" r = requests.post("https://x711.io/api/refuel", json={"tool": tool_name, **kwargs}, headers={"X-API-Key": X711_KEY}, timeout=10) return r.json() researcher = Agent(role="researcher", goal="answer questions with real data", backstory="An agent that pays for its own tool calls via x711.", tools=[x711], verbose=False) task = Task(description="Get the current ETH price", expected_output="Current ETH/USD price", agent=researcher) result = Crew(agents=[researcher], tasks=[task]).kickoff() print(result) # → Agent autonomously called x711 price_feed and paid $0.01 USDC from its balance