Skip to content

模型列表 ​

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

GEThttps://YOUR_API_BASE_URL/v1/models
鉴权:Bearer Token
返回模型列表。不需要请求体。

请求示例 ​

bash
curl "https://YOUR_API_BASE_URL/v1/models" \
  -H "Authorization: Bearer sk-xxxxxxxx"
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)
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"]
    }
  ]
}
字段类型说明
successboolean查询是否成功
objectstring固定为 list
dataarray模型列表,可能为空
data[].idstring请求中使用的完整模型 ID
data[].objectstring固定为 model
data[].createdintegerUnix 秒时间戳,仅为元数据
data[].owned_bystring模型来源标识
data[].supported_endpoint_typesarray支持的接口类型提示;可能为空数组
data[].video_capabilitiesobject视频能力;仅视频模型返回,见下文
data[].asset_libraryobject素材库能力;部分视频模型返回,见下文

supported_endpoint_types ​

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

值对应接口本文档
openaiOpenAI 兼容接口,默认 /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否

TIP

  • 没有 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
      }
    ]
  }
}
字段类型说明
versioninteger能力结构版本
profilesarray参数档位列表;创建任务时选择一个完整档位
profiles[].durationsinteger[]支持的时长(秒)
profiles[].default_durationinteger未指定时长时的默认值
profiles[].supports_smart_durationboolean是否支持智能时长;支持时可传 -1 由模型决定
profiles[].resolutionsstring[]支持的分辨率
profiles[].aspect_ratiosstring[]支持的画幅;adaptive 表示由模型决定
profiles[].max_images / max_videos / max_audiosinteger参考图片 / 视频 / 音频数量上限
profiles[].supports_first_last_framesboolean是否支持首尾帧
profiles[].supports_input_referenceboolean是否支持 input_reference
profiles[].supports_image_aliasboolean是否支持图片别名字段
profiles[].supports_metadataboolean是否支持 metadata 扩展参数
profiles[].supports_generate_audioboolean是否支持生成音频
profiles[].supports_watermarkboolean是否支持水印

按档位取值

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

asset_library ​

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

json
{
  "asset_library": {
    "supported": true,
    "asset_types": ["Image", "Video", "Audio"],
    "upload_endpoint": "/v1/assets",
    "requires_model": true
  }
}
字段类型说明
supportedboolean是否支持素材库
reason_codestring不支持时的原因,例如 asset_not_supported
asset_typesstring[]支持的素材类型,例如 Image、Video、Audio
upload_endpointstring素材上传入口,通常为 /v1/assets
requires_modelboolean上传时是否必须携带 model
  • supported 为 true:先向 upload_endpoint 上传素材,保存返回的 asset_id,在任务中用 asset://<asset_id> 引用。
  • supported 为 false:不要调用素材库接口,直接在任务中使用公网 HTTPS 地址。
  • 素材约 60 分钟有效;成功提交任务后即被消费,提交失败不消费,可修正后重试。

素材库的完整用法见视频生成。

单个模型 ​

GEThttps://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。

鉴权变体 ​

协议请求头
OpenAIAuthorization: Bearer sk-xxxxxxxx
Anthropicx-api-key: sk-xxxxxxxx + anthropic-version: 2023-06-01
Geminix-goog-api-key: sk-xxxxxxxx 或 ?key=sk-xxxxxxxx

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

错误 ​

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

完整错误结构见错误与重试。

相关阅读 ​

接口以实际网关配置与模型能力为准。