---
title: Retrain the AI
protocol: rest
method: POST
endpoint: /v1/projects/{projectId}/ai/retrain
description: "Rebuild the AI assistant's knowledge index from the latest deployed docs."
---

# Retrain the AI

Rebuilds the AI assistant's knowledge index. Every page from your latest deployed docs is re-chunked and re-embedded, so answers immediately reflect current content.

<Note>
Retraining happens **automatically on every deploy** — you normally never need this endpoint. Use it only to force a rebuild (e.g. after a partial index or unexpected answer quality issues).
</Note>

<Endpoint method="POST" path="/v1/projects/{projectId}/ai/retrain" />

## Path Parameters

<ParamField path="projectId" type="string" required>
  The project ID.
</ParamField>

## Example

```bash
curl -X POST "https://api.syntext.dev/v1/projects/prj_abc123/ai/retrain" \
  -H "Authorization: Bearer stx_abc12345_..."
```

### Response

Returns `202 Accepted` — retraining runs in the background.

```json
{
  "data": {
    "status": "running",
    "startedAt": "2025-01-15T10:30:00.000Z"
  }
}
```

### Errors

| Status | Code | Meaning |
| ------ | ---- | ------- |
| `409` | `already_running` | A retrain is already in progress for this project. |
| `400` | `no_deployed_build` | No deployed build with source available — deploy your docs first. |

## Poll Retrain Status

<Endpoint method="GET" path="/v1/projects/{projectId}/ai/retrain" />

```bash
curl "https://api.syntext.dev/v1/projects/prj_abc123/ai/retrain" \
  -H "Authorization: Bearer stx_abc12345_..."
```

### Response

```json
{
  "data": {
    "status": "completed",
    "startedAt": "2025-01-15T10:30:00.000Z",
    "finishedAt": "2025-01-15T10:30:42.000Z",
    "pageCount": 38,
    "chunkCount": 214
  }
}
```

`status` is one of `idle`, `running`, `completed`, or `failed` (failures include an `error` message).
