{"ok":true,"name":"energy-hub-agent-examples","status":"published_as_direct_download","purpose":"Example repository content for CrewAI, LangGraph, AutoGen-compatible functions and MCP clients.","base_url":"https://energy.halowerk.com","files":{"README.md":"# Netzhandwerker Energy Hub Agent Examples\n\nCopy-paste starter code for agents that call the Netzhandwerker Energy Research Hub.\n\nThe API is pay-per-call with x402. First call paid endpoints without a payment proof to receive HTTP 402 terms. Your wallet/client signs the payment, then retries with `PAYMENT-SIGNATURE`. `X-Payment` is accepted as a compatibility alias.\n\nDo not log or publish full payment proofs.\n\n## Endpoints\n\n- Discovery: https://energy.halowerk.com/.well-known/x402.json\n- OpenAPI: https://energy.halowerk.com/openapi.json\n- MCP: https://energy.halowerk.com/mcp\n- Free signal index: GET https://energy.halowerk.com/predict/negative-price\n- Buy exact signal: POST https://energy.halowerk.com/predict/negative-price\n- Main decision endpoint: POST https://energy.halowerk.com/energy/decision\n\n## Run\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\npython basic_x402_probe.py\npython mcp_client.py\n```\n\n## Files\n\n- `basic_x402_probe.py` probes a paid endpoint and prints the 402 terms.\n- `crewai_energy_tool.py` wraps the API as a CrewAI tool.\n- `langgraph_energy_node.py` wraps the API as a LangGraph node.\n- `autogen_energy_tool.py` provides an AutoGen-compatible async tool function.\n- `mcp_client.py` lists MCP tools and calls one paid tool.\n\nPayment is intentionally generated at runtime. Use your x402 wallet/client to create `PAYMENT-SIGNATURE` after receiving the 402 response.","requirements.txt":"requests>=2.32.0\ncrewai>=0.130.0\nlanggraph>=0.4.0\ntyping-extensions>=4.12.0",".env.example":"ENERGY_HUB_BASE_URL=https://energy.halowerk.com\n# PAYMENT_SIGNATURE is optional and should be produced by your x402 wallet/client.\nPAYMENT_SIGNATURE=","basic_x402_probe.py":"import os\nimport requests\n\nBASE = os.getenv(\"ENERGY_HUB_BASE_URL\", \"https://energy.halowerk.com\")\nBODY = {\"goal\": \"minimize_cost\", \"device\": \"ev\", \"location\": \"Germany\", \"duration_hours\": 4}\n\nheaders = {\"Content-Type\": \"application/json\"}\nif os.getenv(\"PAYMENT_SIGNATURE\"):\n    headers[\"PAYMENT-SIGNATURE\"] = os.environ[\"PAYMENT_SIGNATURE\"]\n\nr = requests.post(f\"{BASE}/energy/decision\", json=BODY, headers=headers, timeout=20)\nprint(\"status:\", r.status_code)\nprint(r.text[:2000])\n\nif r.status_code == 402:\n    print(\"Create PAYMENT-SIGNATURE with your x402 wallet/client, then retry the same request.\")","crewai_energy_tool.py":"import os\nimport requests\nfrom crewai.tools import tool\n\nBASE = os.getenv(\"ENERGY_HUB_BASE_URL\", \"https://energy.halowerk.com\")\n\n@tool(\"energy_hub_decision\")\ndef energy_hub_decision(goal: str, location: str = \"DE\") -> str:\n    \"\"\"Return German/EU energy decision context from the Energy Research Hub.\"\"\"\n    r = requests.post(f\"{BASE}/energy/decision\", json={\"goal\": goal, \"location\": location}, timeout=20)\n    if r.status_code == 402:\n        return \"Payment required. Send the 402 terms to your x402 wallet/client and retry with PAYMENT-SIGNATURE.\"\n    r.raise_for_status()\n    return r.text","langgraph_energy_node.py":"import os\nimport requests\nfrom typing_extensions import TypedDict\nfrom langgraph.graph import StateGraph, END\n\nBASE = os.getenv(\"ENERGY_HUB_BASE_URL\", \"https://energy.halowerk.com\")\n\nclass State(TypedDict):\n    goal: str\n    location: str\n    result: str\n\ndef call_energy_hub(state: State):\n    body = {\"goal\": state[\"goal\"], \"location\": state.get(\"location\", \"DE\")}\n    r = requests.post(f\"{BASE}/energy/decision\", json=body, timeout=20)\n    if r.status_code == 402:\n        return {\"result\": \"HTTP 402 received. Pay with x402 and retry the same call.\"}\n    r.raise_for_status()\n    return {\"result\": r.text}\n\ngraph = StateGraph(State)\ngraph.add_node(\"energy_hub\", call_energy_hub)\ngraph.set_entry_point(\"energy_hub\")\ngraph.add_edge(\"energy_hub\", END)\napp = graph.compile()","autogen_energy_tool.py":"import os\nimport requests\n\nBASE = os.getenv(\"ENERGY_HUB_BASE_URL\", \"https://energy.halowerk.com\")\n\nasync def energy_hub_tool(goal: str, location: str = \"DE\") -> str:\n    \"\"\"Register this function as a callable tool in your AutoGen agent/runtime.\"\"\"\n    r = requests.post(f\"{BASE}/energy/decision\", json={\"goal\": goal, \"location\": location}, timeout=20)\n    if r.status_code == 402:\n        return \"Payment required. Forward the 402 body to an x402-capable wallet client.\"\n    r.raise_for_status()\n    return r.text","mcp_client.py":"import os\nimport requests\n\nBASE = os.getenv(\"ENERGY_HUB_BASE_URL\", \"https://energy.halowerk.com\")\n\nlist_tools = {\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools/list\", \"params\": {}}\nprint(requests.post(f\"{BASE}/mcp\", json=list_tools, timeout=20).json())\n\ncall_tool = {\n    \"jsonrpc\": \"2.0\",\n    \"id\": 2,\n    \"method\": \"tools/call\",\n    \"params\": {\n        \"name\": \"energy_decision\",\n        \"arguments\": {\"goal\": \"minimize_cost\", \"device\": \"ev\", \"location\": \"Germany\", \"duration_hours\": 4}\n    }\n}\nprint(requests.post(f\"{BASE}/mcp\", json=call_tool, timeout=20).json())"},"suggested_repository_description":"Agent examples for x402-paid German/EU energy intelligence on Base USDC.","archive_url":"https://energy.halowerk.com/downloads/energy-hub-agent-examples.zip","publish_note":"The complete integration pack is published as a direct ZIP download from the canonical service domain."}