账户额度与价格目录
查询 API Key 的可用 credits,并获取当前 Key 可见的模型价格目录。
鉴权
两个端点都供服务端调用。使用 Authorization: Bearer <API_KEY> 鉴权。请把 Key 保存在自己的后端,不要放进浏览器代码。
可用额度
GET
/v1/account/credits返回当前 API Key 对应账户的可用 credits,以及该 Key 剩余的消费限额。
curl https://u-token.ai/v1/account/credits \\
-H "Authorization: Bearer sk-你的KEY"{
"data": {
"credits": "1250.500000",
"outstanding": "12.300000",
"currency": "credits",
"credits_per_usd": "100",
"key_limit": {
"limit": "500.000000",
"spent": "120.250000",
"remaining": "359.750000"
},
"updated_at": "2026-09-18T09:00:00.000Z"
}
}credits是准入检查使用的可用账户余额。outstanding已经从它里面扣除,不要再次减去outstanding。outstanding是尚未结算的 LLM 用量、尚未结算的图片用量和媒体任务在途占位三者之和。- Key 未设置限额时
key_limit为null。有设置时,remaining为limit − spent − reserved(与准入同一限额桶)。上例是500 − 120.25 − 20占位。开始高成本请求前应同时检查credits与key_limit.remaining。 - 所有金额字段都是十进制字符串,金额使用 6 位小数;
credits_per_usd根据当前积分价格推导。 updated_at是本次余额读取的时间。命中提供方缓存时,会返回缓存写入时间。- 本响应不包含授信或其他借贷字段。
错误
| HTTP 状态 | error.type | 含义 |
|---|---|---|
401 | authentication_error | Key 缺失、无效、停用或不可用。 |
503 | internal_error | 无法读取账户余额;响应包含 error.code 与 error.request_id。 |
503 表示余额暂时不可读取,不表示账户余额为 0。不要把它替换成零余额。
模型价格目录
GET
/v1/models/pricing返回当前 API Key 实际可以调用的模型和渠道的单一、按 Key 裁剪的价格目录。
curl https://u-token.ai/v1/models/pricing \\
-H "Authorization: Bearer sk-你的KEY"响应只有一个目录版本,data 使用可向前兼容的分组数组:
{
"catalog_version": "c1f0a9e2",
"generated_at": "2026-09-18T09:00:00.000Z",
"currency": "credits",
"credits_per_usd": "100",
"data": [
{
"kind": "llm",
"price_unit": "1M_tokens",
"list": [
{
"model": "claude-sonnet-5",
"display_name": "Claude Sonnet 5",
"channel": "flex",
"channel_name": "订阅号直供",
"official_input": "200.000000",
"official_output": "1000.000000",
"input_price": "70.000000",
"output_price": "350.000000",
"cache_read_price": "7.000000",
"cache_write_price": "87.500000",
"cache_write_1h_price": "140.000000"
}
]
},
{
"kind": "media",
"price_unit": "per_call",
"list": [
{
"model": "gpt-image-2",
"display_name": "GPT Image 2",
"channel": "standard",
"channel_name": "官方 API 中转",
"reference_price": "5.000000",
"reference_note": "每张图片;质量与分辨率决定锁定的任务价格",
"call_price": "3.350000",
"token_prices": [{ "meter": "text_input", "price": "3.350000" }]
}
]
}
]
}读取目录
- 必须按
(model, channel)取价。同一个模型在standard(官方 API 中转)和flex(订阅号直供)下可能有不同价格。 data是分组数组,不是固定的llm/media对象。不同kind的组和行字段不同;遇到未知kind时应跳过,不要报错。平台新增品类不会改变已有分组。- 即使当前 Key 没有某个品类的授权,平台仍会返回该品类分组;此时
list为空,并可能带empty_reason: "no_authorization"。 - LLM 价格单位是每 1M tokens 的 credits。未单独配置缓存读价格时,
cache_read_price回退为模型输入价。缓存写价格只对 Anthropic 兼容渠道填充,其他行返回null。 - 媒体
reference_price只是参考价。参数化媒体任务以创建时锁定的价格为准,最终实收不保证等于reference_price。媒体行还可能提供token_prices,这部分应按实际 usage 对账。 - 目录没有价格预告期,也没有历史目录版本。应使用每次调用的
x-aitoken-request-id和该调用记录的牌价快照对账,不要把catalog_version当成账务记录。
使用 ETag 轮询
保存响应体和 ETag,下一次请求带上 If-None-Match:
curl -i https://u-token.ai/v1/models/pricing \\
-H "Authorization: Bearer sk-你的KEY" \\
-H 'If-None-Match: "c1f0a9e2"'目录未变化时返回 304 Not Modified 且无响应体。价格、授权范围或模型目录变化后,会生成新的 catalog_version 与 ETag。
这两个账户与目录端点不使用 LLM 账户限流,也不再占用已退役的按 Key / 按 IP 共享额度。每个响应都包含 x-aitoken-request-id,请保留它用于支持与对账。价格目录源数据无法读取时返回包含 pricing_unavailable 的 503;不要把空目录当作读取失败响应。
