> ## 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 模型是共享公開目錄，不是使用者擁有的微調模型資源。
