Documentation menu

Usage and the request log

Read every request the gateway served, and total usage by day per customer, member, model, key or tag.

Every request the gateway serves is recorded: who it was for, which model answered, its tokens, what it cost and what it was billed, and how it ended. Read the records one by one from the request log, or totals by day from the summary. Requests refused before a provider was called (a bad key, no credit, a limit) are not recorded; webhooks tell you about those that matter.

Records appear a few seconds after the response ends: the gateway hands them to a queue so the request itself never waits on the database.

List requests#

curl "https://api.hixel.dev/v1/usage?customer=org_42&from=2026-11-01T00:00:00Z&limit=50" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Newest first, paginated with cursor and limit (1 to 100). Every filter is an exact match:

Query parameterKeeps requests
customerof this customer (your id)
memberof this member
modelanswered by this model (catalog name)
key_idmade with this key (key_…)
tagcarrying this tag
payerpaid by wallet, tenant (your organization's account) or byok (the customer's own key)
outcomethat ended completed, aborted, upstream_error, truncated or stream_error
endpointfor chat or an endpoint beside chat (embeddings, image_generations, …)
request_idwith this request id, the x-hixel-request-id the gateway answered
session_idof this realtime session
from, tothat started at or after from and before to (ISO 8601 timestamps)

GET /v1/usage/{id} reads one record by its id (use_…).

Find a request by its request id#

Every gateway response carries x-hixel-request-id. Log it with your own request, and you can later find exactly that request's record, its tokens, cost and how it ended:

curl "https://api.hixel.dev/v1/usage?request_id=req_6f1c0e9a2b7d4c3e8a5f0b1d2c3e4f5a" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

A record#

{
  "id": "use_…",
  "request_id": "req_6f1c0e9a2b7d4c3e8a5f0b1d2c3e4f5a",
  "key_id": "key_…",
  "key_tags": ["backend"],
  "customer": "org_42",
  "member": "user_7",
  "provider": "anthropic",
  "api_shape": "openai_chat_completions",
  "endpoint": null,
  "requested_model": "claude-sonnet",
  "model": "claude-sonnet-5-5",
  "upstream_model": "claude-sonnet-5-5",
  "payer": "wallet",
  "attempts": 1,
  "stream": true,
  "tokens": {
    "input": "1200",
    "cache_read": "3400",
    "cache_write_5m": "0",
    "cache_write_1h": "0",
    "output": "450",
    "reasoning": "0"
  },
  "usage_completeness": "complete",
  "cost_micros": "7240",
  "billed_micros": "8688",
  "upstream_status": 200,
  "outcome": "completed",
  "mocked": false,
  "cache": null,
  "tags": ["feature:summarise"],
  "client_token_id": null,
  "settlement": { "status": "settled", "basis": "usage", "reason": null },
  "started_at": "2026-11-25T10:00:00.000Z",
  "duration_ms": 2140,
  …
}
  • Tokens are in disjoint buckets: fresh input, cache_read, cache writes kept for 5 minutes and for an hour, and output. reasoning is part of output, shown apart.
  • cost_micros is what the request cost at the provider's price; billed_micros what the payer was charged: the cost plus your markup for wallet and tenant, "0" for byok. Both are null for a model without a price.
  • requested_model is the name the request sent (an alias, perhaps); model the catalog model that answered.
  • usage_completeness says whether the provider reported all of the usage (complete) or not (partial, missing, truncated). When it did not, the request is charged at the larger of what was seen and the estimate reserved before the call, so billed_micros can be above the price of the tokens shown; usage_cost_micros and usage_billed_micros hold the price of the tokens seen.
  • settlement.status says how the wallet or limits took the request's end; untracked when neither a wallet nor a limit applied.
  • endpoint and endpoint_usage are set for an endpoint beside chat, with its media tokens and units (images, audio milliseconds, characters, search units).

Totals by day, and analytics#

The charts of the dashboard's usage pages are API reads too, and the simplest of them is daily totals: GET /v1/usage/series with bucket=day, grouped by customer, member, model, key, tag, provider, payer or outcome.

curl "https://api.hixel.dev/v1/usage/series?from=2026-11-01T00:00:00Z&to=2026-12-01T00:00:00Z&bucket=day&group_by=customer" \
  -H "Authorization: Bearer $HIXEL_API_KEY"
{
  "from": "2026-11-01T00:00:00.000Z",
  "to": "2026-12-01T00:00:00.000Z",
  "bucket": "day",
  "buckets": ["2026-11-01T00:00:00.000Z", "2026-11-02T00:00:00.000Z", …],
  "group_by": "customer",
  "series": [
    {
      "bucket": "2026-11-24T00:00:00.000Z",
      "group": "org_42",
      "requests": "312",
      "tokens": { "input": "…", "cache_read": "…", "cache_write_5m": "…", "cache_write_1h": "…", "output": "…", "reasoning": "…" },
      "cost_micros": "1840000",
      "billed_micros": "2208000"
    }
  ],
  "others": [],
  "omitted_groups": 0
}

The analytics envelope#

Every analytics read (/v1/usage/series, totals, performance, errors, guardrails, keys, and /v1/limit_crossings/summary) answers in the same shape:

  • from, to: the range, to exclusive. At most 92 days, or 7 with bucket=hour; from must be before to (400 invalid_range otherwise).
  • bucket (day or hour, UTC) and buckets: every bucket of the range, oldest first, with requests or not. A row exists only for a bucket and group with requests, so fill the others with zeros from buckets.
  • group_by and series: rows by bucket, then group. Only the largest groups are listed one by one: omitted_groups says how many were left out, and others sums them per bucket, so nothing is dropped silently. Where a read ranks groups over the whole range, it answers them in groups, and the range's sum in total.

Each takes the same exact filters as the request list (customer, member, model, key_id, tag, payer, outcome, endpoint). Counts and amounts are strings of integers.

CallWhat it answers
GET /v1/usage/seriesRequests, tokens, cost and billed amounts per bucket and group
GET /v1/usage/totalsOne range's totals; call it again with the previous range to compare
GET /v1/usage/performanceLatency percentiles (p50, p95, p99), retries, cache hits and streaming, by model or provider
GET /v1/usage/errorsHow requests ended, by bucket and group_by (outcome or status_class, required)
GET /v1/usage/failuresThe kinds of failed request (provider, model, upstream status, outcome), most frequent first
GET /v1/usage/guardrailsWhat each guardrail rule flagged, masked or blocked
GET /v1/usage/keysWhen each key was last used, and its requests in the range

With group_by=tag, a request counts once in each of its tags' groups, so a bucket's groups can add up to more than its total; requests without tags are in the group null.

Limit crossings#

Requests refused at a spend limit, or because a wallet could not cover them, reach no provider and have no usage record. They are recorded as limit crossings instead: GET /v1/limit_crossings lists them newest first (filter by customer, limit_type of spend_limit or insufficient_credits, and from/to). GET /v1/limit_crossings/summary counts them by bucket and type, in the analytics envelope, and GET /v1/limit_crossings/customers ranks the customers refused most over a range. The first crossing in a window also sends a webhook.

In real time#

To receive each record as it happens, subscribe a webhook endpoint to usage.recorded, or send them to your observability tools with trace exports.