---
title: "Usage and receipts API: evidence for every request"
description: "Read a key's spend for today, this month and its lifetime, look up a finished request by id, and pull the Ed25519 signed receipt you can check offline."
canonical: https://pentestllm.ai/docs/usage-and-receipts
generated: 2026-11-27T06:25:49.481Z
source: https://pentestllm.ai/docs/usage-and-receipts
base_url: https://api.pentestllm.ai/v1
---

[Docs](https://pentestllm.ai/docs) / API reference

# Usage, requests and receipts

Updated 2026-11-22. Published by PentestLLM.

When a client asks what an engagement cost, or an auditor wants proof of what a model was sent, three routes under `https://api.pentestllm.ai/v1` answer: spend per key over three windows, the record of any single request, and that request’s receipt, signed so it can be checked without trusting this site.

## Routes

| Route | Credential | Statuses |
| --- | --- | --- |
| `GET /v1/keys/{key_id}/usage` | admin key | 200, 401, 404 |
| `GET /v1/requests/{request_id}` | API key | 200, 401, 404 |
| `GET /v1/requests/{request_id}/receipt` | API key | 200, 401, 404, 503 |

The usage route declares the admin key alone. The two request routes fall under the root security list instead: a standard key in the Authorization header, or in the header the Anthropic or Google SDK sends. Any key of the organization can read a request another of its keys made. Whether a console session is accepted on any of the three, the OpenAPI document does not say.

## Usage for one key

`GET /v1/keys/{key_id}/usage` answers `data` with `key_id` and three windows, `today` and `month` on UTC boundaries plus `lifetime`. Each window gives `requests` (failed ones counted), `spend_micro` and `spend_usd`; a micro-dollar is a millionth of a dollar. `budget` is null unless the key has a prepaid budget, in which case it states the budget, the spent part and the remainder in both units. Add `group_by=user` to get `by_user`: the 100 end users with the highest spend this UTC month, each with its request count and spend.

## One finished request

`GET /v1/requests/{request_id}` takes the id from the response header every answer carries (1 to 64 ASCII letters, digits, underscores or hyphens) and returns an object of type request:

| Field | Meaning |
| --- | --- |
| `id` | The request id the gateway returned in its response header. |
| `created_at` | An ISO 8601 date-time. |
| `key_id` | The key that sent it. |
| `model` | The model that answered, once any alias is resolved. |
| `status` | The HTTP status the model route gave. |
| `outcome` | completed, client_disconnected, cache_hit, upstream_error and others. |
| `usage` | input_tokens, cache_read_tokens, cache_write_tokens and output_tokens, plus source: whether the counts came from the model or from an estimate. |
| `charge_usd` | What you paid, as an exact decimal string. |
| `list_cost_usd` | The same tokens at the developer's list price, or null. |
| `saved_usd` | The list cost less the charge, floored at zero, or null. |
| `refund` | refusal or invalid_output when the answer went unbilled, else null. |
| `latency_ms` | Milliseconds from start to finish. |

## The signed receipt

`GET /v1/requests/{request_id}/receipt` returns the receipt a non-streamed answer already carries in a response header, as a JSON document:

| Field | Meaning |
| --- | --- |
| `payload` | The receipt as the exact JSON string that was signed. |
| `signature` | Ed25519 over the UTF-8 bytes of payload, base64url encoded. |
| `alg` | Always Ed25519. |
| `key_id` | Which signing key made the signature. |
| `public_key_url` | Where that public key can be fetched. |
| `receipt` | payload decoded: request_id, created_at, model, billed_tokens (input, cache_read, cache_write, output), charge_usd, refund, and request_sha256 and response_sha256, hex digests of the body sent and the body relayed. |

Verify against the bytes of `payload` exactly as delivered. Parsing `receipt` and serializing it again can reorder keys or change spacing, and the signature would no longer match. Match `key_id` to the one on the [statement signing key](https://pentestllm.ai/docs/statements-public-key) before trusting the check. If signing is not set up on the service the route answers `503 not_configured`.

## Errors

A credential that fails is `401 invalid_api_key` on all three. `404 not_found` means the key is not in your organization, or the request is not in the log yet or belongs to another organization.

## Example

```bash
curl "https://api.pentestllm.ai/v1/requests/REQUEST_ID/receipt" \
  -H "Authorization: Bearer sk-ptl-live-…"
```

## Questions

### A request just finished. Why is it a 404?

Records reach the log about a minute after a request ends, so try again shortly. The same 404 also covers an id that belongs to a different organization.

### Do streamed requests get a receipt?

Yes. The receipt route covers streamed requests too, once they are in the log, and the request route is where a stream’s token counts and charge end up.

### Is an invoice the same thing as a receipt?

No. An invoice records a top-up that credited your balance. A receipt here is a signed statement about one model request and what it was billed.

## Read next

- [MCP servers](https://pentestllm.ai/docs/mcp-servers)
- [Log export](https://pentestllm.ai/docs/exports)
- [Invoices](https://pentestllm.ai/docs/invoices)
- [Billing details](https://pentestllm.ai/docs/billing-details)
- [Statement signing key](https://pentestllm.ai/docs/statements-public-key)
- [Keys and scopes](https://pentestllm.ai/docs/keys)
- [Spend limits and balance](https://pentestllm.ai/docs/spend-limits)
- [Redaction and guardrails](https://pentestllm.ai/docs/redaction-and-guardrails)
- [Sessions](https://pentestllm.ai/docs/sessions)
- [Embeddings, rerank and moderation](https://pentestllm.ai/docs/retrieval-and-moderation)
- [Batch files](https://pentestllm.ai/docs/files)
- [Batches](https://pentestllm.ai/docs/batches)
- [Status and proof feeds](https://pentestllm.ai/docs/status-and-proof)
- [Count tokens](https://pentestllm.ai/docs/count-tokens)
- [Usage by app](https://pentestllm.ai/docs/stats-apps)
- [App sign-in keys](https://pentestllm.ai/docs/auth-keys)
- [Webhook deliveries](https://pentestllm.ai/docs/webhooks-deliveries)
- [Docs: connect in two minutes](https://pentestllm.ai/docs)
- [Sessions, usage export and log streaming](https://pentestllm.ai/features/observability)
