> For the complete documentation index, see [llms.txt](https://docs.openkey.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openkey.cloud/tool/models.md).

# 查询模型

本节将介绍如何通过 OpenKey.Cloud 提供的 API 接口来查询当前所支持的模型列表。

## 查询可用模型

GET /v1/models

#### 1. 查询可用模型 (List Models)

此接口用于获取当前令牌（`token`）可用的大语言模型列表。

**请求**

```http
GET /v1/models
Host: https://openkey.cloud
Authorization: Bearer {token}
Content-Type: application/json
```

**请求头（Headers）**

| Key             | Value                   | 描述                       |
| --------------- | ----------------------- | ------------------------ |
| `Host`          | `https://openkey.cloud` | API 服务器地址。               |
| `Authorization` | `Bearer {token}`        | 您的 API 令牌，`{token}` 需替换。 |
| `Content-Type`  | `application/json`      | 请求体格式。                   |

**响应**

```json
{
  "object": "list",
  "data": [
    {
      "id": "gpt-3.5-turbo",
      "object": "model",
      "created": 1706037600,
      "owned_by": "openkey.cloud"
    },
    {
      "id": "gpt-4o",
      "object": "model",
      "created": 1683758102,
      "owned_by": "openkey.cloud"
    },
    {
      "id": "gpt-5",
      "object": "model",
      "created": 1687882411,
      "owned_by": "openkey.cloud"
    }
  ]
}
```

**字段说明**

| 字段              | 类型      | 描述                         |
| --------------- | ------- | -------------------------- |
| `object`        | string  | 响应对象的类型，固定为 `list`。        |
| `data`          | array   | 包含模型对象的数组。                 |
| `data.id`       | string  | 模型的唯一标识符，可在 API 调用中直接使用。   |
| `data.object`   | string  | 模型对象的类型，固定为 `model`。       |
| `data.created`  | integer | 模型创建或引入平台的 Unix 秒级时间戳。     |
| `data.owned_by` | string  | 模型提供方，此处为 `openkey.cloud`。 |

#### 2. 错误码与说明

| 状态码                         | 说明         |
| --------------------------- | ---------- |
| `401 Unauthorized`          | 鉴权失败或令牌非法。 |
| `429 Too Many Requests`     | 超过限流规则。    |
| `500 Internal Server Error` | 服务器内部错误。   |
| `400 Bad Request`           | 请求头或参数有误。  |

#### 3. 限流与使用说明

* 每个令牌每 60 秒最多允许 60 次调用，所有 API 接口共享此限制，超出则返回 `429`。
* 此接口遵循 OpenAI 的 `v1/models` 格式，便于客户端兼容。

#### 4. 示例 cURL

**查询可用模型**

```bash
curl -H "Authorization: Bearer sk-XXXX" \
     -H "Content-Type: application/json" \
     https://openkey.cloud/v1/models
```

#### 5. 注意事项

* 确保 `Authorization` 请求头中使用的是正确的 `Bearer token`。
* 返回的模型列表是动态的，可能会随平台更新而增加或调整。建议客户端动态获取此列表。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.openkey.cloud/tool/models.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
