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

RouteCredentialStatuses
GET /v1/keys/{key_id}/usageadmin key200, 401, 404
GET /v1/requests/{request_id}API key200, 401, 404
GET /v1/requests/{request_id}/receiptAPI key200, 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:

FieldMeaning
idThe request id the gateway returned in its response header.
created_atAn ISO 8601 date-time.
key_idThe key that sent it.
modelThe model that answered, once any alias is resolved.
statusThe HTTP status the model route gave.
outcomecompleted, client_disconnected, cache_hit, upstream_error and others.
usageinput_tokens, cache_read_tokens, cache_write_tokens and output_tokens, plus source: whether the counts came from the model or from an estimate.
charge_usdWhat you paid, as an exact decimal string.
list_cost_usdThe same tokens at the developer's list price, or null.
saved_usdThe list cost less the charge, floored at zero, or null.
refundrefusal or invalid_output when the answer went unbilled, else null.
latency_msMilliseconds 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:

FieldMeaning
payloadThe receipt as the exact JSON string that was signed.
signatureEd25519 over the UTF-8 bytes of payload, base64url encoded.
algAlways Ed25519.
key_idWhich signing key made the signature.
public_key_urlWhere that public key can be fetched.
receiptpayload 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

shell
1curl "https://api.pentestllm.ai/v1/requests/REQUEST_ID/receipt" \
2 -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.

Join on TelegramHelp