# Set voice quality mode

`PUT http://127.0.0.1:19470/v1/quality`

Sets the quality and latency profile used by the voice changer.
If the voice changer is running, its audio engine restarts briefly to
apply the new mode. If it is stopped, the mode is used on the next start.

Authenticate with `Authorization: Bearer <API key>` (key from Settings > Developer in Voices AI Live).

## Request body (application/json)

- `mode` (string, required): `adaptive` balances quality and latency automatically. `high-quality` prioritizes detail. `low-latency` prioritizes responsiveness. One of: `adaptive`, `high-quality`, `low-latency`.

```json
{
  "mode": "adaptive"
}
```

## Responses

### 200: Quality mode updated

- `ok` (boolean, required)
- `qualityMode` (string, required): `adaptive` balances quality and latency automatically. `high-quality` prioritizes detail. `low-latency` prioritizes responsiveness. One of: `adaptive`, `high-quality`, `low-latency`.
- `error` (string or null): Error message when `ok` is false

```json
{
  "ok": true,
  "qualityMode": "adaptive"
}
```

### 400: Invalid mode or engine restart failed

- `ok` (boolean, required)
- `qualityMode` (string, required): `adaptive` balances quality and latency automatically. `high-quality` prioritizes detail. `low-latency` prioritizes responsiveness. One of: `adaptive`, `high-quality`, `low-latency`.
- `error` (string or null): Error message when `ok` is false

```json
{
  "ok": false,
  "qualityMode": "high-quality",
  "error": "The voice engine could not restart."
}
```

### 401: Invalid or missing API key

- `error` (string, required): Error message

```json
{
  "error": "Invalid or missing API key"
}
```

## Examples

```bash
curl -X PUT http://127.0.0.1:19470/v1/quality \
  -H "Authorization: Bearer $VOICES_AI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode":"adaptive"}'
```

```javascript
const res = await fetch('http://127.0.0.1:19470/v1/quality', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.VOICES_AI_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    mode: 'adaptive'
  }),
});
const data = await res.json();
```

```python
import os
import requests

res = requests.put(
    "http://127.0.0.1:19470/v1/quality",
    headers={"Authorization": f"Bearer {os.environ['VOICES_AI_API_KEY']}"},
    json={"mode":"adaptive"},
)
print(res.json())
```
