Skip to content

获取模型列表

GET /v1/models

获取当前可用的模型列表。

根据请求头自动识别返回格式:

  • 包含 x-api-keyanthropic-version 头时返回 Anthropic 格式
  • 包含 x-goog-api-key 头或 key 查询参数时返回 Gemini 格式
  • 其他情况返回 OpenAI 格式

基本信息

项目内容
Base URLhttps://www.yunzhuhub.cn
标签获取模型列表
Operation IDlistModels

认证

  • BearerAuth:使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx

密钥安全

请只使用你自己的 API Key。示例中的 <YOUR_API_KEY> 必须在本地替换,不要把真实密钥提交到代码仓库或发送给他人。

参数

名称位置类型必填说明
keyquerystringGoogle API Key (用于 Gemini 格式)
x-api-keyheaderstringAnthropic API Key (用于 Claude 格式)
anthropic-versionheaderstringAnthropic API 版本
x-goog-api-keyheaderstringGoogle API Key (用于 Gemini 格式)

请求体

此接口没有请求体。

请求示例

以下示例只用于复制到本地终端,不会从文档站发送请求。

bash
curl --request GET 'https://www.yunzhuhub.cn/v1/models' \
  --header 'Authorization: Bearer <YOUR_API_KEY>'

响应

200 成功获取模型列表

json
{
  "title": "ModelsResponse",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "example": "list"
    },
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/Model"
      }
    }
  }
}

401 认证失败

json
{
  "title": "ErrorResponse",
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "错误信息"
        },
        "type": {
          "type": "string",
          "description": "错误类型"
        },
        "param": {
          "type": "string",
          "description": "相关参数",
          "nullable": true
        },
        "code": {
          "type": "string",
          "description": "错误代码",
          "nullable": true
        }
      }
    }
  }
}

云筑Hub 文档。底层项目基于 New API