> For the complete documentation index, see [llms.txt](https://docs.tinyapi.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tinyapi.org/1-register/7-token-usage.md).

# (7) ข้อมูลเครดิตคงเหลือ

## ข้อมูล API Key และเครดิตคงเหลือ

**Quick Start** · 2026/6/13 · อ่านประมาณ 3 นาที

ตรวจสอบชื่อ API Key, เครดิตทั้งหมด, เครดิตที่ใช้ไป, เครดิตคงเหลือ, วันหมดอายุ และสิทธิ์โมเดลของคีย์ที่ใช้เรียก

## Endpoint

TinyAPI ใช้ endpoint ด้านล่างสำหรับตรวจข้อมูลและเครดิตของ API Key โดยตรง คำขอนี้ใช้ API Key ที่ขึ้นต้นด้วย `sk-`

**Method**

```
GET
```

**Endpoint**

```
${apiUrl
```

**Authorization**

```
Authorization: Bearer sk-YOUR_API_KEY
```

>

Endpoint นี้เป็นของ TinyAPI โดยเฉพาะ จึงใช้ path `/api/usage/token` ไม่ใช่ `/v1/me` หรือ `/v1/usage`

## ตัวอย่างคำสั่ง

เปิด Command Prompt, PowerShell หรือ Terminal แล้วแทนที่ `sk-YOUR_API_KEY` ด้วยคีย์ของคุณ

**cURL**

```bash
curl https://api.tinyapi.org/api/usage/token \\
  -H "Authorization: Bearer sk-YOUR_API_KEY"
```

**Example response**

```json
{
  "code": true,
  "message": "ok",
  "data": {
    "object": "token_usage",
    "name": "my-api-key",
    "total_granted": 1000000,
    "total_used": 250000,
    "total_available": 750000,
    "unlimited_quota": false,
    "model_limits": {},
    "model_limits_enabled": false,
    "expires_at": 0
  }
}
```

## ข้อมูลที่ได้รับ

| FIELD                  | TYPE    | DESCRIPTION                                                |
| ---------------------- | ------- | ---------------------------------------------------------- |
| name                   | string  | ชื่อ API Key ที่กำหนดไว้ตอนสร้างคีย์                       |
| total\_granted         | number  | เครดิตหรือโควตารวมของ API Key ก่อนหักการใช้งาน             |
| total\_used            | number  | เครดิตหรือโควตาที่ API Key ใช้ไปแล้ว                       |
| total\_available       | number  | เครดิตหรือโควตาคงเหลือของ API Key                          |
| unlimited\_quota       | boolean | true หมายถึง API Key ไม่ได้จำกัดโควตาแยกจากบัญชี           |
| model\_limits\_enabled | boolean | แสดงว่า API Key เปิดการจำกัดรายชื่อโมเดลหรือไม่            |
| model\_limits          | object  | รายชื่อโมเดลที่คีย์ได้รับอนุญาต เมื่อเปิดการจำกัดโมเดล     |
| expires\_at            | number  | เวลา Unix ที่ API Key หมดอายุ ค่า 0 หมายถึงไม่มีวันหมดอายุ |

## ข้อควรรู้

* ค่าเครดิตจาก endpoint นี้เป็นหน่วยโควตาภายในของ TinyAPI การแสดงเป็นเงินหรือเครดิตบนหน้าเว็บขึ้นกับการตั้งค่าของระบบ
* Endpoint นี้แสดงข้อมูลของ API Key แต่ไม่ส่งอีเมลหรือข้อมูลส่วนตัวของเจ้าของบัญชี
* ถ้าต้องการดูยอดในรูปแบบหน้าเว็บ ให้เปิดหน้า

กระเป๋าเงิน

* แม้คีย์หมดเครดิตหรือหมดอายุ endpoint แบบอ่านอย่างเดียวนี้ยังใช้ตรวจข้อมูลคีย์ได้


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tinyapi.org/1-register/7-token-usage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
