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

# 将模型重新加载到服务运行时

> 重启为模型提供服务的智能体，使其加载最新权重。复用该智能体，因为它已持有训练产出。

使用此接口将模型重新加载到其服务运行时。由于 ariapin 没有独立的服务进程，重新加载通过重启执行该模型训练任务的智能体来实现。该智能体已持有权重，因此重启会加载最新的检查点。

## 方法与路径

```http theme={null}
POST /v1/models/:id/reload
```

## 认证

在 `Authorization` 头中以 Bearer 令牌的形式携带你的 PIN API 令牌或 JWT。

```http theme={null}
Authorization: Bearer <token>
```

## 路径参数

<ParamField path="id" type="string" required>
  模型标识符（例如 `md_abc123def456`）。
</ParamField>

## 请求体

无需请求体。

## 请求示例

<CodeGroup>
  ```bash curl theme={null}
  curl -s -X POST "https://api.ariacompute.com/v1/models/md_abc123def456/reload" \
    -H "Authorization: Bearer $PIN_API_TOKEN"
  ```
</CodeGroup>

## 响应

返回标准的 PIN 成功信封，包含重载结果。

<ResponseField name="code" type="integer" required>
  成功为 `0`，出错为非零值。
</ResponseField>

<ResponseField name="data" type="object" required>
  <Expandable title="属性">
    <ResponseField name="model_id" type="string">
      模型标识符。
    </ResponseField>

    <ResponseField name="job_id" type="string">
      源训练任务标识符。
    </ResponseField>

    <ResponseField name="agent_id" type="string">
      被重启的智能体标识符。
    </ResponseField>

    <ResponseField name="reloaded" type="boolean">
      成功时恒为 `true`。
    </ResponseField>

    <ResponseField name="mode" type="string">
      恒为 `restart`（当前实现）。
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="message" type="string">
  可读消息（成功时为空）。
</ResponseField>

### 响应示例

```json theme={null}
{
  "code": 0,
  "data": {
    "model_id": "md_abc123def456",
    "job_id": "jb_abc123def456",
    "agent_id": "ag_node01_001",
    "reloaded": true,
    "mode": "restart"
  },
  "message": ""
}
```

## 重载条件

模型只有在满足以下全部条件时才可被重载：

1. 模型由 ariapin 训练任务产出（已设置 `job_id`）。
2. 源训练任务在数据库中仍然存在。
3. 源任务绑定到一个活跃智能体（`agent_id` 不为空）。

已停止或已恢复的任务会释放其智能体，因此重载这些模型将返回 422 错误。

## 错误

| Code | HTTP | 含义                         |
| ---- | ---- | -------------------------- |
| 401  | 401  | 缺失或无效的 Bearer 令牌。          |
| 404  | 404  | 模型不存在或不属于你。                |
| 422  | 422  | 模型没有源任务、任务已不存在，或任务未绑定到智能体。 |
| 500  | 500  | 智能体重启失败。                   |
