BazaarLinkBazaarLink
เข้าสู่ระบบ
เอกสารAPI ข้อมูลอ้างอิงSDK ข้อมูลอ้างอิงการใช้งาน AgentAI ทักษะ
บัญชี

รับสรุปการใช้งาน

คืนค่ายอดรวมค่าใช้จ่าย/จำนวนคำขอ/โทเค็นสำหรับช่วงเวลาที่กำหนด แบ่งตามโมเดล ตาม API key และตามชื่อแอป พร้อมชุดข้อมูลอนุกรมเวลารายวัน ต่างจาก /v1/insights เอนด์พอยต์นี้ไม่มีการจัดอันดับโมเดลยอดนิยม สถิติ cache หรือฮีตแมปรายปี — เป็นเอนด์พอยต์รวมข้อมูลที่เบากว่า และรองรับช่วงวันที่กำหนดเอง (period=custom)

GET/api/v1/usage

การอนุญาต

Authorizationจำเป็น
string · header

API key เป็น bearer token ใน header Authorization

พารามิเตอร์คิวรี

period
string

ช่วงเวลา ค่าเริ่มต้น month มีสามแบบ: คำปฏิทินแบบเดิม (day/week/month/year), หน้าต่างแบบเลื่อนที่สิ้นสุด ณ ปัจจุบัน (15m…1y), หน้าต่างที่ตรงกับปฏิทิน (today…prev_year), หรือ custom (ต้องมี from/to) ค่าที่ไม่รู้จักจะคืนค่า 400

dayweekmonthyear15m30m1h3h1d2d1w1mo1ytodayyesterdaythis_weekprev_weekthis_monthprev_monththis_yearprev_yearcustom
Example: "month"
from
string

จุดเริ่มต้นของช่วงกำหนดเอง (ISO 8601) ใช้เฉพาะเมื่อ period=custom

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

จุดสิ้นสุดของช่วงกำหนดเอง (ISO 8601) ใช้เฉพาะเมื่อ 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"
ตัวอย่างการตอบกลับ

สำเร็จ totals คือยอดรวมของช่วงเวลา byModel/byKey/byApp เป็นการแบ่งอิสระสามแบบ (ไม่ใช่ความสัมพันธ์แบบซ้อน) timeSeries คือชุดข้อมูลรายวัน (แบ่งตามโมเดล) ของค่าใช้จ่าย/โทเค็น/จำนวนคำขอ ตัวอย่างด้านล่างถูกย่อไว้

{
  "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.
รับสรุปการใช้งาน — BazaarLink API