Skip to content

Classifier

Overview

The Classifier node sends input text and a list of category labels to a language model, which returns the most appropriate label (or labels, in multi-label mode). A confidence score is produced for each predicted category; results below confidence_threshold are excluded from the output. This node replaces ad-hoc prompt engineering for classification tasks and produces a consistent, structured output that downstream nodes can branch on without additional parsing.

Configuration

FieldTypeRequiredDefaultDescription
categoriesarray of stringsYesOrdered list of category labels the model may assign. Each label should be a short, unambiguous string (e.g. ["positive", "negative", "neutral"]).
model_keystringYesLanguage model to use for classification (e.g. "gpt-4o-mini", "claude-3-haiku"). Must be registered in the platform's model registry.
multi_labelbooleanNofalseWhen false (default), the model returns exactly one category (single-label classification). When true, the model may return multiple categories that all apply.
confidence_thresholdnumberNo0.5Minimum confidence score (0–1) a category must achieve to appear in the output. Categories below this value are silently dropped. Only meaningful when the model returns probability estimates.
system_promptstringNoCustom system prompt providing domain context or classification guidelines. If omitted, a default zero-shot classification prompt is used.
input_pathstringNo"$.text"JSONPath expression pointing to the text field in the incoming data object. Defaults to the top-level text property.

Inputs

PortTypeDescription
inputobjectData object containing the text to classify. The field at input_path is extracted and sent to the model.
textstringShorthand input: a bare string to classify. When connected, input_path is ignored.

Outputs

PortTypeDescription
labelstringThe top predicted category label. In single-label mode this is always set. In multi-label mode it is the highest-confidence label above the threshold.
labelsarray of objectsAll predicted categories above confidence_threshold, each with { label: string, confidence: number }, sorted descending by confidence.
confidencenumberConfidence score of the top label (0–1).
usageobjectToken usage for the LLM call: { prompt_tokens: number, completion_tokens: number, total_tokens: number }.

Example

json
{
  "nodeType": "classifier",
  "config": {
    "model_key": "gpt-4o-mini",
    "categories": ["bug_report", "feature_request", "question", "praise", "other"],
    "multi_label": false,
    "confidence_threshold": 0.6,
    "input_path": "$.body"
  }
}
json
{
  "nodeType": "classifier",
  "config": {
    "model_key": "claude-3-haiku",
    "categories": ["violence", "hate_speech", "spam", "adult_content", "safe"],
    "multi_label": true,
    "confidence_threshold": 0.75,
    "system_prompt": "You are a content moderation assistant. Apply all labels that clearly apply."
  }
}

Notes

  • In single-label mode, connect the label output directly to a switch node to branch the workflow per category without an intermediate output_parser step.
  • Confidence scores are model-dependent; some models return calibrated probabilities while others produce heuristic estimates. Validate thresholds empirically for your use case.
  • For a fixed, small label set (2–5 categories), lower-cost models like gpt-4o-mini or claude-3-haiku typically achieve accuracy comparable to larger models at a fraction of the cost.
  • When using multi_label: true, the labels array may be empty if no category clears confidence_threshold; add a downstream if_condition to handle this case explicitly.