价格查询 API
查询模型的基础价和你的当前折扣,或根据输入参数估算某次请求的价格。
接口信息
| 项目 | 说明 |
|---|---|
| 接口路径 | /v1/models/price |
| HTTP 方法 | POST |
| Content-Type | application/json |
| 鉴权 | 通过 Authorization 头传 Bearer token |
请求
bash
curl -X POST "https://api.get3w.com/v1/models/price" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_id": "kling/kling-3/text-to-video",
"inputs": {
"prompt": "A cat walking on the beach at sunset",
"duration": 5,
"resolution": "1080p",
"generate_audio": true
}
}'python
import requests
response = requests.post(
"https://api.get3w.com/v1/models/price",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model_id": "kling/kling-3/text-to-video",
"inputs": {"duration": 5, "resolution": "1080p", "generate_audio": True},
},
timeout=(10, 60),
)
response.raise_for_status()
data = response.json()["data"]
print(f"Price: ${data['price']}, you pay: ${data['discounted_price']}")Body 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model_id | string | 是 | 模型 slug {provider_id}/{model_id}/{run_type},与列出模型返回的一致 |
inputs | object | 否 | 不传则返回基础价;传对象(包括 {})则估算具体请求的价格 |
inputs 的含义
是否传 inputs 决定了 price 的含义:
- 不传:
price是模型的基础价,与列出模型中的base_price一致。响应中仍会带上你账户的折扣。 - 传对象(包括
{}):用inputs覆盖模型 schema 的默认值后计价。没传的参数按默认值算,所以{}表示全部取默认值的请求。尚未提供的媒体(例如参考音频、视频)按 0 计,因此估价可能低于最终扣费。 只查询基础价和折扣:
json
{
"model_id": "kling/kling-3/text-to-video"
}响应
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
code | integer | 成功时为 200 | 200 |
message | string | 状态信息 | "success" |
data.model_id | string | 模型 slug | "kling/kling-3/text-to-video" |
data.price | number | 折扣前的原价(美元) | 0.857 |
data.discounted_price | number | 折扣后的应付金额(美元) | 0.686 |
data.discount_rate | number | 实付百分比。100 表示无折扣,80 表示 8 折 | 80 |
data.currency | string | 固定为 USD | "USD" |
响应示例
json
{
"code": 200,
"message": "success",
"data": {
"model_id": "kling/kling-3/text-to-video",
"price": 0.857,
"discounted_price": 0.686,
"discount_rate": 80,
"currency": "USD"
}
}计价错误
错误沿用 /v1/ 的标准错误格式。计价失败时,error 是带业务码的嵌套对象:
| HTTP | 业务码 | 含义 | 处理方式 |
|---|---|---|---|
| 404 | — | model_id 格式错误或模型不存在 | 用列出模型核对 slug |
| 400 | 1401 | 输入参数无效,例如给不接受通道的模型(Veo 3.1)传了 channel | 修正参数后重试 |
| 400 | 4005 | 无法计算价格 | 检查计价参数;参数正确仍失败请联系支持 |
json
{
"code": 400,
"error": {
"code": 4005,
"error": "Failed to calculate model price"
}
}请求失败时不会返回可用价格,也不会退回基础价。界面预览可以另发一个不带 inputs 的请求展示基础价,但它不能当作失败请求的报价。
注意事项
- 价格可能取决于
duration、resolution、generate_audio、channel等参数。 - 未知的
channel与提交任务时的处理一致:按模型的第一个通道计价;模型没有通道时忽略该参数。见通道。 price是原价;discounted_price是你的账户按当前等级需要支付的金额。- 提交任务时会重新计价(包括测量参考媒体),以提交时的扣费为准。