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

# 列出模型

> 列出所有可用模型

## 响应

<ResponseField name="object" type="string">
  始终为 `list`。
</ResponseField>

<ResponseField name="data" type="array">
  模型对象数组。

  每个模型始终包含：

  * `id` (string): 模型标识符
  * `object` (string): `model`
  * `created` (integer): 创建时间戳
  * `owned_by` (string): 模型提供方
  * `tokenlab.aliases` (array): 同一模型的公开别名
  * `tokenlab.pricing` (object): 公开基础价格摘要
  * `tokenlab.capabilities` (array): 公开能力标签
  * `tokenlab.max_input_tokens` (number or `null`): 可用时的输入上下文上限
  * `tokenlab.max_output_tokens` (number or `null`): 可用时的输出上限
  * `tokenlab.category` (string): 公开模型分类
  * `tokenlab.pricing_unit` (string): 公开定价单位
  * `tokenlab.has_complex_pricing` (boolean): 价格是否有模型专属维度
  * `tokenlab.lifecycle`（object）：生命周期状态、发布日期/弃用日期、替代模型和 latest 标签来源
  * `tokenlab.commercial`（object）：用户收费策略、免费原因和可选免费截止时间
  * `tokenlab.badges`（array）：由生命周期和商业策略派生的展示标签

  条件式列表元数据：

  * `tokenlab.providers` (array): 可用时的公开提供方
  * `tokenlab.cache_pricing` (object or `null`): 可用时的 prompt cache 价格
  * `tokenlab.pricing_summary` (object or `null`): 仅在复杂价格模型上返回
  * `tokenlab.request_format_summary` (object or `null`): 轻量级非聊天发现摘要，包含 `public_operations`、`request_endpoint` 和 `request_endpoint_by_operation`
  * `tokenlab.agent_preferences` (object): 仅在存在 `recommended_for` 时返回

  `tokenlab.capability_flags`、`tokenlab.supported_operations`、`tokenlab.pricing_provenance`、`tokenlab.request_format_details` 等仅详情可见的字段，只会由 `GET /v1/models/{model}` 返回。
</ResponseField>

<Note>
  `GET /v1/models` 侧重于发现。像 `capability_flags`、`pricing_provenance` 和完整的 `request_format_details` 这类仅详情可见的元数据都在 `GET /v1/models/{model}` 中。
</Note>

## 查询参数

<ParamField query="category" type="string">
  可选的公开分类筛选。支持 `chat`、`image`、`video`、`audio`、`tts`、`stt`、`music`、`3d`、`embedding`、`rerank` 和 `translation`。
</ParamField>

<ParamField query="recommended_for" type="string">
  可选的非聊天推荐场景。支持 `image`、`video`、`music`、`3d`、`tts`、`stt`、`embedding`、`rerank` 和 `translation`。
</ParamField>

<ParamField query="provider" type="string">
  可选的提供方筛选，例如 `openai`、`anthropic`、`google` 或 `deepseek`。
</ParamField>

<ParamField query="tag" type="string">
  可选的模型标签筛选，例如 `chat`、`image`、`video`、`embedding` 或 `translation`。
</ParamField>

<Note>
  当 `recommended_for` 存在时，`/v1/models` 会按照最近缓存的 24 小时成功率快照对非聊天模型排序。`status = "insufficient_samples"` 的模型仍会显示，但会排在已有评分的模型之后。
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.tokenlab.sh/v1/models" \
    -H "Authorization: Bearer sk-your-api-key"
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="sk-your-api-key",
      base_url="https://api.tokenlab.sh/v1"
  )

  models = client.models.list()

  for model in models.data:
      print(f"{model.id} ({model.owned_by})")
  ```

  ```javascript JavaScript theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: 'sk-your-api-key',
    baseURL: 'https://api.tokenlab.sh/v1'
  });

  const models = await client.models.list();

  for (const model of models.data) {
    console.log(`${model.id} (${model.owned_by})`);
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      req, _ := http.NewRequest("GET", "https://api.tokenlab.sh/v1/models", nil)
      req.Header.Set("Authorization", "Bearer sk-your-api-key")

      resp, _ := http.DefaultClient.Do(req)
      defer resp.Body.Close()

      var payload struct {
          Data []struct {
              ID      string `json:"id"`
              OwnedBy string `json:"owned_by"`
          } `json:"data"`
      }

      json.NewDecoder(resp.Body).Decode(&payload)

      for _, model := range payload.Data {
          fmt.Printf("%s (%s)\n", model.ID, model.OwnedBy)
      }
  }
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.tokenlab.sh/v1/models');

  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer sk-your-api-key'
      ]
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $data = json_decode($response, true);
  foreach ($data['data'] as $model) {
      echo "{$model['id']} ({$model['owned_by']})\n";
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "object": "list",
    "data": [
      {
        "id": "gpt-5.4",
        "object": "model",
        "created": 1706000000,
        "owned_by": "openai"
      },
      {
        "id": "claude-sonnet-4-6",
        "object": "model",
        "created": 1706000000,
        "owned_by": "anthropic"
      },
      {
        "id": "gemini-3.5-flash",
        "object": "model",
        "created": 1706000000,
        "owned_by": "google"
      }
    ]
  }
  ```
</ResponseExample>

## 按提供方筛选

```python theme={null}
# Get all OpenAI models
openai_models = [m for m in models.data if m.owned_by == "openai"]

# Get all Anthropic models
anthropic_models = [m for m in models.data if m.owned_by == "anthropic"]
```

## 模型类别

| 提供方         | 示例模型                                                     |
| ----------- | -------------------------------------------------------- |
| `openai`    | gpt-5.4, gpt-5.4-mini, gpt-5-mini, gpt-4o, gpt-image-2   |
| `anthropic` | claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5     |
| `google`    | gemini-3.1-pro-preview, gemini-3.5-flash, gemini-2.5-pro |
| `deepseek`  | deepseek-r1, deepseek-v3-2                               |
| `xai`       | grok-4.1                                                 |
| `moonshot`  | kimi-k2.5                                                |
| `minimax`   | minimax-m3                                               |
| `meta`      | llama-3.3-70b, llama-3.1-405b                            |

## 模型删除

`DELETE /v1/models/{model}` 不受支持。TokenLab 模型是共享公开目录，不是用户拥有的微调模型资源。
