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

# Export a trained model to GGUF, MLX, MNN, or QNN

> Request an asynchronous export of a trained model into GGUF, MLX, MNN, or QNN format. Returns an export task ID you can poll for status.

Use this endpoint to convert a trained model into a deployment-ready format. Supported formats are GGUF (quantized), MLX (Apple Silicon), MNN (Alibaba mobile), and QNN (Qualcomm). The export runs asynchronously; poll `GET /v1/exports/:id` to track completion.

## Method + Path

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

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

<ParamField body="format" type="string" required>
  Target export format. Must be one of: `gguf`, `mlx`, `mnn`, `qnn`.
</ParamField>

### Request body example

```json theme={null}
{
  "format": "gguf"
}
```

## Request example

<CodeGroup>
  ```bash curl theme={null}
  curl -s -X POST "https://api.ariacompute.com/v1/models/md_abc123def456/export" \
    -H "Authorization: Bearer $PIN_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"format": "gguf"}'
  ```
</CodeGroup>

## Response

Returns a standard PIN success envelope with the export task.

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

<ResponseField name="data" type="object" required>
  <Expandable title="export object">
    <ResponseField name="export_id" type="string">
      Unique export task identifier (e.g., `ex_...`).
    </ResponseField>

    <ResponseField name="model_id" type="string">
      The source model identifier.
    </ResponseField>

    <ResponseField name="format" type="string">
      Requested format: `gguf`, `mlx`, `mnn`, or `qnn`.
    </ResponseField>

    <ResponseField name="status" type="string">
      Task status: `queued`, `running`, `succeeded`, or `failed`.
    </ResponseField>

    <ResponseField name="artifact_path" type="string">
      Output path or file (populated after success).
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message if the export failed.
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO 8601 creation timestamp.
    </ResponseField>
  </Expandable>
</ResponseField>

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

### Example response

```json theme={null}
{
  "code": 0,
  "data": {
    "export_id": "ex_7a8b9c0d1e2f",
    "model_id": "md_abc123def456",
    "format": "gguf",
    "status": "queued",
    "created_at": "2025-01-15T14:32:08Z"
  },
  "message": ""
}
```

## Export process

1. If the model does not have a merged artifact, the system automatically merges the LoRA adapter into the base weights first.
2. The converter tool runs in a background goroutine:
   * **GGUF**: Converts to FP16 then quantizes to `Q4_K_M` using llama.cpp.
   * **MLX**: Runs `mlx_lm.convert` or the tool configured by `ARIAPIN_CONVERT_MLX`.
   * **MNN**: Runs `mnnconvert` or the tool configured by `ARIAPIN_CONVERT_MNN`.
   * **QNN**: Runs `qairt-converter` or the tool configured by `ARIAPIN_CONVERT_QNN`.
3. On success, the artifact path is registered and the model status returns to `ready`.

## Errors

| Code | HTTP | Meaning                                           |
| ---- | ---- | ------------------------------------------------- |
| 401  | 401  | Missing or invalid Bearer token.                  |
| 404  | 404  | Model not found or does not belong to you.        |
| 422  | 422  | Unsupported format or missing converter tool.     |
| 500  | 500  | Export executor failed (details in `data.error`). |


## Related topics

- [Merge LoRA adapter into a base model](/api-reference/pin/models/merge.md)
- [Get Model Export Job Status - PIN API](/api-reference/pin/exports/get.md)
- [Get PIN Model](/api-reference/pin/models/get.md)
- [Accept a trained model version as production](/api-reference/pin/models/accept.md)
- [List All Model Export Jobs - PIN API](/api-reference/pin/exports/list.md)
