Skip to main content
The Usage API is a read-only endpoint that exposes aggregated usage data for a developer application. It is backed by OpenMeter (OPENMETER_URL is required) — all responses include "source": "openmeter". It is designed for billing dashboards, cost analytics, per-user attribution, and pipeline/model breakdown workflows. All monetary values are expressed in wei as decimal strings, with USD micro equivalents available via include=retail.

Authentication

Two auth modes are accepted. The tenant boundary is enforced identically in both: the clientId in the URL path must match the authenticated principal’s app. HTTP Basic auth with your M2M credentials:
No additional scope is required beyond possessing valid M2M credentials — the endpoint only returns data for the authenticated client’s own app.

Provider dashboard session

A logged-in provider session whose user is the app’s owner, a platform admin, or a providerAdmins team member may call the endpoint without Basic auth.
Requests that satisfy neither auth mode, or whose authenticated principal does not match the path clientId, receive 404 Not Found. The endpoint deliberately does not distinguish “unauthenticated” from “not found” to avoid leaking app existence.

Endpoint

Path parameters

Query parameters

All query parameters are optional. Date format: Date.parse-compatible strings are accepted (e.g. 2026-01-01T00:00:00.000Z or 2026-01-01). Invalid values return 400 Bad Request. userId vs externalUserId: The userId parameter accepts the internal PymtHouse user id (endUserId), not your system’s externalUserId. Resolve an externalUserId to an endUserId via a prior groupBy=user response.

groupBy values

Response

200 OK

Response fields

totalFeeWei and feeWei are decimal strings, not numbers. They can exceed Number.MAX_SAFE_INTEGER. Always parse them with a BigInt-capable library (e.g. BigInt(feeWei) in JavaScript, viem’s formatEther for display).

The "unknown" bucket

Usage records without a resolvable userId are grouped under endUserId: "unknown" rather than silently dropped. This guarantees that totals.requestCount always equals the sum of byUser[].requestCount (including the "unknown" bucket) when groupBy=user is requested.

Usage balance

Check a user’s remaining entitlement balance before allowing access:
Response:
See Allowances for granting additional balance.

Examples

App-level totals (all time)

Per-user breakdown

Pipeline/model breakdown

Pipeline/model breakdown with retail estimates

Month-to-date window

Usage balance for a user

Filter to a single gateway request

Format wei as ETH in a shell script

SDK helper: usage by external user

Error responses

Security boundaries

  • Tenant isolation is enforced by matching the authenticated client’s app to the path clientId. A valid credential for a different app returns 404.
  • Provider sessions must be the app owner, a platform admin, or a recorded providerAdmins team member.
  • No secrets, signer material, per-request payloads, or customer PII are returned.
  • Confidential client secrets must stay server-side. Do not call this endpoint from the browser with Basic auth.

Key design decisions

  1. OpenMeter-authoritative. All usage reads come from OpenMeter meters (network_fee_usd_micros, signed_ticket_count). The "source": "openmeter" field is always present. Allowance balance reads use OpenMeter entitlement APIs, never Postgres.
  2. pipeline_model grouping from billing events. The groupBy=pipeline_model dimension aggregates from validated usage_billing_events rows — records that have a full pipeline + modelId constraint from the gateway payment envelope. Records without this constraint appear only in totals.
  3. Async metering. Signing hot-path performance is not impacted by metering writes. go-livepeer emits events to Kafka; the OpenMeter collector ingests them asynchronously.
  4. 404 for all auth and tenant-mismatch failures. Collapsing 401, 403, and “wrong app” into 404 prevents enumeration of valid client_ids.
  5. Retail estimates are opt-in. include=retail triggers retail rate computation from the active plan’s rate cards. Authoritative invoicing remains OpenMeter after plan sync.

Implementation tasks

  • Parse totalFeeWei and feeWei with BigInt before any arithmetic.
  • When displaying fees in your dashboard, convert from wei using a safe formatter (e.g. viem’s formatEther).
  • For reconciliation workflows, always supply explicit startDate/endDate bounds.
  • Use groupBy=pipeline_model to build per-pipeline attribution dashboards. Only requests with full pipeline + modelId constraints appear in this dimension.
  • Check getUsageBalance() (or GET .../usage/balance) before allowing user actions that consume entitlement.
  • Rotate M2M client secrets periodically via the credentials endpoint.