---
title: ข้อมูลอ้างอิง API: Usage
description: Platform API v1 ส่วน Usage: path, พารามิเตอร์, ฟิลด์ของคำขอและคำตอบ, scope, idempotency และข้อผิดพลาดของทุก operation จาก contract
url: https://agentlab.cresclab.com/docs/th/api/usage
language: th
updated: 2026-12-05
---

# ข้อมูลอ้างอิง API: Usage

Platform API v1 ส่วน Usage: path, พารามิเตอร์, ฟิลด์ของคำขอและคำตอบ, scope, idempotency และข้อผิดพลาดของทุก operation จาก contract

> [!NOTE]
> สร้างจาก API contract (Agent Lab Platform API 1.0.0-alpha.1) คำอธิบายเป็นภาษาอังกฤษตามต้นฉบับใน contract

What an installation's runs and evaluation runs spent, by the `agentRef` of the
configuration each answered from, read as a member who may read the workspace's usage.

## What the installation's runs spent, by agentRef

`GET /v1/workspaces/{workspaceId}/usage`

The model calls this installation's runs and evaluation runs made in the last `sinceDays`
days, grouped by the `agentRef` of the configuration each reply answered from and by
`kind`: `run` for a run's replies, `evaluation` for an evaluation run's answers (its
judging is not included). Another installation's runs are never counted. A configuration
passed without a `ref` is the `agentRef: null` group. Highest cost first (most model calls
first when the cost is not shown), at most 100 groups; `truncated` is true when there are
more. Needs a member who may read the workspace's usage; `cost` is null for a member who
may not read its cost, never zero.

| Scope | ทำในนามของ | การยืนยันตัวตน | Idempotency-Key |
| --- | --- | --- | --- |
| `usage:read` | `member` | `installationToken` | — |

### พารามิเตอร์

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `workspaceId` | path | `string` | ใช่ | The workspace, by id. It must be the installation's. |
| `Agentlab-On-Behalf-Of` | header | `string` | ใช่ | The account id of the member the installation acts for: a current member of the workspace whose sign-in to the application there is still live, neither revoked nor expired. When the member's sign-in expires, the application acts for them again once they sign in again. |
| `sinceDays` | query | `integer` | ไม่ | The window, in days back from now. 30 when absent. ค่าที่เป็นไปได้: `7`, `30`, `90`. |
| `agentRef` | query | `string` | ไม่ | Only this `agentRef`, exactly as the configuration passed it. |

### คำตอบ

| สถานะ | เนื้อหา | คำอธิบาย |
| --- | --- | --- |
| `200` | `application/json`: [UsageReport](https://agentlab.cresclab.com/docs/th/api/schemas.md#UsageReport) | The installation's usage by agentRef. |
| `400` | `application/json`: [Error](https://agentlab.cresclab.com/docs/th/api/schemas.md#Error) | The request itself is wrong, such as a `cursor` this list did not answer (`recovery: none`). |
| `401` | `application/json`: [Error](https://agentlab.cresclab.com/docs/th/api/schemas.md#Error) | No token, or a token the platform does not honor. |
| `403` | `application/json`: [Error](https://agentlab.cresclab.com/docs/th/api/schemas.md#Error) | Refused: `SCOPE_NOT_GRANTED` (`configure`); `WORKSPACE_NOT_INSTALLED`, the path names a workspace other than the installation's (`configure`); `MEMBER_REQUIRED`, no single `Agentlab-On-Behalf-Of` (`none`); `MEMBER_NOT_AUTHORIZED`, the named account is not a current member who signed in to the application here, or the member may not read or do this (`authorize`); `SERVER_TO_SERVER_ONLY`, sent from a browser (`none`); `PRODUCT_ACCESS_DENIED`, the workspace's plan does not include it (`configure`). |
| `404` | `application/json`: [Error](https://agentlab.cresclab.com/docs/th/api/schemas.md#Error) | No such operation or resource. |
| `429` | `application/json`: [Error](https://agentlab.cresclab.com/docs/th/api/schemas.md#Error) | Rate limited (`recovery: retry`). |
| `503` | `application/json`: [Error](https://agentlab.cresclab.com/docs/th/api/schemas.md#Error) | Try again later (`recovery: retry`). |
