BazaarLinkBazaarLink
Masuk
DokumentasiReferensi APIReferensi SDKPenggunaan AgentikSkill AI
Akun

Dapatkan penggunaan

Mengembalikan total pengeluaran/permintaan/token untuk jendela waktu tertentu, dipecah berdasarkan model, API key, dan nama aplikasi, ditambah rangkaian waktu harian. Berbeda dari /v1/insights, endpoint ini tidak memiliki peringkat model teratas, statistik cache, atau heatmap tahunan — ini endpoint agregat yang lebih ringan, dan mendukung rentang tanggal kustom (period=custom).

GET/api/v1/usage

Otorisasi

Authorizationwajib
string · header

API key sebagai bearer token di header Authorization.

Parameter query

period
string

Jendela waktu, default month. Tiga jenis: kata kalender lama (day/week/month/year), jendela bergulir berakhir sekarang (15m…1y), jendela selaras kalender (today…prev_year), atau custom (memerlukan from/to). Nilai yang tidak dikenali mengembalikan 400.

dayweekmonthyear15m30m1h3h1d2d1w1mo1ytodayyesterdaythis_weekprev_weekthis_monthprev_monththis_yearprev_yearcustom
Example: "month"
from
string

Awal jendela kustom (ISO 8601). Hanya digunakan dengan period=custom.

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

Akhir jendela kustom (ISO 8601). Hanya digunakan dengan 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"
Contoh respons

Berhasil. totals adalah agregat jendela; byModel/byKey/byApp adalah tiga rincian independen (bukan hubungan bersarang); timeSeries adalah rangkaian harian (tersegmentasi per model) dari pengeluaran/token/permintaan. Contoh di bawah dipersingkat.

{
  "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.
Dapatkan penggunaan — BazaarLink API