> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 列出模型

> 查詢當前 API Key 可用的模型列表，兼容 OpenAI Models API

> [!NOTE]
>
> **中國大陸用戶請注意：** 中國大陸用戶請使用 `https://toapis.cn` 作為接口地址（Base URL）。文檔示例中的 `https://toapis.com` 請替換為 `https://toapis.cn`。

* 兼容 OpenAI Models API 格式
* 返回當前 API Key 與用戶組可用的模型
* 默認返回文字模型，可通過 `type=all` 獲取全部類型模型
* 可按模型類型篩選文字、圖片、視頻或音頻模型

獲取當前 API Key 可訪問的模型列表。返回結果會根據令牌模型限制、用戶組、可用渠道和模型計費配置動態過濾。

## Authorizations

**Authorization** `string` *required*

所有接口均需要使用 Bearer Token 進行認證

獲取 API Key：訪問 [API Key 管理頁面](https://toapis.com/console/token) 獲取您的 API Key

使用時在請求頭中添加：

```
Authorization: Bearer YOUR_API_KEY
```

## Query Parameters

**type** `string` (default: text)

模型類型篩選。

可選值：

* `text` 或 `chat`：僅返回文字對話模型
* `image`：僅返回圖片模型
* `video`：僅返回視頻模型
* `audio`：僅返回音頻模型
* `all`：返回全部可用模型

不傳時默認只返回文字模型。

## Response

**success** `boolean`

請求是否成功。

**object** `string`

列表對象類型，固定爲 `list`。

**data** `object[]`

模型列表。

**data\[n]**

**id** `string`

模型 ID，用於請求其他接口時的 `model` 參數。

**object** `string`

對象類型，固定爲 `model`。

**created** `integer`

模型創建時間戳。部分自定義模型會返回平臺默認時間戳。

**owned\_by** `string`

模型所屬供應商或渠道名稱。

**supported\_endpoint\_types** `string[]`

模型支持的接口類型。不同模型可能支持 Chat Completions、Responses、圖片、視頻等不同端點。

```bash cURL theme={null}
curl --request GET \
  --url 'https://toapis.com/v1/models' \
  --header 'Authorization: Bearer <token>'
```

```bash cURL（獲取全部類型） theme={null}
curl --request GET \
  --url 'https://toapis.com/v1/models?type=all' \
  --header 'Authorization: Bearer <token>'
```

```python Python theme={null}
import requests

API_BASE = 'https://toapis.com'
API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxx'

headers = {
    'Authorization': f'Bearer {API_KEY}'
}

response = requests.get(f'{API_BASE}/v1/models', headers=headers)
data = response.json()

if data.get('success'):
    for model in data.get('data', []):
        print(model['id'])
else:
    print(data)
```

```javascript JavaScript theme={null}
const API_BASE = 'https://toapis.com';
const API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxx';

async function listModels(type = 'text') {
  const url = new URL('/v1/models', API_BASE);
  if (type) url.searchParams.set('type', type);

  const response = await fetch(url, {
    headers: {
      Authorization: `Bearer ${API_KEY}`,
    },
  });

  const data = await response.json();
  console.log(data.data?.map((model) => model.id));
  return data;
}

listModels('all');
```

```json theme={null}
{
  "success": true,
  "object": "list",
  "data": [
    {
      "id": "claude-sonnet-4-6",
      "object": "model",
      "created": 1626777600,
      "owned_by": "anthropic",
      "supported_endpoint_types": ["chat_completions", "responses"]
    },
    {
      "id": "gpt-5",
      "object": "model",
      "created": 1626777600,
      "owned_by": "openai",
      "supported_endpoint_types": ["chat_completions"]
    }
  ]
}
```

## 說明

* 如果 API Key 配置了模型限制，只會返回該令牌允許訪問的模型。
* 如果不傳 `type`，視頻和音頻等異步任務模型不會出現在默認結果中。
* 如果需要獲取圖片、視頻、音頻等全部可用模型，請使用 `GET /v1/models?type=all`。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.