跳到主要内容

Regular Key 自助查询

只接受 Regular Key,返回所属账户当前总余额和当前 Key 的余额信息。

以下 Regular Key 状态仍允许查询并返回 200:

  • 手工禁用;
  • 已过期;
  • 额度已耗尽;
  • 待订阅生效。

已删除、伪造或无法识别的 Key 返回 401 invalid_api_key;账户被禁用返回 403 account_disabled。

请求参数: 无

响应示例

{
"object": "self_balance",
"currency": "USD",
"as_of": "2026-08-08T06:30:00Z",
"account": {
"total_balance": "850",
"paid_balance": null,
"free_balance": null,
"breakdown_status": "unavailable"
},
"key": {
"id": "key_01JPRODUCTION",
"name": "Production Server",
"key_type": "regular",
"disabled": false,
"manually_disabled": false,
"limit": "200",
"limit_reset": "monthly",
"quota_scope": "usage",
"period": {
"start": "2026-07-21T08:30:00Z",
"end_exclusive": "2026-08-21T08:30:00Z"
},
"consumed_this_period": "85.5",
"consumed_today": "2.3",
"key_limit_remaining": "114.5",
"remaining": "114.5",
"effective_remaining": "114.5",
"usage_pct": "42.75",
"status": "active",
"status_reason": null
}
}

自助接口不返回以下敏感或管理型数据:

  • 账户累计消费 total_consumed;
  • Key lifetime 消费 consumed.all_time;
  • 按模型消费 consumed.by_model;
  • 其他 Key 的任何信息。

Management Key 调用本接口固定返回 403 forbidden_scope。

自助接口说明

即使 Key 已手工禁用、过期、额度耗尽或待订阅生效,仍可查询自身余额并返回 200。自助接口不返回账户累计消费、Key lifetime 消费、按模型消费以及其他 Key 的信息。

相关接口

通用请求约定、字段定义与错误码见 余额查询接口概览。

在线客服