Recipes
Recipes that show what TypeScript unlocks for an Arkor training run today.
This section collects the patterns that show up first when you put logic inside an Arkor training run. Each recipe stays inside today's public SDK: no roadmap APIs, no internal imports, nothing that requires forking the runtime.
Recipes
| Recipe | What it shows | Built on |
|---|---|---|
| Mid-run evaluation | Sanity-check the half-trained model against a fixed prompt at every checkpoint, before the run finishes. | onCheckpoint({ infer }) |
| Structured outputs and function calling | Constrain a checkpoint's output to a JSON schema, parse it as a typed object, and let the model call functions. | infer({ responseFormat, tools }) |
| Early stopping on diverging loss | Abort a run automatically when the loss curve goes the wrong way, and stop the GPU on the backend too. | onLog, AbortSignal, trainer.cancel() |
| Slack / Discord notifications | Post to a webhook on completion or failure, without leaving the trainer file. | onCompleted / onFailed, fetch |
| Programmatic runs (no CLI) | Drive training from a Next.js API route, a cron worker, or CI without going through arkor dev / arkor start. | runTrainer, Trainer.start / wait |
| Customizing the starter templates | Treat the scaffolded templates as starting points. Change the dataset, hyperparameters, callbacks, and base model. | createTrainer, DatasetSource |
A note on callback exceptions before you start
Three of the recipes below put logic inside the lifecycle callbacks. A throw inside a callback rejects trainer.wait() immediately with your error (SDK § Lifecycle callbacks); it is not routed through the SSE reconnect loop, not silently retried, and the event is not swallowed. The reconnect loop handles only transport failures (a dropped connection, a transient 5xx). For non-fatal handling, catch inside the callback.
The recipes here use a simple convention to stay deterministic:
- State changes go through outer variables. Use an
AbortController, a closure flag, or a returned Promise rather than throwing. - Side effects are guarded with
try / catchinside the callback. If a Slack post fails, log it and continue; do not let it bubble.
This is a pattern, not a limit on what you can do. Once you have it, the recipes compose cleanly.
Things this section does not cover
- Production-serving recipes. Publishing a trained adapter at a stable
*.arkor.appendpoint already works, per Deployments; this section simply has no serving recipes yet (createArkor'sdeploymanifest slot is still a reserved type field with no implementation). - Multiple trainers per project.
createArkoraccepts a singletrainer; running several together is a programmatic-run pattern (see the recipe), not a manifest pattern. - Custom base models beyond what the backend accepts. The
modelfield is forwarded to the cloud API verbatim; today the curated path is Gemma. Recipes do not pretend other models work end to end.