> ## 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.

# 获取模型

> 检索一个模型实例

## 路径参数

<ParamField path="model" type="string" required>
  要检索的模型 ID（例如：`gpt-5.4`、`claude-sonnet-4-6`）。
</ParamField>

## 响应

<ResponseField name="id" type="string">
  模型标识符。
  它还包含 `lifecycle`、`commercial` 和 `badges`，用于说明弃用/退役状态、用户收费策略和展示标签。
</ResponseField>

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

<ResponseField name="created" type="integer">
  创建时间戳。
</ResponseField>

<ResponseField name="owned_by" type="string">
  模型提供方。
</ResponseField>

<ResponseField name="tokenlab" type="object">
  TokenLab 专属的公开元数据。详情路由可包含 `category`、`pricing_unit`、`capability_flags`、`supported_operations`、`pricing_provenance`、`request_format_summary`、完整的 `request_format_details`，以及非聊天推荐快照的场景级 `agent_preferences`。
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.tokenlab.sh/v1/models/gpt-5.4" \
    -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"
  )

  model = client.models.retrieve("gpt-5.4")
  print(f"Model: {model.id}, Provider: {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 model = await client.models.retrieve('gpt-5.4');
  console.log(`Model: ${model.id}, Provider: ${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/gpt-5.4", nil)
      req.Header.Set("Authorization", "Bearer sk-your-api-key")

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

      var model map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&model)
      fmt.Printf("Model: %s, Provider: %s\n", model["id"], model["owned_by"])
  }
  ```

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

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

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

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

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "gpt-5.4",
    "object": "model",
    "created": 1706000000,
    "owned_by": "openai"
  }
  ```
</ResponseExample>

## 非聊天推荐元数据

对于非聊天模型，详情路由还会返回 `tokenlab.agent_preferences.<scene>`。

可用于查看：

* `preferred_rank`
* `success_rate_24h`
* `sample_count_24h`
* `status`
* `updated_at`

公开响应会用 `basis.source` 概括推荐依据，不会暴露路由标识符。

## 公开详情元数据

与 `GET /v1/models` 相比，详情路由还可以额外返回：

* `tokenlab.capability_flags`
* `tokenlab.supported_operations`
* `tokenlab.pricing_provenance`
* `tokenlab.request_format_summary`
* `tokenlab.request_format_details`

## 错误处理

如果该模型不存在，你将收到一个 404 错误：

```json theme={null}
{
  "error": {
    "message": "Model 'invalid-model' not found",
    "type": "invalid_request_error",
    "code": "model_not_found"
  }
}
```

## 模型删除

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