All workflows

Agent Run Cost Audit — Repeated Paid Calls & Budget Leaks

Analyze up to 250 caller-supplied billed agent tool events to locate duplicate idempotency keys, failures, run-budget overruns and expensive tools. Returns grouped evidence and possible redundant spend, explicitly NOT verified refunds or recovered money.

4 credits per call · $0.035 USDC with x402

Sample input

{
  "policy": {
    "max_run_usd": 0.06
  },
  "events": [
    {
      "run_id": "research-1",
      "tool": "web_extract",
      "cost_usd": 0.04,
      "status": "success",
      "idempotency_key": "page-123"
    },
    {
      "run_id": "research-1",
      "tool": "web_extract",
      "cost_usd": 0.04,
      "status": "success",
      "idempotency_key": "page-123"
    }
  ]
}

Worked sample output

{
  "ok": true,
  "mode": "agent-run-cost-audit",
  "event_count": 2,
  "observed_billed_usd": 0.08,
  "failed_events": 0,
  "repeat_idempotency_key_events": 1,
  "potential_duplicate_charges_usd": 0.04,
  "over_caller_budget": true,
  "budget_usd": 0.06,
  "observed_budget_overage_usd": 0.02,
  "expensive_tools": [
    {
      "tool": "web_extract",
      "calls": 2,
      "failed_calls": 0,
      "billed_usd": 0.08,
      "input_tokens": 0,
      "output_tokens": 0
    }
  ],
  "repeat_groups": [
    {
      "run_id": "research-1",
      "tool": "web_extract",
      "idempotency_key_hash": "106e9867be80f5c8",
      "calls": 2,
      "successful": 2,
      "potential_duplicate_charges_usd": 0.04
    }
  ],
  "input_sha256": "5af9246f61ffec6e14ee186d7c4f9f4898317d6710cdd6343ce834dd520761c8",
  "recommendations": [
    "Review same-run repeated idempotency keys; consider caching or idempotent deduplication.",
    "Enforce a hard per-run budget before future buyer-authorized calls."
  ],
  "limitations": [
    "Amounts, statuses and token counts are caller-supplied, not settlement-verified.",
    "Possible duplicate charges are not independently proven waste, refunds or savings.",
    "No invented token pricing or inferred buyer intent; no API calls are performed."
  ],
  "charged_downstream": false
}

Worked example using published sample data only. Own-data execution is paid.

Connect in curl

Set BOUNTY_API_KEY privately after your payment is verified. Change the retry key for each new logical request.

curl 'https://bounty-engineer-x402-prod.onrender.com/v1/prepaid/agent-run-cost-audit' \
  -H "Authorization: Bearer $BOUNTY_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: workflow-request-001' \
  -H 'X-Max-Credits: 4' \
  --data '{"policy":{"max_run_usd":0.06},"events":[{"run_id":"research-1","tool":"web_extract","cost_usd":0.04,"status":"success","idempotency_key":"page-123"},{"run_id":"research-1","tool":"web_extract","cost_usd":0.04,"status":"success","idempotency_key":"page-123"}]}'

Connect in n8n

Download the inactive n8n template. Import it, configure the private Header Auth credential, inspect the sample and run it manually. A new execution creates a new billable request; there is no automatic schedule.

Use an HTTP POST to https://bounty-engineer-x402-prod.onrender.com/v1/prepaid/agent-run-cost-audit. Send JSON and these headers; store the Bearer token as a private credential.

{
  "method": "POST",
  "headers": {
    "Authorization": "Bearer YOUR_PRIVATE_API_KEY",
    "Content-Type": "application/json",
    "Idempotency-Key": "UNIQUE_PER_LOGICAL_REQUEST",
    "X-Max-Credits": "4"
  },
  "body": {
    "policy": {
      "max_run_usd": 0.06
    },
    "events": [
      {
        "run_id": "research-1",
        "tool": "web_extract",
        "cost_usd": 0.04,
        "status": "success",
        "idempotency_key": "page-123"
      },
      {
        "run_id": "research-1",
        "tool": "web_extract",
        "cost_usd": 0.04,
        "status": "success",
        "idempotency_key": "page-123"
      }
    ]
  }
}

Reuse a retry key only for the same input. Failed execution returns reserved credits. Full integration and recovery guide · Machine-readable recipe