Usage Statistics
Endpoint
Section titled “Endpoint”GET https://api.bve.me/admin/usageAuthorization: Bearer admin_bve_YOUR_ADMIN_KEYReturns aggregated usage statistics from Cloudflare D1. Usage is recorded asynchronously after each request via ctx.waitUntil.
Query parameters
Section titled “Query parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
key_id | string | No | — | Filter by API key UUID. Omit to return all keys. |
from | string | No | — | Earliest date to include, in YYYY-MM-DD format. Filters daily rows by date and monthly rows by year-month prefix. |
to | string | No | — | Latest date to include, in YYYY-MM-DD format. Same filtering as from. |
daily_limit | integer | No | 30 / 100 | Max daily rows to return (1–500). Default is 30 when key_id is set, 100 otherwise. |
monthly_limit | integer | No | 12 / 50 | Max 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.
Response
Section titled “Response”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" } ]}Response fields
Section titled “Response fields”daily[] row:
| Field | Type | Description |
|---|---|---|
id | string | Row UUID (internal) |
key_id | string | API key UUID this row belongs to |
date | string | Date in YYYY-MM-DD format |
request_count | integer | Number of requests recorded on this date |
prompt_tokens | integer | Prompt token total for this date |
completion_tokens | integer | Completion token total for this date |
total_tokens | integer | Sum of prompt + completion tokens |
updated_at | string | ISO 8601 timestamp of last write |
monthly[] row:
| Field | Type | Description |
|---|---|---|
id | string | Row UUID (internal) |
key_id | string | API key UUID this row belongs to |
year_month | string | Month in YYYY-MM format |
request_count | integer | Number of requests recorded this month |
prompt_tokens | integer | Prompt token total for this month |
completion_tokens | integer | Completion token total for this month |
total_tokens | integer | Sum of prompt + completion tokens |
updated_at | string | ISO 8601 timestamp of last write |
cURL examples
Section titled “cURL examples”All keys:
curl "https://api.bve.me/admin/usage" \ -H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"Single key:
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):
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:
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:
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:
curl "https://api.bve.me/admin/usage?daily_limit=500&monthly_limit=100" \ -H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"TypeScript examples
Section titled “TypeScript examples”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`);Python examples
Section titled “Python examples”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) record0. - Usage data is stored in the
monthly_usageanddaily_usagetables in Cloudflare D1. - Usage is recorded asynchronously via
ctx.waitUntiland does not block the response.