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

# 通过 PIN API 创建训练任务

> 通过 POST /v1/jobs 向 Aria PIN 提交新的训练任务。支持 SFT、OPD、pretrain、distill、QAT、GRPO、DPO、KTO、ORPO、SimPO 与 PPO，并配置 LoRA。

通过 Aria PIN API 创建训练任务，需指定任务类型、基座模型、数据集、LoRA 配置与超参数。该接口立即返回已排队的任务标识符。

## 接口

`POST /v1/jobs`

每次请求都需携带 `Authorization: Bearer <api_key>` 头。

## 请求体

<ParamField body="type" type="string" required>
  训练类型：`sft`、`opd`、`pretrain`、`distill`、`qat`、`grpo`、`dpo`、`kto`、`orpo`、`simpo` 或 `ppo`。
</ParamField>

<ParamField body="base_model" type="string" required>
  可训练基座的 Hugging Face 模型标识符或本地路径。
</ParamField>

<ParamField body="teacher_model" type="string">
  冻结的教师模型标识符。当 `type` 为 `opd` 或 `distill` 时必填，其他情况忽略。
</ParamField>

<ParamField body="lora" type="object" required>
  LoRA 配置对象。

  <Expandable title="属性">
    <ParamField body="method" type="string" required>
      `lora`、`qlora` 或 `none`。
    </ParamField>

    <ParamField body="rank" type="integer" required>
      LoRA 秩（例如 16）。
    </ParamField>

    <ParamField body="alpha" type="integer" required>
      LoRA alpha（例如 32）。
    </ParamField>

    <ParamField body="lora_dropout" type="number">
      Dropout 比率。
    </ParamField>

    <ParamField body="target_modules" type="string[]">
      目标模块名称（例如 `["q_proj", "v_proj"]`）。
    </ParamField>

    <ParamField body="quantization" type="string">
      当 `method=qlora` 时的量化方法，例如 `4bit_nf4`。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="dataset_id" type="string" required>
  在 PIN 中注册的数据集标识符。
</ParamField>

<ParamField body="hyperparams" type="object" required>
  训练超参数。常见字段包括 `epochs`、`lr`。类型相关字段包括 `distill_alpha`、`temperature`、`fp8_recipe`、`max_tokens`、`qat_group_size`、`group_size` 与 `beta`。
</ParamField>

<ParamField body="auto_intervention" type="object">
  可选的自动干预配置，包含规则、冷却时间与启用开关。
</ParamField>

## 响应

<ResponseField name="job_id" type="string">
  所创建任务的唯一标识符。
</ResponseField>

<ResponseField name="status" type="string">
  初始状态，通常为 `queued`。
</ResponseField>

## 示例

```bash theme={null}
curl -X POST http://host:8001/v1/jobs \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "opd",
    "base_model": "thinkingmachines/Inkling",
    "teacher_model": "Qwen/Qwen2.5-1.5B-Instruct",
    "lora": {"method": "lora", "rank": 16, "alpha": 32},
    "dataset_id": "ds_xxx",
    "hyperparams": {"epochs": 1, "lr": 5e-5, "distill_alpha": 0.7, "temperature": 3.0}
  }'
```

```json Response theme={null}
{
  "code": 0,
  "data": {
    "job_id": "job_abc123",
    "status": "queued"
  },
  "message": ""
}
```
