Skip to content

获取价目

查询模型的完整价目信息,包括计费单位、分段定价、分辨率档位和可选的变体折扣。

  • 传入 model 参数时返回单个模型的价目详情。
  • 不传 model 时返回全量价目列表,可用 modality 筛选。

JWT 登录后,响应中的价格字段会额外返回折后价(list_amountdiscount_factordiscount_label)。


Endpoint

MethodURL
GET{TRINITY_BASE_URL}/prices

Base URL

Base URLhttps://api.trinitydesk.ai/v1
协议HTTPS
bash
export TRINITY_BASE_URL="https://api.trinitydesk.ai/v1"
export TRINITY_API_KEY="xh-..."

Headers

Header必填说明
AuthorizationBearer <TRINITY_API_KEY>;JWT 登录时返回折后价
Acceptapplication/json

查询参数

参数必填类型说明
modelstring模型 code;传入时返回单模型价目,省略时返回列表
modalitystringtext | image | video;列表模式下筛选模态,单模型模式下用于消歧
localestring本地化语言,影响 displaylabel 等文案;默认 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}"

返回字段(单模型)

字段类型必有说明
objectstring固定 "model_prices"
modelstring模型 code
display_namestring通常有模型展示名
modality_typestringtext | image | video
charge_unitstring计费单位,如 tokenimage_countvideo_second
pricing_modestring计价模式标识,见下方说明
currencystring固定 "USD"
price_unitstring价格单位,如 per_million_tokensper_imageper_second
price_groupsarray通常有价目分组,结构随 pricing_mode 变化,见下方说明
price_variantsarray | null有时有可选的变体价目(如分时折扣),见下方说明
effective_variantstring | null有时有当前生效的变体 code
effective_variant_labelstring | null有时有当前生效的变体展示名
updated_atstring价目更新时间(ISO 8601)

pricing_mode

适用模态说明
context_length_rangetext按上下文长度分段计价,输入/输出/缓存输入各有独立分段
input_output_matrixtext输入区间 × 输出区间矩阵计价
image_tieredimage按分辨率档位计价
video_tieredvideo按分辨率档位计价
flat任意统一单价,不分段
legacytext旧版简单输入/输出单价

price_groups

price_groups 是一个数组,每个元素的结构取决于 pricing_mode

context_length_range(生文分段)

字段类型说明
typestring固定 "token_kind"
labelstring分组展示名,如 "输入 token · 按上下文长度"
token_kindstringinput | output | cached_input
rangesarray分段列表,见下方

image_tiered / video_tiered(分辨率档位)

字段类型说明
typestring固定 "resolution_tier"
labelstring档位展示名,如 "720p""1080p""4k"
conditions_summarystring条件摘要
conditionsobject条件详情,如 { "resolution": "720p" }
pricesobject键固定为 "unit",值为 PriceAmount

input_output_matrix(矩阵计价)

字段类型说明
typestring固定 "matrix"
tiersarray矩阵档位列表,见下方

Range

context_length_range 模式下 ranges[] 的元素:

字段类型说明
rangeobject{ min, max, display, display_short }maxnull 表示无上限
priceobjectPriceAmount

Tier

input_output_matrix 模式下 tiers[] 的元素:

字段类型说明
tier_idstring档位标识
labelstring档位展示名
input_rangeobject{ min, max, display, display_short }
output_rangeobject{ min, max, display, display_short }
pricesobject键为 inputoutput 等,值为 PriceAmount

PriceAmount

字段类型必有说明
amountstring单价金额
currencystring固定 "USD"
unitstring价格单位,如 per_million_tokensper_imageper_second
displaystring格式化展示文案,如 "$5 / 百万 input tokens"
list_amountstring仅 JWT折前原价
discount_factorstring仅 JWT折扣系数
discount_labelstring仅 JWT折扣展示名
list_displaystring仅 JWT折前格式化展示文案

未登录或 API Key 鉴权时不返回折后字段。

price_variants

部分模型支持变体价目(如分时折扣),登录用户可能命中不同变体:

字段类型说明
variantstring变体 code
labelstring变体展示名
scheduleobject | null分时调度信息,含 codetimezonewindows[]
price_groupsarray该变体下的价目分组,结构同上

返回字段(列表)

不传 model 时返回列表:

字段类型说明
objectstring固定 "list"
dataarray单模型价目 数组

返回示例

生文(分段计价)

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": [ ... ], ... }
  ]
}

错误码

HTTPerror.code场景
404model_not_found模型未上架、不存在或当前 Key 无访问权限
404pricing_not_configured模型存在但未配置价目
404ambiguous_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']}")

相关

© Trinity AI