← Back to docs

Recipe

Human-in-the-loop review

High-stakes model output deserves a human eye before it ships. Meridian lets you flag any completion as review_required and pauses delivery until an authorized reviewer in your queue approves, edits, or rejects it. This recipe wires a reviewer queue, a blocking await, and a fallback path in under twenty lines of code.

1. Flag the request

Addmetadata.review_requiredto any chat completion. Meridian intercepts the draft, stores it in your reviewer queue, and returns a draft id instead of streaming tokens to the caller.

2. Route to a reviewer

Specify a queue name and Meridian dispatches the draft to every reviewer subscribed to it via the dashboard, the Slack app, or the webhook. Reviewers can approve as-is, edit inline, or reject with notes that flow back into your application.

3. Await the verdict

Block onmeridian.review.awaitwith a timeout and a fallback policy. The promise resolves with the reviewer-approved text, or follows your timeout rule if no human responds in time.

End-to-end example

// Meridian: gate model output behind a human reviewer
import { meridian } from "@meridian/sdk";

const draft = await meridian.chat.completions.create({
  model: "azure/model-router",
  messages: [{ role: "user", content: userTask }],
  metadata: { review_required: true, queue: "ops-reviewers" },
});

// Pause until a human in your review queue approves or edits.
const final = await meridian.review.await(draft.id, {
  timeoutSeconds: 900,
  onTimeout: "reject",
});

if (final.status === "approved") {
  await ship(final.output);
} else {
  await escalate(final.reviewerNotes);
}