查询模型定价
按账号或自有 Key 视角查询当前模型定价目录
国内用户请注意: 中国大陆用户请使用 https://api.toapis.cn 作为接口地址 (Base URL). 文档示例中的 https://api.toapis.com 请替换为 https://api.toapis.cn.
使用说明
查询当前账户可用的模型定价目录, 包括每个模型的计费方式和单价. 指定 api_key_id 可查看某个自有 Key 视角下的目录. 与旧 GET /v1/pricing 共用同一套目录计算, 但鉴权方式, 参数和响应结构不同. 目录反映当前费率, 不是生成请求的报价, 也不用于估算总价或锁价.
实际扣费金额见实际费用与任务用量.
定价区域由账户决定, 不接受 region, group, after 或生成参数. 如果账户当前没有任何有效定价区域, 返回 503. 这个空结果不会保存为账户的定价区域配置. 账户视角使用账户有效基础分组. 指定 api_key_id 时额外应用目标 Key 的分组和模型限制.
目标 Key 已删除, 属于他人或带 scope 时统一返回 404, 分组不可用时返回 403 (code=13003). meta.key_status 只说明目标 Key 的配置状态, 不代表当前可用性.
完整目录会跳过无法确认价格的模型, 缺少价格不代表免费. 查询指定 model 时: 不在可见目录中返回 404 (code=16008), 可见但暂无已确认价格返回 503 (code=18029), 目录依赖不可用返回 503 (code=18028). 配置变化可能使分页游标失效, 同一分页过程中也不保证价格快照一致.
鉴权
Authorizationstring请求头必填系统访问令牌, 格式为 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 不接受模型 Key, 无需 X-User-Id. 共用规则见接入方式.
请求参数
api_key_idstring查询可选, 指定自有未删除普通模型 Key 的定价视角. 省略时使用账户配置; 停用, 过期和耗尽 Key 可查询配置价格, 不表示现在可调用.
modelstring查询精确模型 ID, 最多 255 字节.
typestring查询模型类型: image, video 或 audio.
limitinteger查询默认值: 100每页数量, 默认 100, 范围 1-100.
cursorstring查询上一页 next_cursor, 最多 2048 字节. 修改筛选或定价上下文后重新开始.
请求示例
请求示例
curl --request GET \
--url 'https://api.toapis.com/api/v1/pricing?type=image&limit=20' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.get(
"https://api.toapis.com/api/v1/pricing",
headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
params={"type": "image", "limit": "20"},
timeout=30,
)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.toapis.com/api/v1/pricing?type=image&limit=20", {
method: "GET",
headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());响应字段
示例使用虚构数据. 响应包装和错误处理见接入方式.
data.itemsarray模型目录, 每项包含 id, type 和 prices.
data.meta.currencystring币种, 固定为 USD.
data.meta.contextstring定价视角: account 或 api_key.
data.meta.api_key_idstring | null目标 Key ID, 账户视角为 null.
data.meta.key_statusstring | null目标 Key 状态, 账户视角为 null.
data.meta.regionstring账户有效区域: cn 或 global.
data.has_moreboolean是否还有下一页.
data.next_cursorstring | null下一页游标, 末页为 null.
prices[].groupstring该价格适用的路由分组. 使用自动分组的 API Key 可能收到多个分组.
prices[].conditionsobject价格成立的条件, 包含影响计价的模型默认值. 生成请求应与这些值匹配.
prices[].charge_typestring计费类型: per_request, per_second 或 per_token.
prices[].price_basisstring计费依据: request, output_seconds, output_videos, total_tokens 或 text_input_tokens.
prices[].unitstring价格单位: request, second, video 或 1m_tokens.
prices[].unit_pricestring以十进制字符串返回的 USD 生效单价. 该价格已包含客户价格和分组倍率, 不要再次乘以分组倍率.
价格还可能包含 input_unit_price, input_image_unit_price, free_input_image_count, minimum_charge_usd 或 image_token_prices.
分时价格还可能包含 pricing_period, pricing_timezone, pricing_schedule_version 和 pricing_peak_windows.
图片 token 计价中的 image_token_prices 可包含 text_input, cached_text_input, image_input, cached_image_input 和 image_output. 每项金额单位均为 USD/100 万 tokens.
响应示例
响应示例
{
"code": 0,
"message": "",
"data": {
"items": [
{
"id": "example-image-model",
"type": "image",
"prices": [
{
"charge_type": "per_request",
"unit": "request",
"unit_price": "0.05",
"price_basis": "request",
"group": "default",
"conditions": {
"size": "1024x1024"
}
}
]
}
],
"has_more": false,
"next_cursor": null,
"meta": {
"currency": "USD",
"context": "account",
"api_key_id": null,
"key_status": null,
"region": "global"
}
}
}