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

# Start instruction optimization job

> Improve question instructions using uploaded labeled datasets.

Optimize question instructions using uploaded datasets in the [fine-tuning dataset format](https://docs.modaic.dev/docs/dataset/guidance.md). Use an existing saved model, or a base model with a destination. The request returns `202 Accepted` with a `Location` header to poll.

**Idempotency-Key** `string` *required*

A key between 8 and 255 characters. Reuse it only when retrying this exact request.

**model** `string` *required*

A base model such as `mo-latest`, or a saved model such as `acme/support-priority`.
Saved models require repository write access.

**destination** `string`

Required with a base model: the `workspace/model` to create or update. An existing
destination must use the same base model. Omit this field when `model` is already a saved model.

**training\_file** `string` *required*

Name of a validated dataset uploaded in the model's workspace. Its version is pinned for the job.

**validation\_file** `string`

Optional uploaded dataset used entirely for candidate selection. When supplied,
the training file's validation rows return to training.

**eval\_only\_dataset** `string`

Optional evaluation-only resource used entirely for final held-out metrics.
When supplied, the training file's test rows return to training.

**branch** `string` (default: main)

Branch to optimize and update. A new destination starts on `main`.

**sourceCommitSha** `string`

Optional current branch head, from 7 to 128 characters. Omit to resolve the current
head when creating the job. A stale value returns `409 source_commit_conflict`.
Omit for a new destination.

**budget** `object` (default: \{})

`maxMetricCalls` is a positive integer up to 1,000,000. Omit to size the budget
from the validation partition. A run can finish a few calls past the budget;
final held-out evaluation is billed separately.

**reflection** `object` (default: \{ seed: 0 })

Optional settings: `model`, positive `minibatchSize` up to 10,000, and integer
`seed` from 0 to 2,147,483,647.

## Dataset requirements

All rows across the supplied files must share the same question IDs and definitions, including nonempty text instructions. Supported labels are Noul `0` or `1`, Choice with keyed criteria and one option label, and Score with ordered levels and one level index. Soft-label distributions are not supported for instruction optimization.

For saved models, the question IDs, types, and criteria must match the model. Its current instructions provide the starting point. A model without saved questions starts from the dataset's definitions.

The training dataset is split deterministically into training, validation, and test partitions. Explicit validation or evaluation files replace their respective partitions. Every partition must be nonempty. Duplicate inputs and `groupId` values cannot cross partitions. The combined uploaded files must be at most 64 MiB.

Candidate selection uses validation rows. Final metrics use held-out test rows or the explicit evaluation-only dataset. Stored model examples and annotations are not optimization inputs.

## Request example

```json theme={null}
{
  "model": "mo-latest",
  "destination": "acme/support-priority",
  "training_file": "triage-labels",
  "reflection": {"seed": 42, "minibatchSize": 8}
}
```

For an existing saved model, use `"model": "acme/support-priority"` and omit `destination`. The model-scoped `POST /v1/models/{workspace}/{model}/instruction-optimizations` route also accepts the dataset fields, branch, source commit, budget, and reflection settings.

## Response

**id** `UUID` *required*

Instruction optimization job ID.

**repositoryId** `UUID` *required*

**status** `queued | running | completed | failed | cancelled` *required*

**phase** `queued | optimizing | done | failed | cancelled` *required*

**branch** `string` *required*

**sourceCommitSha** `string` *required*

**training\_file** `string`

Uploaded dataset name. New jobs also return `datasetCommitSha` and `datasetSha256`
identifying its pinned version. Optional `validation_file` and `eval_only_dataset`
are returned when supplied.

**resultCommitSha** `string | null` *required*

New commit when instructions improve, or when initializing a model's question definitions.

**result** `InstructionOptimizationResult | null` *required*

On completion: `improved`, best candidate instructions, initial and best validation
scores, token usage, held-out evaluation metrics, and artifact path.

**progress** `InstructionOptimizationProgress | null` *required*

Stage, elapsed time, and available metric-call, iteration, candidate, and score counters.

**error** `object | null` *required*

Job-level error with `code` and `message`.

**createdAt** `ISO 8601 datetime` *required*

**updatedAt** `ISO 8601 datetime` *required*

**startedAt** `ISO 8601 datetime | null` *required*

**finishedAt** `ISO 8601 datetime | null` *required*

An improving run commits optimized instructions and its optimization artifact. A run without improvement leaves existing saved instructions unchanged. Completion does not start a batch prediction job on stored examples.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.