Skip to content
Sign Up Free
API Reference

Query request logs for one API Key

Retrieve up to 1,000 recent request logs for one BetterToken API Key. Read timestamps, request IDs, token counts, and recorded charges in each record's currency.

Use GET https://bettertoken.ai/api/log/token to retrieve recent request logs for one BetterToken API Key.

Send a request

Use the same sk-... BetterToken API Key that you use for model calls. Set it as the local environment variable BETTERTOKEN_API_KEY before running this command.

Authenticate with Authorization: Bearer <API_KEY>. The request has no parameters or body. The full URL does not include /v1.

Terminal window
curl -sS 'https://bettertoken.ai/api/log/token' \
-H "Authorization: Bearer ${BETTERTOKEN_API_KEY}"

Successful response

On success, success is true, and data is an array of logs for this Key. The most recently written records appear first, with up to 1,000 records returned.

This endpoint has no pagination, time filter, or request ID filter.

The example shows only commonly used fields. All values are for demonstration.

{
"success": true,
"message": "",
"data": [
{
"created_at": 1795046400,
"type": 2,
"model_name": "gpt-6.2-sol",
"request_id": "example-request-id",
"prompt_tokens": 120,
"completion_tokens": 48,
"quota": 600,
"recorded_amount": "0.0012",
"currency": "USD"
}
]
}

Read each record

FieldMeaning
created_atUnix timestamp in seconds.
model_nameModel ID.
request_idWhen present, use it to match the record to a model request.
prompt_tokensRecorded input token count, depending on the endpoint and billing method.
completion_tokensRecorded output token count, depending on the endpoint and billing method.
type2 indicates a consumption record.
quotaThe recorded quota value, in internal quota units.
recorded_amountAmount as a decimal string. Returned for consumption records with a saved billing conversion factor.
currencyCurrency of the amount, such as USD.

Handle amounts

Do not treat a missing recorded_amount as a zero charge. Sum records separately for each currency.

For this Key’s cumulative usage and remaining quota, see Query API Key quota. For account-level history, open BetterToken Workspace.