# 模型列表

查询当前 API Key 可访问的模型。请求中的 `model` 字段必须取自这里返回的 `id`。

**接口地址**：`GET https://YOUR_API_BASE_URL/v1/models`

- 鉴权：Bearer Token

返回模型列表。不需要请求体。

## 请求示例

**cURL**

```bash
curl "https://YOUR_API_BASE_URL/v1/models" \
  -H "Authorization: Bearer sk-xxxxxxxx"
```

**Python**

```python
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url=os.environ["API_BASE"] + "/v1",
)
for model in client.models.list().data:
    print(model.id)
```

**Node.js**

```javascript
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.API_KEY,
  baseURL: process.env.API_BASE + '/v1'
})
const list = await client.models.list()
for (const model of list.data) console.log(model.id)
```

## 请求参数

无路径参数、查询参数或请求体。

## 成功响应

HTTP `200`：

```json
{
  "success": true,
  "object": "list",
  "data": [
    {
      "id": "gpt-4o-mini",
      "object": "model",
      "created": 1626777600,
      "owned_by": "openai",
      "supported_endpoint_types": ["openai"]
    }
  ]
}
```

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `success` | boolean | 查询是否成功 |
| `object` | string | 固定为 `list` |
| `data` | array | 模型列表，可能为空 |
| `data[].id` | string | 请求中使用的完整模型 ID |
| `data[].object` | string | 固定为 `model` |
| `data[].created` | integer | Unix 秒时间戳，仅为元数据 |
| `data[].owned_by` | string | 模型来源标识 |
| `data[].supported_endpoint_types` | array | 支持的接口类型提示；可能为空数组 |
| `data[].video_capabilities` | object | 视频能力；仅视频模型返回，见下文 |
| `data[].asset_library` | object | 素材库能力；部分视频模型返回，见下文 |

### supported_endpoint_types

这个字段是网关内部的 EndpointType 枚举，取值如下：

| 值 | 对应接口 | 本文档 |
| --- | --- | --- |
| `openai` | OpenAI 兼容接口，默认 `/v1/chat/completions`；音频等 OpenAI 兼容接口也归在此类 | 是 |
| `openai-response` | `/v1/responses` | 是 |
| `openai-response-compact` | `/v1/responses/compact` | 是 |
| `openai-alpha-search` | `/v1/alpha/search`（Codex 搜索） | 否 |
| `anthropic` | `/v1/messages` | 是 |
| `gemini` | `/v1beta/models/{model}:generateContent` | 是 |
| `image-generation` | `/v1/images/generations`、`/v1/images/edits` | 是 |
| `openai-video` | `/v1/videos` | 是 |
| `embeddings` | `/v1/embeddings` | 否 |
| `jina-rerank` | `/v1/rerank` | 否 |

**提示**

- 没有 `openai-audio` 这个值；音频模型通常返回 `openai`。
- 数组可能有多个值，部分模型通常是 `["anthropic", "openai"]`，表示两种协议都能调。
- 这是能力提示，不是严格契约；模型参数支持范围仍需查看对应接口文档。
- 该字段由网关自动计算，调用方不能修改；值与预期不符时请联系服务方确认。

### video_capabilities

视频模型会返回该字段，描述创建任务时允许使用的参数；图片模型和文本模型通常没有该字段。以下仅为结构示例，实际取值以当前 Key 的响应为准：

```json
{
  "video_capabilities": {
    "version": 1,
    "profiles": [
      {
        "durations": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
        "supports_smart_duration": true,
        "default_duration": 5,
        "aspect_ratios": ["16:9", "4:3", "1:1", "3:4", "9:16", "21:9", "adaptive"],
        "resolutions": ["480p", "720p", "1080p"],
        "max_images": 9,
        "max_videos": 3,
        "max_audios": 3,
        "supports_image_alias": true,
        "supports_input_reference": true,
        "supports_metadata": true,
        "supports_generate_audio": true,
        "supports_watermark": true,
        "supports_first_last_frames": true
      }
    ]
  }
}
```

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `version` | integer | 能力结构版本 |
| `profiles` | array | 参数档位列表；创建任务时选择一个完整档位 |
| `profiles[].durations` | integer[] | 支持的时长（秒） |
| `profiles[].default_duration` | integer | 未指定时长时的默认值 |
| `profiles[].supports_smart_duration` | boolean | 是否支持智能时长；支持时可传 `-1` 由模型决定 |
| `profiles[].resolutions` | string[] | 支持的分辨率 |
| `profiles[].aspect_ratios` | string[] | 支持的画幅；`adaptive` 表示由模型决定 |
| `profiles[].max_images` / `max_videos` / `max_audios` | integer | 参考图片 / 视频 / 音频数量上限 |
| `profiles[].supports_first_last_frames` | boolean | 是否支持首尾帧 |
| `profiles[].supports_input_reference` | boolean | 是否支持 `input_reference` |
| `profiles[].supports_image_alias` | boolean | 是否支持图片别名字段 |
| `profiles[].supports_metadata` | boolean | 是否支持 `metadata` 扩展参数 |
| `profiles[].supports_generate_audio` | boolean | 是否支持生成音频 |
| `profiles[].supports_watermark` | boolean | 是否支持水印 |

**注意：按档位取值**

时长、分辨率、画幅和参考素材上限必须来自同一个 `profiles[]` 档位，不能把不同档位的值混用。某个 `max_*` 为 `0` 时不要传对应素材；没有能力配置时不要猜测取值。

### asset_library

部分视频模型会返回素材库能力；其他模型通常没有该字段。

```json
{
  "asset_library": {
    "supported": true,
    "asset_types": ["Image", "Video", "Audio"],
    "upload_endpoint": "/v1/assets",
    "requires_model": true
  }
}
```

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `supported` | boolean | 是否支持素材库 |
| `reason_code` | string | 不支持时的原因，例如 `asset_not_supported` |
| `asset_types` | string[] | 支持的素材类型，例如 `Image`、`Video`、`Audio` |
| `upload_endpoint` | string | 素材上传入口，通常为 `/v1/assets` |
| `requires_model` | boolean | 上传时是否必须携带 `model` |

- `supported` 为 `true`：先向 `upload_endpoint` 上传素材，保存返回的 `asset_id`，在任务中用 `asset://<asset_id>` 引用。
- `supported` 为 `false`：不要调用素材库接口，直接在任务中使用公网 HTTPS 地址。
- 素材约 60 分钟有效；成功提交任务后即被消费，提交失败不消费，可修正后重试。

素材库的完整用法见[视频生成](https://docs.myaigf.cfd/api/videos#模型能力与素材)。

## 单个模型

**接口地址**：`GET https://YOUR_API_BASE_URL/v1/models/{model}`

- 鉴权：Bearer Token

查询单个模型的元信息。

```bash
curl "https://YOUR_API_BASE_URL/v1/models/YOUR_MODEL" \
  -H "Authorization: Bearer sk-xxxxxxxx"
```

响应通常包含 `id`、`object`、`created`、`owned_by`。图片模型通常还会返回 `supported_endpoint_types`；视频模型还会返回 `supported_endpoint_types`、`video_capabilities` 和 `asset_library`。若模型不存在或未对当前 Key 开放，返回 `404`。

## 鉴权变体

| 协议 | 请求头 |
| --- | --- |
| OpenAI | `Authorization: Bearer sk-xxxxxxxx` |
| Anthropic | `x-api-key: sk-xxxxxxxx` + `anthropic-version: 2023-06-01` |
| Gemini | `x-goog-api-key: sk-xxxxxxxx` 或 `?key=sk-xxxxxxxx` |

使用 Anthropic 头调用时，返回结果会按 Anthropic 的模型列表格式组织；使用 Gemini 头时同理。

## 错误

| 状态码 | 含义 |
| --- | --- |
| `401` | Key 缺失、无效或过期 |
| `403` | Key 无权访问模型列表 / 账号异常 |

完整错误结构见[错误与重试](https://docs.myaigf.cfd/guide/errors)。

## 相关阅读

- [模型与分组](https://docs.myaigf.cfd/guide/models)：分组、计费和模型选择建议。
- [Chat Completions](https://docs.myaigf.cfd/api/chat)：文本对话接口。
