Skip to main content
guard.scan inspects a payload and reports the decision. It never throws: a failed detection call is resolved by onScanError.

Input shapes

Every guard method accepts a bare string or a { system, messages } payload.
A system field and any system-role messages are merged into one system string, because Anthropic accepts only one. The whole payload is flattened into one string and sent in a single detection call. Multimodal content is flattened automatically, and non-text parts such as images are left alone.

Reading the result

A match carries an evidence field only when the client was created with includeEvidence, because evidence is your own text.

Shortcuts

BlockedError carries the full result, so you can log what was found without scanning again.

Severity threshold

blockSeverity sets the lowest severity that blocks. It defaults to medium. A match below it is still reported in matches, but blocked stays false.