获取价目
查询模型的完整价目信息,包括计费单位、分段定价、分辨率档位和可选的变体折扣。
- 传入
model参数时返回单个模型的价目详情。 - 不传
model时返回全量价目列表,可用modality筛选。
JWT 登录后,响应中的价格字段会额外返回折后价(list_amount、discount_factor、discount_label)。
Endpoint
| Method | URL |
|---|---|
GET | {TRINITY_BASE_URL}/prices |
Base URL
| 项 | 值 |
|---|---|
| Base URL | https://api.trinitydesk.ai/v1 |
| 协议 | HTTPS |
bash
export TRINITY_BASE_URL="https://api.trinitydesk.ai/v1"
export TRINITY_API_KEY="xh-..."Headers
| Header | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer <TRINITY_API_KEY>;JWT 登录时返回折后价 |
Accept | 否 | application/json |
查询参数
| 参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
model | 否 | string | 模型 code;传入时返回单模型价目,省略时返回列表 |
modality | 否 | string | text | image | video;列表模式下筛选模态,单模型模式下用于消歧 |
locale | 否 | string | 本地化语言,影响 display、label 等文案;默认 zh |
请求示例
bash
# 单模型价目
curl -sS "${TRINITY_BASE_URL}/prices?model=gpt-5.5" \
-H "Authorization: Bearer ${TRINITY_API_KEY}"
# 按模态筛选列表
curl -sS "${TRINITY_BASE_URL}/prices?modality=image" \
-H "Authorization: Bearer ${TRINITY_API_KEY}"
# 指定语言
curl -sS "${TRINITY_BASE_URL}/prices?model=kling-2.6&modality=video&locale=en" \
-H "Authorization: Bearer ${TRINITY_API_KEY}"返回字段(单模型)
| 字段 | 类型 | 必有 | 说明 |
|---|---|---|---|
object | string | 是 | 固定 "model_prices" |
model | string | 是 | 模型 code |
display_name | string | 通常有 | 模型展示名 |
modality_type | string | 是 | text | image | video |
charge_unit | string | 是 | 计费单位,如 token、image_count、video_second |
pricing_mode | string | 是 | 计价模式标识,见下方说明 |
currency | string | 是 | 固定 "USD" |
price_unit | string | 是 | 价格单位,如 per_million_tokens、per_image、per_second |
price_groups | array | 通常有 | 价目分组,结构随 pricing_mode 变化,见下方说明 |
price_variants | array | null | 有时有 | 可选的变体价目(如分时折扣),见下方说明 |
effective_variant | string | null | 有时有 | 当前生效的变体 code |
effective_variant_label | string | null | 有时有 | 当前生效的变体展示名 |
updated_at | string | 是 | 价目更新时间(ISO 8601) |
pricing_mode
| 值 | 适用模态 | 说明 |
|---|---|---|
context_length_range | text | 按上下文长度分段计价,输入/输出/缓存输入各有独立分段 |
input_output_matrix | text | 输入区间 × 输出区间矩阵计价 |
image_tiered | image | 按分辨率档位计价 |
video_tiered | video | 按分辨率档位计价 |
flat | 任意 | 统一单价,不分段 |
legacy | text | 旧版简单输入/输出单价 |
price_groups
price_groups 是一个数组,每个元素的结构取决于 pricing_mode:
context_length_range(生文分段)
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定 "token_kind" |
label | string | 分组展示名,如 "输入 token · 按上下文长度" |
token_kind | string | input | output | cached_input |
ranges | array | 分段列表,见下方 |
image_tiered / video_tiered(分辨率档位)
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定 "resolution_tier" |
label | string | 档位展示名,如 "720p"、"1080p"、"4k" |
conditions_summary | string | 条件摘要 |
conditions | object | 条件详情,如 { "resolution": "720p" } |
prices | object | 键固定为 "unit",值为 PriceAmount |
input_output_matrix(矩阵计价)
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定 "matrix" |
tiers | array | 矩阵档位列表,见下方 |
Range
context_length_range 模式下 ranges[] 的元素:
| 字段 | 类型 | 说明 |
|---|---|---|
range | object | { min, max, display, display_short };max 为 null 表示无上限 |
price | object | PriceAmount |
Tier
input_output_matrix 模式下 tiers[] 的元素:
| 字段 | 类型 | 说明 |
|---|---|---|
tier_id | string | 档位标识 |
label | string | 档位展示名 |
input_range | object | { min, max, display, display_short } |
output_range | object | { min, max, display, display_short } |
prices | object | 键为 input、output 等,值为 PriceAmount |
PriceAmount
| 字段 | 类型 | 必有 | 说明 |
|---|---|---|---|
amount | string | 是 | 单价金额 |
currency | string | 是 | 固定 "USD" |
unit | string | 是 | 价格单位,如 per_million_tokens、per_image、per_second |
display | string | 是 | 格式化展示文案,如 "$5 / 百万 input tokens" |
list_amount | string | 仅 JWT | 折前原价 |
discount_factor | string | 仅 JWT | 折扣系数 |
discount_label | string | 仅 JWT | 折扣展示名 |
list_display | string | 仅 JWT | 折前格式化展示文案 |
未登录或 API Key 鉴权时不返回折后字段。
price_variants
部分模型支持变体价目(如分时折扣),登录用户可能命中不同变体:
| 字段 | 类型 | 说明 |
|---|---|---|
variant | string | 变体 code |
label | string | 变体展示名 |
schedule | object | null | 分时调度信息,含 code、timezone、windows[] |
price_groups | array | 该变体下的价目分组,结构同上 |
返回字段(列表)
不传 model 时返回列表:
| 字段 | 类型 | 说明 |
|---|---|---|
object | string | 固定 "list" |
data | array | 单模型价目 数组 |
返回示例
生文(分段计价)
json
{
"object": "model_prices",
"model": "gpt-5.5",
"display_name": "GPT-5.5",
"modality_type": "text",
"charge_unit": "token",
"pricing_mode": "context_length_range",
"currency": "USD",
"price_unit": "per_million_tokens",
"price_groups": [
{
"type": "token_kind",
"label": "输入 token · 按上下文长度",
"token_kind": "input",
"ranges": [
{
"range": { "min": 0, "max": 272000, "display": "0 – 272K tokens", "display_short": "≤ 272K" },
"price": { "amount": "5", "currency": "USD", "unit": "per_million_tokens", "display": "$5 / 百万 input tokens" }
},
{
"range": { "min": 272001, "max": null, "display": "> 272K tokens", "display_short": "> 272K" },
"price": { "amount": "10", "currency": "USD", "unit": "per_million_tokens", "display": "$10 / 百万 input tokens" }
}
]
},
{
"type": "token_kind",
"label": "输出 token · 按上下文长度",
"token_kind": "output",
"ranges": [
{
"range": { "min": 0, "max": 272000, "display": "0 – 272K tokens", "display_short": "≤ 272K" },
"price": { "amount": "30", "currency": "USD", "unit": "per_million_tokens", "display": "$30 / 百万 output tokens" }
},
{
"range": { "min": 272001, "max": null, "display": "> 272K tokens", "display_short": "> 272K" },
"price": { "amount": "45", "currency": "USD", "unit": "per_million_tokens", "display": "$45 / 百万 output tokens" }
}
]
}
],
"updated_at": "2026-06-05T07:22:08.196614Z"
}生图(分辨率档位)
json
{
"object": "model_prices",
"model": "GG-2.5",
"display_name": "Nano-2.5",
"modality_type": "image",
"charge_unit": "image_count",
"pricing_mode": "image_tiered",
"currency": "USD",
"price_unit": "per_image",
"price_groups": [
{
"type": "resolution_tier",
"label": "1k",
"conditions_summary": "1k",
"conditions": { "variant": "-", "pricing_tier": "1k", "resolution_tier": "1k" },
"prices": {
"unit": { "amount": "0.0414", "currency": "USD", "unit": "per_image", "display": "$0.0414 / 张" }
}
},
{
"type": "resolution_tier",
"label": "4k",
"conditions_summary": "4k",
"conditions": { "variant": "-", "pricing_tier": "4k", "resolution_tier": "4k" },
"prices": {
"unit": { "amount": "0.0635", "currency": "USD", "unit": "per_image", "display": "$0.0635 / 张" }
}
}
],
"updated_at": "2026-06-08T16:00:00Z"
}生视频(分辨率档位)
json
{
"object": "model_prices",
"model": "kling-2.6",
"display_name": "Kling-2.6",
"modality_type": "video",
"charge_unit": "video_second",
"pricing_mode": "video_tiered",
"currency": "USD",
"price_unit": "per_second",
"price_groups": [
{
"type": "resolution_tier",
"label": "720p",
"conditions_summary": "720p",
"conditions": { "resolution": "720p" },
"prices": {
"unit": { "amount": "0.042", "currency": "USD", "unit": "per_second", "display": "$0.042 / 秒" }
}
},
{
"type": "resolution_tier",
"label": "1080p",
"conditions_summary": "1080p",
"conditions": { "resolution": "1080p" },
"prices": {
"unit": { "amount": "0.14", "currency": "USD", "unit": "per_second", "display": "$0.14 / 秒" }
}
}
],
"updated_at": "2026-05-20T16:00:00Z"
}JWT 折后价
登录后,price 对象额外返回折后字段:
json
{
"amount": "4",
"currency": "USD",
"unit": "per_million_tokens",
"display": "$4 / 百万 input tokens",
"list_amount": "5",
"discount_factor": "0.8",
"discount_label": "企业版 8 折",
"list_display": "$5 / 百万 input tokens"
}列表
json
{
"object": "list",
"data": [
{ "object": "model_prices", "model": "gpt-5.5", "modality_type": "text", "price_groups": [ ... ], ... },
{ "object": "model_prices", "model": "GG-2.5", "modality_type": "image", "price_groups": [ ... ], ... }
]
}错误码
| HTTP | error.code | 场景 |
|---|---|---|
| 404 | model_not_found | 模型未上架、不存在或当前 Key 无访问权限 |
| 404 | pricing_not_configured | 模型存在但未配置价目 |
| 404 | ambiguous_model_code | 同名 code 匹配多个模态且未传 modality |
完整错误码见 错误与调试。
Python 示例
python
import os
import requests
r = requests.get(
f"{os.environ['TRINITY_BASE_URL']}/prices",
headers={"Authorization": f"Bearer {os.environ['TRINITY_API_KEY']}"},
params={"model": "gpt-5.5", "locale": "zh"},
timeout=60,
)
r.raise_for_status()
prices = r.json()
for group in prices.get("price_groups", []):
print(f"[{group['label']}]")
for rng in group.get("ranges", []):
price = rng["price"]
print(f" {rng['range']['display']} → {price['display']}")
for tier_label, price in group.get("prices", {}).items():
print(f" {group['label']} → {price['display']}")