API reference

Usage summary

Return usage periods and account billing counters. Review Diffio API behavior, response fields, setup details, and production workflows.

Read API usage period totals and account-level billing counters.

POST/v1/usage/summaryPermissions: usage:read

Endpoint

HTTP request

https://api.diffio.ai/v1/usage/summary

Use POST with a JSON body.

Permissions

usage:read

API keys must be active.

Authentication

Send the API key on every request using one of the supported headers.

  • Authorization: Bearer <apiKey>
  • X-Api-Key: <apiKey>
  • Xi-Api-Key: <apiKey>

Request

Send an empty object for the authenticated key, or apiKeyId when an admin key reads another key on the same account.

Body fields

FieldTypeRequiredDescription
apiKeyIdstringNoOptional API key id to read. Non-admin keys can only read their own usage.
cURL
curl -X POST "https://api.diffio.ai/v1/usage/summary" \  -H "Authorization: Bearer $DIFFIO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "apiKeyId": "key_123"  }'

Response

Returns usage periods plus billing counters for the account.

Response fields

FieldTypeRequiredDescription
usageobjectYesUsage summary for the requested API key.
usage.apiKeyIdstringYesAPI key id whose usage was returned.
usage.periodsarrayYesUsage periods sorted by periodStart descending.
usage.periods[].periodIdstringYesUsage period id.
usage.periods[].reservedCentsnumberYesReserved usage cents for the period.
usage.periods[].finalizedCentsnumberYesFinalized usage cents for the period.
usage.periods[].totalCentsnumberYesTotal reserved and finalized cents for the period.
usage.periods[].modelSecondsobjectYesUsage seconds grouped by model key.
usage.periods[].modelCentsobjectYesUsage cents grouped by model key.
billingobjectYesAccount billing counters.
billing.billingPolicyobjectYesAccount billing policy.
billing.lifetimeListPriceCentsnumberYesLifetime list price usage in cents.
billing.lifetimeBillableCentsnumberYesLifetime billable usage in cents.
billing.unbilledCentsnumberYesCurrent unbilled cents on the account.
Successful response
{  "usage": {    "apiKeyId": "key_123",    "periods": [      {        "periodId": "period_2026_05",        "apiKeyId": "key_123",        "periodStart": "2026-05-01T00:00:00Z",        "periodEnd": "2026-06-01T00:00:00Z",        "reservedCents": 100,        "finalizedCents": 200,        "totalCents": 300,        "modelSeconds": {          "diffio-2": 120        },        "modelCents": {          "diffio-2": 300        }      }    ]  },  "billing": {    "billingPolicy": {      "type": "customerStripe"    },    "lifetimeListPriceCents": 300,    "lifetimeInternalAppliedCents": 0,    "lifetimeBillableCents": 300,    "unbilledCents": 300  }}

Return codes

  • 200Success, treated as complete.: Usage summary returned.
  • 204Success, treated as empty response.: CORS preflight when method is OPTIONS.
  • 400Bad request, treated as client error.: Invalid JSON body.
  • 401Unauthorized, treated as auth error.: Missing API key, or invalid API key.
  • 403Forbidden, treated as permission error.: API key is not active, missing usage:read permission, or a non-admin key requested another apiKeyId.
  • 405Client error, treated as fix required.: Method is not POST.
  • 500Server error, treated as retryable.: API key missing userId, or failed to read usage summary.

Notes

  • When apiKeyId is omitted, the endpoint returns usage for the authenticated key.
  • Only admin keys can request usage for another key id.
  • Usage periods are read from api_key_usage/{apiKeyId}/periods in the API Firestore database.