# 查询模型运行状态

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

查询当前用户模型最近一小时的请求量、耗时、错误率和健康状态。

```text
GET https://billing.moi.matrixorigin.cn/api/v1/taas/dashboard/model-status
```

## 调用前准备

准备个人访问令牌。创建和管理方法参阅[创建和管理个人访问令牌](../../../../../guides/genesis/api-keys.md#创建和管理个人访问令牌)。

查询范围为当前用户有权访问的数据。

## 查询参数

将示例中的 `$MOI_PERSONAL_ACCESS_TOKEN` 替换为个人访问令牌。

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} 输入示例

```bash
curl --get "https://billing.moi.matrixorigin.cn/api/v1/taas/dashboard/model-status" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN" \
  --data-urlencode "model_status_sort=requests1h" \
  --data-urlencode "model_status_limit=8"
```

:::::
:::::{tab-item} 参数说明

::::{div} mo-api-parameter-table

| 参数 | 类型 | 是否必填 | 说明 |
| --- | --- | --- | --- |
| `model_status_sort` | string | 否 | 降序排序：`requests1h`、`latency` 或 `errorRate`；默认 `requests1h`。 |
| `model_status_limit` | integer | 否 | 最多返回的模型数，默认 8，最大 50。 |
| `model_type` | string | 否 | 模型类型。 |
| `requested_model` | string | 否 | 调用请求填写的模型名称。 |
| `status` | string | 否 | 调用状态，例如 `success` 或 `failed`。 |
| `error_type` | string | 否 | 调用错误类别。 |
| `caller_ip` | string | 否 | 调用方 IP。 |
| `token_key_id` | string | 否 | TaaS 本地密钥 ID。 |
| `token_key_ids` | string | 否 | TaaS 本地密钥 ID 列表；可重复传递或用逗号分隔。 |
| `credential_type` | string | 填写 `credential_id` 时必填 | 凭据类别：`taas_token_key`、`personal_access_token` 或 `service_account_api_key`；必须同时填写 `credential_id`。 |
| `credential_id` | string | 填写 `credential_type` 时必填 | 凭据对象 ID；必须同时填写 `credential_type`。 |
| `billing_event_id` | string | 否 | 计费用量事件 ID。 |
| `billing_record_id` | string | 否 | 计费记录 ID。 |
| `pricing_mode` | string | 否 | 计价方式。 |
| `settlement_method` | string | 否 | 结算方式：genesis 或 `ai_service`。 |
| `enterprise_plan_id` | string | 否 | 企业方案 ID。 |
| `enterprise_contract_no` | string | 否 | 企业合同编号。 |
| `enterprise_plan_model_id` | string | 否 | 企业方案模型 ID。 |
| `response_id` | string | 否 | Responses 响应 ID。 |
| `conversation_id` | string | 否 | Conversation ID。 |
| `ids` | string | 否 | 请求日志 ID 列表；可重复传递或用逗号分隔。 |
| `usage_ids` | string | 否 | ids 的兼容参数；与 ids 合并。 |
| `provider_id` | string | 否 | 供应商 ID；查询仍限定为当前用户的调用。 |

::::

:::::
::::::
:::::::

## 成功响应

返回 HTTP `200`，响应包含模型最近一小时的运行指标和健康状态。

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{
  "model_status": [
    {
      "model_id": "model_example",
      "model_name": "Example Chat",
      "latency_ms": 120,
      "avg_latency_ms": 120,
      "error_rate": 0,
      "recent_1h_requests": 2,
      "requests_1h": 2,
      "health_status": "healthy"
    }
  ],
  "model_health": [
    {
      "model_id": "model_example",
      "model_name": "Example Chat",
      "latency_ms": 120,
      "avg_latency_ms": 120,
      "error_rate": 0,
      "recent_1h_requests": 2,
      "requests_1h": 2,
      "health_status": "healthy"
    }
  ],
  "model_status_sort": "requests1h",
  "model_status_limit": 8
}
```

:::::
:::::{tab-item} 字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `model_status` | array of object | 模型状态列表。 |
| `model_status[].model_id` | string | 模型目录对象 ID。 |
| `model_status[].model_name` | string | 模型显示名称。 |
| `model_status[].latency_ms` | integer | 最近一小时的平均调用耗时，毫秒。 |
| `model_status[].avg_latency_ms` | integer | 与 `latency_ms` 相同。 |
| `model_status[].error_rate` | number | 最近一小时的失败比例，范围 0 到 1。 |
| `model_status[].recent_1h_requests` | integer | 最近一小时的请求次数。 |
| `model_status[].requests_1h` | integer | 与 `recent_1h_requests` 相同。 |
| `model_status[].health_status` | string | 最近记录的健康状态；无记录时为 `unknown`。 |
| `model_health` | array of object | 与 `model_status` 相同。 |
| `model_health[].model_id` | string | 模型目录对象 ID。 |
| `model_health[].model_name` | string | 模型显示名称。 |
| `model_health[].latency_ms` | integer | 最近一小时的平均调用耗时，毫秒。 |
| `model_health[].avg_latency_ms` | integer | 与 `latency_ms` 相同。 |
| `model_health[].error_rate` | number | 最近一小时的失败比例，范围 0 到 1。 |
| `model_health[].recent_1h_requests` | integer | 最近一小时的请求次数。 |
| `model_health[].requests_1h` | integer | 与 `recent_1h_requests` 相同。 |
| `model_health[].health_status` | string | 最近记录的健康状态；无记录时为 `unknown`。 |
| `model_status_sort` | string | 实际使用的排序方式。 |
| `model_status_limit` | integer | 实际使用的数量上限。 |

字段路径中的 `[]` 表示数组中的每一项。

:::::
::::::
:::::::

除排序和数量上限外，筛选条件作用于调用统计。模型列表按可见的启用模型返回，筛选后没有调用的模型仍可能显示为零次调用。
