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

# 查询用量

> GET /v1/dashboard/billing/usage —— 时间段内的消耗

查询指定时间区间内的累计消耗(单位:USD)。

## 请求

```bash theme={null}
curl "https://openp.ai/v1/dashboard/billing/usage?start_date=2026-05-01&end_date=2026-05-15" \
  -H "Authorization: Bearer $OPENPAI_API_KEY"
```

### Query 参数

| 参数           | 类型     |  必填 | 说明                 |
| ------------ | ------ | :-: | ------------------ |
| `start_date` | string |  ✅  | `YYYY-MM-DD`,包含此日  |
| `end_date`   | string |  ✅  | `YYYY-MM-DD`,不包含此日 |

最长跨度 100 天。

## 响应

```json theme={null}
{
  "object": "list",
  "total_usage": 12.43,
  "daily_costs": [
    {
      "timestamp": 1714521600,
      "line_items": [
        {"name": "gpt-5.5", "cost": 1.20},
        {"name": "gpt-5.5", "cost": 0.15}
      ]
    }
  ]
}
```

`total_usage` 单位是 **USD ×100**(即 12.43 = \$0.1243),与 OpenAI 官方约定一致。
但 OpenPAI 控制台 / 日志使用人民币展示,具体换算请以控制台为准。

## 更细粒度

如需逐请求级别的日志,使用控制台 → **日志** 页面,或专用 API:

```bash theme={null}
curl "https://openp.ai/api/log/self?page=1&page_size=50" \
  -H "Authorization: Bearer $OPENPAI_USER_TOKEN"
```

返回每一条调用的:模型、token、耗时、扣费、Request ID、IP 等。

## 客户端兼容

NextChat / ChatBox / LobeChat 等会调用此接口在 UI 上展示消耗趋势,
OpenPAI 完整支持以保证客户端 "Account 信息" 面板可用。
