Skip to main content
The Firewall SDK validates AI inputs and outputs against content safety policies in real time. It integrates with the monitoring SDK via hooks — dangerous prompts are blocked before reaching the model, and risky responses are flagged after generation.

Installation

Quick start

With this configuration:
  • Inputs are validated before reaching the AI model. If a violation is detected, a HookBlockedError is thrown and the request never reaches the model.
  • Outputs are validated after the AI responds. Violations are logged but the response is still returned.

Configuration

Violation actions

Throws a HookBlockedError, preventing the AI call:
Logs a warning but allows the request/response to proceed:

Callback

Invokes your custom function with full violation context:

Violation context

Risk threshold

Only trigger violations when the risk score exceeds a threshold:

Category filtering

Only check specific risk categories:

Standalone client

Use the Firewall without the monitoring SDK for direct API access:

Error handling

Fail-open design

If the Firewall API is unreachable (network error, timeout, etc.), the request proceeds normally. This fail-open design ensures your AI application remains available even if the Firewall is temporarily down. Errors are logged but do not block AI calls.

Full example