# Tunes

> Fine-tune ChakraTS on your series, then forecast with the tune.

| Method and path | What it does |
|---|---|
| `POST /v1/series/tunes` | starts a tune (a background job) |
| `GET /v1/jobs/{id}` | the job; once it succeeded, `result` is the tune |
| `GET /v1/series/tunes`, `GET /v1/series/tunes/{id}` | lists the project's tunes, reads one |
| `DELETE /v1/series/tunes/{id}` | deletes a tune |
| `POST /v1/series/forecast` with `"tune": "tune_..."` | forecasts with a tune |

In Python and the CLI this is `yh.tune(...)` and `yhatlabs tune`, from yhatlabs 0.2.2. See [Tuning on your data](https://yhatlabs.com/models/docs/time-series/tuning) for what a tune does and when it helps.

## Start a tune

`POST /v1/series/tunes`

The body is a [forecast request](https://yhatlabs.com/models/docs/api/forecast) (`series`, `horizon`, `freq`, `season`, `model`) plus:

| Field | Type | Meaning |
|---|---|---|
| `steps` | integer, 50 to 1,000 | training steps (default 300); the best count is picked on the held-back steps |
| `name` | string | a label |
| `ttl_days` | number, at most 365 | how long the tune is kept after its last use (default 30) |

The reply is `202` with a job: `{"id": "job_...", "object": "job", "kind": "tune", "status": "queued"}`. Poll
`GET /v1/jobs/{id}` (a tune takes a few minutes). A series shorter than `2 x horizon + 64` values fails the job with an
`invalid_request_error` saying so, and its credits are given back.

## The tune

| Field | Meaning |
|---|---|
| `id` | `tune_...`, for `"tune"` in a forecast |
| `used` | `true` when the tuned forecast beat the model as it is on the last `horizon` steps of your series; otherwise forecasts with this tune are the model as it is |
| `report.holdout` | `zero_shot` and `tuned` scores on those steps: `wape` and `loss` (scaled quantile loss) |
| `horizon`, `freq`, `series`, `steps`, `model`, `name` | what was tuned |
| `ttl_days`, `last_used_at`, `expires_at` | how long it is kept |
| `usage` | tokens and credits |

## Forecast with a tune

Add `"tune": "tune_..."` to a forecast request with the same `model`. The reply carries
`"tune": {"id", "used", "holdout"}`, so every forecast says whether it used the tuning.
