BazaarLinkBazaarLink
Sign in
DocsAPI ReferenceSDK ReferenceAgentic UsageAI Skills
Account

Get usage

Returns spend/requests/token totals for a given window, broken down by model, by API key, and by app name, plus a daily time series. Unlike /v1/insights, this endpoint has no top-models ranking, cache stats, or year heatmap — it's the lighter-weight aggregate endpoint, and it supports a custom date range (period=custom).

GET/api/v1/usage

Authorizations

Authorizationrequired
string · header

API key as bearer token in the Authorization header.

Query parameters

period
string

The time window, defaults to month. Three families: legacy calendar words (day/week/month/year), rolling windows ending now (15m…1y), calendar-aligned windows (today…prev_year), or custom (requires from/to). An unrecognized value returns 400.

dayweekmonthyear15m30m1h3h1d2d1w1mo1ytodayyesterdaythis_weekprev_weekthis_monthprev_monththis_yearprev_yearcustom
Example: "month"
from
string

Start of the custom window (ISO 8601). Only used with period=custom.

ISO 8601, required with period=custom
Example: "2026-07-01T00:00:00.000Z"
to
string

End of the custom window (ISO 8601). Only used with period=custom.

ISO 8601, required with period=custom
Example: "2026-07-27T00:00:00.000Z"
GET /api/v1/usage
curl "https://bazaarlink.ai/api/v1/usage?period=month" \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY"
Response examples

Success. totals is the window aggregate; byModel/byKey/byApp are three independent breakdowns (not a nested relationship); timeSeries is a daily (per-model-segmented) series of spend/tokens/requests. The example below is truncated.

{
  "period": "month",
  "since": "2026-07-01T00:00:00.000Z",
  "until": "2026-07-27T12:00:00.000Z",
  "credits": 42.5,
  "totals": {
    "spend": 4.82,
    "requests": 340,
    "tokens": 152000,
    "promptTokens": 120000,
    "completionTokens": 32000
  },
  "byModel": [
    {
      "model": "openai/gpt-4.1",
      "spend": 4.82,
      "tokens": 152000,
      "requests": 340
    }
  ],
  "byKey": [
    {
      "keyId": "key_abc123",
      "keyName": "default",
      "spend": 4.82,
      "tokens": 152000,
      "requests": 340,
      "spendLimitUsd": null,
      "spendLimitPeriod": null
    }
  ],
  "byApp": [
    {
      "appName": "my-app",
      "spend": 4.82,
      "tokens": 152000,
      "requests": 340
    }
  ],
  "timeSeries": [
    {
      "date": "2026-07-01",
      "model": "openai/gpt-4.1",
      "cost": 0.16,
      "tokens": 5200,
      "requests": 12
    }
  ]
}
Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
Get usage — BazaarLink API