Skip to content

Usage Statistics

GET https://api.bve.me/admin/usage
Authorization: Bearer admin_bve_YOUR_ADMIN_KEY

Returns aggregated usage statistics from Cloudflare D1. Usage is recorded asynchronously after each request via ctx.waitUntil.

ParameterTypeRequiredDefaultDescription
key_idstringNoFilter by API key UUID. Omit to return all keys.
fromstringNoEarliest date to include, in YYYY-MM-DD format. Filters daily rows by date and monthly rows by year-month prefix.
tostringNoLatest date to include, in YYYY-MM-DD format. Same filtering as from.
daily_limitintegerNo30 / 100Max daily rows to return (1–500). Default is 30 when key_id is set, 100 otherwise.
monthly_limitintegerNo12 / 50Max monthly rows to return (1–500). Default is 12 when key_id is set, 50 otherwise.

from and to are both optional and can be combined with key_id. Passing a date string that is not YYYY-MM-DD returns 400 validation_error.

Use daily_limit and monthly_limit to retrieve more than the default number of rows — for example, to fetch 90 days of daily data for a specific key, pass ?daily_limit=90.

The response is an object with two arrays: daily and monthly. Row counts are bounded by daily_limit and monthly_limit respectively (defaults: 30/100 for daily, 12/50 for monthly depending on whether key_id is set).

{
"daily": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"key_id": "550e8400-e29b-41d4-a716-446655440000",
"date": "2026-05-21",
"request_count": 47,
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"updated_at": "2026-05-21T14:32:00.000Z"
}
],
"monthly": [
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"key_id": "550e8400-e29b-41d4-a716-446655440000",
"year_month": "2026-05",
"request_count": 1420,
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"updated_at": "2026-05-21T14:32:00.000Z"
}
]
}

daily[] row:

FieldTypeDescription
idstringRow UUID (internal)
key_idstringAPI key UUID this row belongs to
datestringDate in YYYY-MM-DD format
request_countintegerNumber of requests recorded on this date
prompt_tokensintegerPrompt token total for this date
completion_tokensintegerCompletion token total for this date
total_tokensintegerSum of prompt + completion tokens
updated_atstringISO 8601 timestamp of last write

monthly[] row:

FieldTypeDescription
idstringRow UUID (internal)
key_idstringAPI key UUID this row belongs to
year_monthstringMonth in YYYY-MM format
request_countintegerNumber of requests recorded this month
prompt_tokensintegerPrompt token total for this month
completion_tokensintegerCompletion token total for this month
total_tokensintegerSum of prompt + completion tokens
updated_atstringISO 8601 timestamp of last write

All keys:

Terminal window
curl "https://api.bve.me/admin/usage" \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

Single key:

Terminal window
curl "https://api.bve.me/admin/usage?key_id=550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

Date range (all keys for May 2026):

Terminal window
curl "https://api.bve.me/admin/usage?from=2026-05-01&to=2026-05-31" \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

Single key within date range:

Terminal window
curl "https://api.bve.me/admin/usage?key_id=550e8400-e29b-41d4-a716-446655440000&from=2026-05-01&to=2026-05-31" \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

Last 90 days of daily data for a specific key:

Terminal window
curl "https://api.bve.me/admin/usage?key_id=550e8400-e29b-41d4-a716-446655440000&daily_limit=90" \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

All-keys view with expanded daily and monthly limits:

Terminal window
curl "https://api.bve.me/admin/usage?daily_limit=500&monthly_limit=100" \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

Fetch all keys — current month token totals:

const res = await fetch("https://api.bve.me/admin/usage", {
headers: { Authorization: `Bearer ${adminKey}` },
});
const data: { daily: any[]; monthly: any[] } = await res.json();
const totalTokens = data.monthly.reduce((sum, m) => sum + m.total_tokens, 0);
console.log(`Total tokens across all keys this month: ${totalTokens.toLocaleString()}`);

Single key — last 90 days of daily data:

const keyId = "550e8400-e29b-41d4-a716-446655440000";
const res = await fetch(
`https://api.bve.me/admin/usage?key_id=${keyId}&daily_limit=90`,
{ headers: { Authorization: `Bearer ${adminKey}` } }
);
const { daily } = await res.json();
for (const row of daily) {
console.log(`${row.date}: ${row.request_count} requests, ${row.total_tokens} tokens`);
}

Date range — aggregate May 2026 totals:

const res = await fetch(
"https://api.bve.me/admin/usage?from=2026-05-01&to=2026-05-31",
{ headers: { Authorization: `Bearer ${adminKey}` } }
);
const { daily } = await res.json();
const totals = daily.reduce(
(acc, row) => ({
requests: acc.requests + row.request_count,
tokens: acc.tokens + row.total_tokens,
}),
{ requests: 0, tokens: 0 }
);
console.log(`May 2026: ${totals.requests} requests, ${totals.tokens} tokens`);

Fetch all keys — current month token totals:

import requests
res = requests.get(
"https://api.bve.me/admin/usage",
headers={"Authorization": f"Bearer {admin_key}"},
)
data = res.json()
total_tokens = sum(m["total_tokens"] for m in data["monthly"])
print(f"Total tokens across all keys this month: {total_tokens:,}")

Single key — last 90 days of daily data:

import requests
key_id = "550e8400-e29b-41d4-a716-446655440000"
res = requests.get(
f"https://api.bve.me/admin/usage?key_id={key_id}&daily_limit=90",
headers={"Authorization": f"Bearer {admin_key}"},
)
daily = res.json()["daily"]
for row in daily:
print(f"{row['date']}: {row['request_count']} requests, {row['total_tokens']} tokens")

Date range — aggregate May 2026 totals:

import requests
res = requests.get(
"https://api.bve.me/admin/usage?from=2026-05-01&to=2026-05-31",
headers={"Authorization": f"Bearer {admin_key}"},
)
daily = res.json()["daily"]
total_requests = sum(r["request_count"] for r in daily)
total_tokens = sum(r["total_tokens"] for r in daily)
print(f"May 2026: {total_requests} requests, {total_tokens:,} tokens")
  • Token counts (prompt_tokens, completion_tokens, total_tokens) are recorded from upstream responses for /v1/chat/completions (streaming and non-streaming), /v1/completions, /v1/embeddings, and /v1/messages. Routes that proxy binary or non-JSON content (audio, images, files) record 0.
  • Usage data is stored in the monthly_usage and daily_usage tables in Cloudflare D1.
  • Usage is recorded asynchronously via ctx.waitUntil and does not block the response.