> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prismgateway.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage

> ตรวจยอดเครดิต ค่าใช้จ่าย และ metered units ราย request

# Usage

## ยอดเครดิต

```bash theme={null}
curl -sS "https://api.prismgateway.io/v1/credits" \
  -H "Authorization: Bearer $PRISM_API_KEY"
```

```json theme={null}
{
  "object": "credits",
  "balance_minor": 2000,
  "spent_minor": 0
}
```

`100` minor credits เท่ากับ 1 บาท ให้เก็บจำนวนเงินเป็น integer

`balance_minor` เป็นยอดสุทธิรวมทุก credit kind ของเจ้าของ key และ organization
ที่ผูกกับ key จึงเป็น account summary ไม่ได้ยืนยันว่า route ใด route หนึ่งใช้ยอดนั้น
ได้ เพราะ admission ของแต่ละ route ใช้ `general` รวมกับ credit kind ของ route นั้น

## Usage ราย request

นำ `x-prism-trace-id` จาก successful chat response มาใช้:

```bash theme={null}
curl -sS "https://api.prismgateway.io/v1/usage/$REQUEST_ID" \
  -H "Authorization: Bearer $PRISM_API_KEY"
```

Response ระบุ model, เวลา, billed units และ `cost_credits_minor` ที่ลูกค้าถูก
คิดจริงหลัง organization pricing โดยไม่เปิดเผย provider cost หรือ margin ภายใน

Usage lookup จำกัดตามเจ้าของ key หาก request ID ไม่พบหรือเป็นของ user อื่นจะคืน
`404`

[English version](/usage)
