Docs / API reference
Usage, requests and receipts
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 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
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
- Log export
- Invoices
- Billing details
- Statement signing key
- Keys and scopes
- Spend limits and balance
- Redaction and guardrails
- Sessions
- Embeddings, rerank and moderation
- Batch files
- Batches
- Status and proof feeds
- Count tokens
- Usage by app
- App sign-in keys
- Webhook deliveries
- Docs: connect in two minutes
- Sessions, usage export and log streaming