> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sunra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 价格

[sunra.ai](https://sunra.ai/models) 的每个模型页都会在模型名旁展示各 endpoint 的价格，例如 `$0.045-$0.09 per image`。把鼠标悬停在价格上会显示 tooltip，说明具体规则（例如不同分辨率或选项对价格的影响）。

对于绝大多数模型，单次请求的价格**在提交时即已确定**：价格由你的请求参数计算得出，模型运行前就已锁定，[账单流水](https://sunra.ai/dashboard/billing) 中的扣费就是这个金额。相同参数的请求价格永远相同，可以精确预算。少数模型（例如按输出秒数计费的视频模型）在完成后按实际用量结算，其 tooltip 中会注明。

## Pricing API

价格可以通过 API 编程读取——既有人读字符串，也有机器可读的规则。

| Endpoint                                                        | 鉴权      | 说明                                  |
| --------------------------------------------------------------- | ------- | ----------------------------------- |
| api.sunra.ai/v1/pricing                                         | API key | 列出所有模型的 `display` 与 `tooltip` 价格字符串 |
| api.sunra.ai/v1/models                                          | 无需      | 列出所有模型，可查到模型 `id`                   |
| api.sunra.ai/v1/pricing/model/\{model\_id}/endpoint/\{endpoint} | 无需      | 单个 endpoint 的完整机器可读价格规则             |

要在发送请求前精确计算价格，先查模型 `id`：

```bash theme={null}
curl -s "https://api.sunra.ai/v1/models?limit=300" \
  | jq '.data[] | select(.alias == "bytedance/seedream-5.0-pro") | .id'
# "model_b63ac71d3992"
```

再获取目标 endpoint 的价格规则：

```bash theme={null}
curl -s "https://api.sunra.ai/v1/pricing/model/model_b63ac71d3992/endpoint/image-editing"
```

```json theme={null}
{
  "id": "mep_e5e2c1437feb",
  "object": "model_endpoint_price",
  "model_name": "seedream-5.0-pro",
  "model_endpoint": "image-editing",
  "display": "$0.045-$0.126 per image",
  "tooltip": "1K: $0.045, 2K: $0.09 per image, +$0.004 per reference image from the 2nd",
  "type": "pre_defined",
  "prices": [
    { "unit_amount": "0.045", "matches": { "resolution": "1K", "images": { "$size_lte": 1 } } },
    { "unit_amount": "0.049", "matches": { "resolution": "1K", "images": { "$size": 2 } } },
    { "unit_amount": "0.09",  "matches": { "images": { "$size_lte": 1 } } },
    { "unit_amount": "0.094", "matches": { "images": { "$size": 2 } } },
    { "unit_amount": "0.126" }
  ]
}
```

## 价格规则如何生效

`prices` 数组**自上而下与请求参数逐行匹配**，第一条 `matches` 条件全部成立的行决定价格。没有 `matches` 的行恒成立——即兜底价。

条件与请求参数的比较方式：

| 条件                                      | 含义                                                              |
| --------------------------------------- | --------------------------------------------------------------- |
| `"resolution": "1K"`                    | 参数与值完全相等                                                        |
| `"duration": { "$gte": 5, "$lte": 10 }` | 数值参数在区间内（支持 `$gt`、`$gte`、`$lt`、`$lte`、`$in`、`$nin`）             |
| `"images": { "$size": 3 }`              | 数组参数恰好 3 个元素（区间用 `$size_gt`、`$size_gte`、`$size_lt`、`$size_lte`） |

**请求中未传的参数不会匹配任何条件**——匹配前不会填充默认值。价格表的行序已按此设计：省略可选参数会落到其默认行为对应的行。

以上表为例：

* `{"images": [a], "resolution": "1K"}` → 第一行 → **\$0.045**
* `{"images": [a, b, c], "resolution": "1K"}` → 1K 且 `$size: 3` 的行 → **\$0.053**
* `{"images": [a]}`（省略 resolution，模型默认 2K）→ 跳过 1K 各行，命中 `$size_lte: 1` → **\$0.09**

若命中的行带有 `usage_key`，则金额为 `unit_amount ×` 该参数的值（例如按请求时长每秒计价）。

LLM 模型（chat、messages、responses）按 token 计费——见 [sunra.ai/models](https://sunra.ai/models?type=llm) 各模型价格页及 `GET /v1/pricing/model/{model_id}/endpoint/llm`。
