# OpenAI fine-tune job failed: validate the training file before paying for another run

## The symptom

The fine-tuning job errors out or sits in failed state. Each blind retry burns money, so never relaunch without knowing the cause.

## Confirm the cause

Validate the training file locally before it touches the API:

1. **JSONL shape.** One complete JSON object per line. No pretty-printed multi-line objects, no trailing commas.
2. **Message format.** Each line needs a `messages` array, every message with `role` and `content`. A typo in a role name fails the whole file.
3. **Upload purpose.** The file must be uploaded with purpose `fine-tune`. A file uploaded for another purpose is not accepted as training data.
4. **Size sanity.** Check token counts per example. Pathological examples turn a validation problem into a billing problem.

Then read the job's events, not just its status. The events carry the specific validation error: which line, which field. Fix that exact thing.

## The fix

1. Write a local validator: every line parses as JSON, has a messages array, every message has role and content, no empty strings where forbidden.
2. Fix all errors, re-upload with purpose fine-tune, launch a new job.
3. Start with a few hundred examples to prove the pipeline before training on the full dataset.
4. Estimate cost from token counts before the full run.

## Verify the fix

The validator passes clean on the exact file uploaded. The new job reaches running state with steady progress in its events, not a validation error. Keep the validator in the pipeline so the next dataset is checked automatically.