Skip to main content

Documentation Index

Fetch the complete documentation index at: https://apidoc.deerapi.com/llms.txt

Use this file to discover all available pages before exploring further.

DeerAPI 提供四个接口用于查询账户余额、用量和 API Key 详情,适用于构建监控面板、设置低余额告警或验证 Key 配置。
接口Base URL认证方式金额单位
GET /user/quotaquery.deerapi.com查询参数 key美元
GET /v1/dashboard/billing/subscriptionapi.deerapi.comBearer Token美元
GET /v1/dashboard/billing/usageapi.deerapi.comBearer Token美分(0.01 美元)
GET /api/usage/tokenapi.deerapi.comBearer Token内部单位

余额查询

GET https://query.deerapi.com/user/quota 返回账户级余额、累计消耗、总请求次数以及各 API Key 的额度明细。该接口使用 query.deerapi.com 查询服务,通过 key 查询参数认证,而非 Bearer Token。
建议生成一个专门用于查询的 API Key,并将余额设置为 0(仅查询权限)。即使该 Key 泄露,攻击者也无法发起模型请求。

请求参数

参数类型必填描述
keystring你的 DeerAPI API Key

响应字段

字段类型描述
usernamestring用户名
total_quotanumber账户当前余额(单位:美元)
total_used_quotanumber账户累计消耗额度(单位:美元)
request_countinteger累计请求次数
keysarray各 API Key 的额度明细
keys[].namestringAPI Key 名称
keys[].remain_quotanumberKey 剩余额度,-1 表示无限额度
keys[].used_quotanumberKey 已用额度,-1 表示无限额度

代码示例

通过以下请求查询账户余额:
curl "https://query.deerapi.com/user/quota?key=$DEERAPI_KEY"

响应示例

{
  "username": "example_user",
  "total_quota": 2105.234088,
  "total_used_quota": 21.065912,
  "request_count": 1221,
  "keys": [
    {
      "name": "my-key",
      "remain_quota": 8.93872,
      "used_quota": 2.099206
    }
  ]
}

订阅信息查询(OpenAI 兼容)

GET https://api.deerapi.com/v1/dashboard/billing/subscription 以 OpenAI 兼容的订阅格式返回额度信息。所有 USD 字段表示总额度(剩余 + 已用)。如果你的工具已对接 OpenAI 计费 API,可直接使用该接口。

认证方式

在请求头中传递 Bearer Token:
Authorization: Bearer <DEERAPI_KEY>

响应字段

字段类型描述
objectstring对象类型,固定为 billing_subscription
has_payment_methodboolean账户是否有余额,有余额时为 true
soft_limit_usdnumber总额度(剩余 + 已用),单位:美元
hard_limit_usdnumber总额度,与 soft_limit_usd 相同
system_hard_limit_usdnumber总额度,与 soft_limit_usd 相同
access_untilintegerAPI Key 过期时间(Unix 时间戳),0 表示永不过期

代码示例

通过以下请求查询总额度:
curl "https://api.deerapi.com/v1/dashboard/billing/subscription" \
  -H "Authorization: Bearer $DEERAPI_KEY"

响应示例

{
  "object": "billing_subscription",
  "has_payment_method": true,
  "soft_limit_usd": 100.5,
  "hard_limit_usd": 100.5,
  "system_hard_limit_usd": 100.5,
  "access_until": 0
}

用量查询(OpenAI 兼容)

GET https://api.deerapi.com/v1/dashboard/billing/usage 以 OpenAI 兼容的计费格式返回累计用量。
total_usage 的单位是美分(0.01 美元)。需要除以 100 才能转换为美元。

认证方式

在请求头中传递 Bearer Token:
Authorization: Bearer <DEERAPI_KEY>

响应字段

字段类型描述
objectstring对象类型,固定为 list
total_usagenumber累计用量,单位:美分。除以 100 得到美元

代码示例

通过以下请求查询累计用量:
curl "https://api.deerapi.com/v1/dashboard/billing/usage" \
  -H "Authorization: Bearer $DEERAPI_KEY"

响应示例

{
  "object": "list",
  "total_usage": 5025.0
}

API Key 详情查询

GET https://api.deerapi.com/api/usage/token 返回当前 API Key 的详细信息,包括授予额度、使用量、模型限制和过期时间。适用于以编程方式检查单个 Key 的配置。

认证方式

在请求头中传递 Bearer Token:
Authorization: Bearer <DEERAPI_KEY>

响应字段

字段类型描述
codeboolean请求是否成功
messagestring状态信息
data.objectstring对象类型,固定为 token_usage
data.namestringAPI Key 名称
data.total_grantednumber该 Key 的总授予额度(内部单位)
data.total_usednumber该 Key 的已用额度(内部单位)
data.total_availablenumber该 Key 的剩余额度(total_grantedtotal_used
data.unlimited_quotaboolean该 Key 是否拥有无限额度
data.model_limitsobject | null模型级限制配置,未配置时为 null
data.model_limits_enabledboolean是否启用模型级额度限制
data.expires_atintegerKey 过期时间(Unix 时间戳),0 表示永不过期

代码示例

通过以下请求查询 API Key 详情:
curl "https://api.deerapi.com/api/usage/token" \
  -H "Authorization: Bearer $DEERAPI_KEY"

响应示例

{
  "code": true,
  "message": "ok",
  "data": {
    "object": "token_usage",
    "name": "my-token-name",
    "total_granted": 150000,
    "total_used": 50000,
    "total_available": 100000,
    "unlimited_quota": false,
    "model_limits": null,
    "model_limits_enabled": false,
    "expires_at": 0
  }
}