# 模型与价格

下面这些公开接口说明你能调用什么、价格是多少，都不需要密钥。

## GET /v1/models

OpenAI 风格的列表（`object: list`、`data[]`）。每个模型有 `id`、`object`、`created`、`owned_by` 和 `category`（`chat`、`image`、`video`、`music` 或 `audio`）。已知时还会带 `name`、`description`、`context_length`、`architecture`、`top_provider`、`supported_parameters` 和 `pricing`。列表缓存约一分钟。

```bash
curl https://api.novapi.ai/v1/models

{
  "object": "list",
  "data": [
    {
      "id": "<model-id>",
      "object": "model",
      "owned_by": "<vendor>",
      "category": "chat",
      "pricing": {
        "prompt": "<credits per token>",
        "completion": "<credits per token>",
        "unit": "points_per_token"
      }
    }
  ]
}
```

## 价格字段

价格是字符串，单位是积分（不是美元），为标价，不含个人折扣。请按 `pricing.unit` 解读。没有 `pricing` 表示目录里没有该模型的价格，不代表免费。 想看含个人折扣的价格，或在提交前给某次请求询价，见「模型价格查询」页。

| pricing.unit | 字段 | 含义 |
| --- | --- | --- |
| `points_per_token` | `prompt`、`completion`、`input_cache_read`、`input_cache_write`（5 分钟缓存写入）、`input_cache_write_1h`（1 小时缓存写入，仅在配置了该档价格时返回） | 每 token 积分 |
| `points_per_request` | `request` | 每次调用或任务积分 |
| `points_per_second` | `request` | 每秒积分 |
| `points_per_image` | `request` | 每张图片积分 |

生成类模型可能带 `tiers`（例如按分辨率或模式）。此时 `request` 是最低档，请显示为「起」；每一档有各自的 `price` 和 `unit`。

## GET /v1/models/{id}

返回单个模型对象。id 可以包含斜杠。id 不存在时返回 404 `model_not_found`。

## GET /v1/models/{id}/endpoints

列出模型配置的提供方：`provider`、`priority`、`weight`、`status`。`status` 只来自本服务自身的失败计数，取值 `ok`、`degraded`、`unavailable`；没有这类数据时为 `unknown`。它不是延迟或可用率指标。基址与凭证不会暴露。

```bash
curl https://api.novapi.ai/v1/models/<model-id>/endpoints

{
  "object": "list",
  "model": "<model-id>",
  "data": [
    { "provider": "<name>", "priority": <int>, "weight": <int>, "status": "ok" }
  ]
}
```

## GET /api/cqt/models

第二个公开列表，无需密钥。外形与 OpenAI 的 `GET /v1/models` 一致，但所有价格都以积分计（100 积分 = 1 美元）。生成类模型带有通过生成器提交所需的 `channel` 和 `endpoint_mode`。加 `?category=chat`、`image`、`video` 或 `audio` 可以筛选。与 `GET /v1/models` 不同的是，这里的价格是数字，`pricing` 对象包含 `currency`、`unit`，以及 token 价格或 `price` / `tiers`。

```bash
curl https://api.novapi.ai/api/cqt/models

# only one category: ?category=chat | image | video | music | audio
curl "https://api.novapi.ai/api/cqt/models?category=video"
```

```json
{
  "object": "list",
  "data": [
    {
      "id": "<chat-model-id>",
      "object": "model",
      "created": 0,
      "owned_by": "<vendor>",
      "category": "chat",
      "name": "<chat-model-id>",
      "pricing": {
        "currency": "credits",
        "unit": "token",
        "input_per_million": 2500,
        "output_per_million": 10000,
        "cache_write_per_million": 3125,
        "cache_read_per_million": 250,
        "rate": 1
      }
    },
    {
      "id": "happyhorse-1.0-i2v",
      "object": "model",
      "created": 0,
      "owned_by": "<vendor>",
      "category": "video",
      "channel": "qwen",
      "endpoint_mode": "async",
      "pricing": {
        "currency": "credits",
        "unit": "per_second",
        "tiers": [
          { "key": "720P", "label": "720P", "unit": "per_second", "price": 90 },
          { "key": "1080P", "label": "1080P", "unit": "per_second", "price": 160 }
        ]
      }
    }
  ]
}
```

上面的模型和数值只是示例，以实际响应为准。

| 字段 | 说明 |
| --- | --- |
| `id` | 模型名，也就是调用时传的 `model` 值。 |
| `owned_by` | 模型厂商。 |
| `category` | 类型：`chat`、`image`、`video`、`audio` 等。 |
| `channel` | 仅生成类模型有。通过 `POST /api/cqt/generator/{channel}` 提交。 |
| `endpoint_mode` | 仅生成类模型有：`async` 或 `sync`，见「模型价格查询」。 |
| `created` | 为兼容 OpenAI 保留，恒为 `0`。 |
| `pricing.currency` | 恒为 `credits`。 |
| `pricing.unit` | 计费单位：`token`、`per_call`、`per_image`、`per_second` 或 `per_task`。 |

- 对话模型（`unit: token`）：`input_per_million` 和 `output_per_million` 是每百万 token 的积分；实际扣费 = 用量 × 单价 × `rate`。`cache_*` 字段只在模型有缓存价格时出现。一口价的对话模型（`unit: per_call`）只有 `price`，不乘 `rate`。
- 生成类模型：只有一个价格时给 `price`；有多档（分辨率、时长等）时 `price` 为空，每一档列在 `tiers` 里。各档是互斥还是叠加取决于模型，所以不要直接相加。
- 没有 `price` 或 `tiers` 的模型不一定是没公布价格：可能是免费的准备步骤（价格 0）、提交时无法得知最终价的后付费模型，或尚未公布。拿不准时，用实际参数询价。
- 这里是标价。如果你的账号有个人折扣，实际扣费还要再乘折扣；含折扣的价目表和按请求的报价见「模型价格查询」。

## GET /v1/rankings

全平台匿名的请求量排名。查询参数：`period`（`day`、`week`、`month`，默认 `week`，为滚动窗口）、`category`（默认 `chat`）、`limit`（默认 20，最大 50）。每条含 `rank`、`model`、`requests`、`share`。用户可以选择退出；使用人数过少的模型不会出现，所以榜单可能很短甚至为空。结果缓存约 10 分钟。

```bash
curl "https://api.novapi.ai/v1/rankings?period=week&category=chat&limit=10"

{
  "object": "list",
  "period": "week",
  "category": "chat",
  "generated_at": <unix-seconds>,
  "data": [
    { "rank": 1, "model": "<model-id>", "requests": <int>, "share": <0..1> }
  ]
}
```

## 相关链接
- [模型价格查询](https://www.novapi.ai/zh/docs/guide/pricing)
- [模型目录](https://www.novapi.ai/zh/pricing)
- [排名](https://www.novapi.ai/zh/rankings)
