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

# Merge LoRA adapter into a base model

> Merge a LoRA or adapter checkpoint into its base model weights. Required before exporting to formats like GGUF, MLX, MNN, or QNN.

Use this endpoint to merge a trained LoRA adapter back into the base model weights. Merging produces a full-weight model under the `merged` artifact path, which is required before exporting to deployment formats like GGUF, MLX, MNN, or QNN.

## Method + Path

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

## Authentication

Include your PIN API token or JWT in the `Authorization` header as a Bearer token.

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

## Path parameters

<ParamField path="id" type="string" required>
  The model identifier (e.g., `md_abc123def456`).
</ParamField>

## Request body

No request body is required.

## Request example

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

## Response

Returns a standard PIN success envelope with the merge status.

<ResponseField name="code" type="integer" required>
  `0` on success, nonzero on error.
</ResponseField>

<ResponseField name="data" type="object" required>
  <Expandable title="properties">
    <ResponseField name="model_id" type="string">
      The model identifier.
    </ResponseField>

    <ResponseField name="status" type="string">
      `ready` when the merge completes successfully.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable message (empty on success).
</ResponseField>

### Example response

```json theme={null}
{
  "code": 0,
  "data": {
    "model_id": "md_abc123def456",
    "status": "ready"
  },
  "message": ""
}
```

## Merge process

1. The system validates that the model exists and is not already merging.
2. It generates a temporary Python script using PEFT's `merge_and_unload` to fuse the adapter into the base weights.
3. The merged weights are saved to the model's `merged` artifact directory.
4. On success, the model status returns to `ready` and `artifact_paths.merged` is updated.

## Errors

| Code | HTTP | Meaning                                      |
| ---- | ---- | -------------------------------------------- |
| 401  | 401  | Missing or invalid Bearer token.             |
| 404  | 404  | Model not found or does not belong to you.   |
| 409  | 409  | Merge is already in progress for this model. |
| 500  | 500  | Merge script execution failed.               |

## Notes

* If you call `POST /v1/models/:id/export` before merging, the export service automatically triggers a merge first.
* For models trained with full-parameter methods (`pretrain`, `qat`, `distill` with `mode=full`), no merge is needed because the output is already full weights.


## Related topics

- [Export a trained model to GGUF, MLX, MNN, or QNN](/api-reference/pin/models/export.md)
- [Create Training Job with PIN API](/api-reference/pin/jobs/create.md)
- [Aria Compute PIN API: Post-Training & Evaluation](/api-reference/pin/introduction.md)
- [Retrieve full training job detail with checkpoints and metrics](/api-reference/pin/jobs/get.md)
- [Get PIN Model](/api-reference/pin/models/get.md)
