Docs

Meter an endpoint over HTTP.

Call /api/v1. Prepaid needs agent id + token; unpaid calls get a 402 Payment Required challenge. OpenAPI is live.

OpenAPI JSON → · Live five-beat demo → · Credential vault →

Install

Node 20+. Provider keys stay in server env. Browser vault (Settings) only holds operator/agent tokens for UI mutations.

# Keys in .env (gitignored) — server only
TAVILY_API_KEY=...
TINYFISH_API_KEY=...
METER_OPERATOR_KEY=...      # required for fund / invoice mutations in prod
# optional LLM — research path does not require it
AGENTROUTER_API_KEY=...
npm run dev

# Machine-readable surface
GET /api/v1/openapi.json
GET /api/v1/health
GET /api/v1/health?deep=1

Meter a route

Units × price is the pricing model. Prepaid debit happens before providers are called; provider failure refunds the debit.

# Fund sandbox subaccount (operator key when configured)
curl -X POST /api/v1/subaccounts \
  -H 'content-type: application/json' \
  -H 'X-Meter-Operator-Key: $METER_OPERATOR_KEY' \
  -d '{"id":"agent_b7f2","amount":5}'
# Response includes agentToken (shown once) — store it; only the hash is kept server-side

# Paid research (live Tavily + TinyFish)
curl '/api/v1/research?q=bnb+agent+os' \
  -H 'X-Meter-Agent-Id: agent_b7f2' \
  -H 'X-Meter-Agent-Token: $AGENT_TOKEN' \
  -H 'X-Meter-Payment: prepaid'

402 challenge

HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: <base64 PaymentRequired>
X-Meter-Endpoint: /research
X-Meter-Unit: query
X-Meter-Price: 0.02
X-Meter-Settle: prepaid|x402

# Body also includes paymentRequired.accepts[] with scheme + maxAmountRequired

Invoices

Issued from unbilled receipts on the shared ledger. Both agents see the same invoice id.

# Issue from unbilled receipts
POST /api/v1/invoices
{ "agentId": "agent_b7f2" }

# Example 201 response (fields from live ledger — ids are real)
{
  "id": "inv_…",
  "agentId": "agent_b7f2",
  "amount": 0.02,
  "calls": 1,
  "takeFee": 0.00018,
  "status": "open"
}

# Mark paid
POST /api/v1/invoices/inv_…/pay
Header: X-Meter-Operator-Key

Limit policy

# Read live utilization
GET /api/v1/limits

{
  "limits": [
    {
      "id": "lm_daily",
      "scope": "workspace",
      "cap": 20,
      "used": 0.02,
      "window": "utc-day",
      "action": "block"
    }
  ]
}

# Cap is enforced server-side on prepaid debit (default $20/UTC day).

Failure modes

LIMIT_WORKSPACE_DAILY / 429

Workspace daily cap hit. Debit blocked; audited on the ledger.

INSUFFICIENT_BALANCE / 402

Prepaid agent balance below call price — quote shows this before convert.

PAYMENT_REQUIRED / 402

Missing or invalid prepaid/x402 credentials before research runs.

UNAUTHORIZED / 401

Bad operator key or agent token hash mismatch.

PROVIDER_ERROR

Tavily/TinyFish failed after debit — prepaid amount is refunded.