Alignment with the SDK
Alignment improves a model from its annotated examples. A job starts from an exact model commit and finishes with a new commit when it finds an improvement.
Configure the model
Load a model with annotated examples, then save the configuration you want to align:
import { Modaic } from "modaic";
const modaic = new Modaic();
const model = await modaic.models.get("acme", "support-priority");
const configured = await modaic.models.update(model.id, {
questions: {
priority: {
type: "choice",
instructions: "Choose the support priority.",
criteria: {
low: "No financial or time-sensitive impact.",
normal: "Routine customer issue.",
high: "Financial impact or an urgent blocker.",
},
},
},
message: "Prepare priority alignment",
});
if (!configured.commit) {
throw new Error("The model configuration did not change.");
}
Start and wait for alignment
Use model.jobs.alignments to create and list jobs for this model. Methods that
take a job ID, such as wait, get, logs, and cancel, remain on
modaic.alignments. With AsyncModaic, await each call.
const alignment = await model.jobs.alignments.create({
branch: configured.commit.branch,
sourceCommitSha: configured.commit.commitSha,
idempotencyKey: "support-alignment-2026-09-22",
reflection: { minibatchSize: 8, seed: 42 },
});
const finished = await modaic.alignments.wait(alignment.id, {
progress: true,
pollIntervalMs: 2_000,
timeoutMs: 900_000,
});
console.log(finished.status, finished.resultCommitSha);
The metric-call budget is optional. When maxMetricCalls is omitted, as
above, the API sizes it to the validation split at launch, which is the
recommended default. Pass maxMetricCalls in TypeScript or
max_metric_calls in Python only to override that sizing.
Set progress: true in TypeScript or progress=True in Python to show the
current stage and metric calls against the reported budget. Python uses tqdm
and supports the same option with AsyncModaic; TypeScript renders to stderr.
Output is silent by default.
The bar measures budget usage, not overall job completion. Alignment can finish before using the full budget. If counts are unavailable, the display shows the stage without a percentage. Updates follow the polling interval; a timeout stops waiting without cancelling the job.
Inspect logs or cancel
const current = await modaic.alignments.get(alignment.id);
const logs = await modaic.alignments.logs(alignment.id);
await modaic.alignments.cancel(alignment.id);
See the Alignment API reference for the complete wire contract.