Classify text into a caller-supplied label set (you define the labels at call time). Returns the single best-fit label with a rationale and confidence. Optional fallback label.
Assign a piece of text to exactly one label from a caller-supplied label set. You define the labels and their definitions at call time; the prompt returns the single best fit with a rationale and confidence.
Use it for ticket categorization, intent tagging, content routing, topic labeling — anywhere the taxonomy is yours, not baked into the prompt.
| Entrypoint | Renders | Inputs |
|---|---|---|
system | Instructions + your label definitions + embedded output schema | labels, optional fallbackLabel |
user | The delimited text block to classify | text |
labels (array, required) — your candidate labels. Each item is { name, description }:
name (string) — machine-readable identifier, e.g. billing_issue.description (string) — one-sentence definition of when the label applies. Good descriptions drive accuracy far more than the model choice does.fallbackLabel (string, optional) — emitted when nothing fits, e.g. other. Omit it to force the model to always pick the closest label.text (string, required) — the text to classify.{
"rationale": "Mentions a duplicate charge on the monthly invoice.",
"label": "billing_issue",
"confidence": 0.91
}
rationale is emitted before label (reasoning-first; the system prompt pins the order).confidence is self-reported and ⚠️ not calibrated — a rough triage signal, not a probability.Because the label set is runtime input but the output schema is fixed per version, the generated parseOutput() can guarantee label is a string but cannot verify it's one of the labels you passed. Add a one-line membership check in your code:
const out = parseOutput(raw);
if (!labels.some(l => l.name === out.label)) {
// handle off-taxonomy label (retry, route to fallback, log)
}
text, label name/description, and fallbackLabel so special characters in your taxonomy are never HTML-escaped.additionalProperties: false, confidence bounded 0–1.Verified by local render with a sample label set. Suggested default model claude-sonnet-4-6 at temperature: 0.