Skip to content

AI Classify

Classifies input into one of your configured classes.

@lainstack/ai/classify · AI

Puts one input into exactly one of 2 to 8 classes that you define. Use it to route work by intent, document type or category. For free-form answers use @lainstack/ai/prompt. For multi-step investigation use @lainstack/ai/agent.

  • The block has one “out” port. To branch, add @lainstack/flow/switch after it and compare classId with your class ids.
  • Each class needs a unique id (lowercase, starts with a letter, letters, digits, “_” and “-”, up to 64 characters), a label and criteria (up to 2,000 characters) that say when the class applies. Clear, non-overlapping criteria matter more than instructions.
  • The model must pick one class. It cannot answer “none”. Add an explicit catch-all class such as “other” if the input may fit nothing.
  • inputKind must match the value in input. A mismatch fails the block (ai_classification_input_invalid) and is not retried.
  • A provider reply that is not one of your classes fails the block (ai_classification_invalid_response). There is no fallback to another model.
  • probabilities and confidence appear only when the provider returns them. They are never estimated. engineKind says whether a native decision model or a structured language model answered.
  • Needs an AI connection (provider or decision provider) and a model of that connection. The timeout defaults to 30 s (allowed 1 s to 300 s).
  • A replay or a test run calls the model again, unless the block has a pinned sample output (testing).
Setting Key Type Details
Connection (required) credentialId Connection
Model (required) model Text At most 240 characters.
Input (required) input Text
Instructions instructions Text
Classes (required) classes List From 2 to 8 items.
Timeout timeoutMs Number
Output Path Type
Class ID classId Text
Class label classLabel Text
Engine engineKind Text
Configured model configuredModel Text
Resolved model resolvedModel Text
Probabilities probabilities List
Provider confidence confidence.value Number