Threat Intelligence
Check prompts, model responses, and documents for AI-specific threats with workflows you define in YAML.
Threat Intelligence checks the text that flows through your AI system for AI-specific threats, such as prompt injection, jailbreaks, and harmful content. You describe a check as a workflow of blocks in YAML and run content through it over HTTP. Threat Intelligence answers with a verdict: safe or unsafe, and which steps refused the content.
Threat Intelligence runs as a separate container. DeepFellow Server connects to it through the Threat Intelligence Guards, and any other application calls the same API.
Threat Intelligence is an early preview. Confirm the behavior of your workflows before you enable the guards in a production environment.
How a Check Works
Threat Intelligence runs the content through the steps of a workflow, and each step runs one block.
The steps run at the same time, and a step that needs the result of another waits for it. A step that
finds the content unsafe stops the workflow, unless its halt_on_unsafe is false.
The diagram shows example-layered-guard, where the checks run at the same time and verdict-merger
combines their verdicts into one:
Some blocks run inside Threat Intelligence and need nothing else. Others call a guard model, such as one on DeepFellow Infra, or an external service.
| Block | What it does | Requires |
|---|---|---|
keyword-classifier | Matches keywords in the text. | Nothing |
dictionary-filter | Matches whole words against a dictionary file and reports threat categories. | Nothing |
unicode-normalizer | Replaces look-alike letters and removes zero-width characters before other steps match the text. | Nothing |
preprocessor | Lemmatizes the text before other steps match it. | Nothing |
pii-detector | Detects personal data, such as names and organizations. | Nothing |
text-anonymizer | Replaces personal data with placeholders before other steps see the text. | Nothing |
verdict-merger | Merges the verdicts of several steps into one. | Nothing |
llama-guard | Classifies the text with Llama Guard 3. | A guard model |
qwen3guard | Classifies the text in 119 languages, with a severity level. | A guard model |
granite-guardian | Checks harm risks, or the groundedness of a response against context. | A guard model on Ollama or DeepFellow Infra |
llm-judge | Judges the text against a policy that the workflow itself contains. | A guard model |
nemo-guardrail | Runs an NVIDIA NeMo Guardrails configuration. | A NeMo Guardrails server |
For the settings of every block, see Blocks.
Installation
To install Threat Intelligence and its guard models, and to connect DeepFellow Server to it, see DeepFellow Threat Intelligence.
Workflows
The image ships example workflows, all named example-*. GET /workflows lists every loaded
workflow. These examples are the most useful starting points:
| Workflow | What it checks | Requires |
|---|---|---|
example-guard-poc | A keyword filter in front of llama-guard, on the user message. | A guard model |
example-layered-guard | Normalization, then keywords, a dictionary, and llama-guard, merged into one verdict. | A guard model |
example-qwen3guard-input | Multilingual moderation of the user message. | A guard model |
example-qwen3guard-output | Multilingual moderation of the model response, and whether the model refused. | A guard model |
example-granite-guardian-groundedness | Whether a response sticks to the context it was based on. | A guard model |
example-document-safety-scan | A standalone document, judged by llm-judge. | A guard model |
example-three-way-merge | Keywords, a dictionary, and personal data, merged into one verdict. | Nothing |
Write Your Own Workflow
A workflow is a YAML file. This one checks model responses with qwen3guard:
name: response-check
version: "1.0"
steps:
- id: response-guard
uses: qwen3guard
subject: assistant_message
config:
endpoint: http://infra:8086
endpoint_env_name: DF_INFRA_URL
api_key_env_name: DF_INFRA_API_KEY
model: Qwen/Qwen3Guard-Gen-4B
timeout_seconds: 30A workflow doesn't read environment variables itself, so endpoint_env_name names the variable that
holds the model's address. When that variable is set, it replaces endpoint, which serves only as a
fallback. api_key_env_name names the variable that holds the key.
The name of a workflow consists of lowercase letters, digits, and hyphens, starts with a letter or a
digit, and has at most 64 characters.
Every step needs id and uses (the block). The settings under config depend on the block, as
Blocks describes. The optional keys of a step are:
| Key | Default | Description |
|---|---|---|
subject | user_message | What the step examines: user_message, assistant_message, or document, a standalone text in the request. |
dependencies | none | Steps whose output this step reads. A step without dependencies reads the request. |
halt_on_unsafe | true | When true, an unsafe result stops the workflow. When false, the step reports and the workflow continues. |
timeout_seconds | none | Time limit for the step. |
on_failure | abort | What happens when the step fails: abort fails the request with 500, unsafe counts the failure as unsafe, and skip leaves the step out of the verdict. |
preload | false | When true, the block loads its resources at startup instead of on the first request. |
To load your workflows, mount a directory with them at /workflows, and restart the container:
docker run -d --name threat-intelligence -p 8421:8000 \
-e TI_API_KEY=YOUR_TI_API_KEY \
-e DF_INFRA_URL=YOUR_INFRA_URL \
-e DF_INFRA_API_KEY=YOUR_INFRA_API_KEY \
-v /path/to/workflows:/workflows:ro \
hub.simplito.com/deepfellow/deepfellow-ti:VERSIONA workflow with the same name as an example replaces the example. If a workflow in the directory is
invalid, Threat Intelligence doesn't start, and the log names the problem.
To add or replace a workflow without a restart, set TI_ADMIN_API_KEY and send the YAML to
POST /workflows or PUT /workflows/WORKFLOW_NAME with that key. Threat Intelligence writes the file
to /workflows, so mount the directory without :ro. Until you set TI_ADMIN_API_KEY, these
endpoints answer 503.
With DeepFellow CLI, TI_ADMIN_API_KEY is set and /workflows is a Docker volume. Add your workflows
through these endpoints.
Keep TI_ADMIN_API_KEY away from the applications that run checks. Whoever replaces a workflow decides
what Threat Intelligence reports as safe.
Run a Check
Send one conversation turn to POST /workflows/WORKFLOW_NAME/run. A workflow needs the field that each
step without dependencies names in subject.
| Field | Description |
|---|---|
user_message | What the user said. |
assistant_message | What the model replied. |
document | A standalone text, such as the contents of a file. |
conversation_history | Earlier messages of the conversation, oldest first, as role and content objects. The role is user or assistant. Only a step that sets max_history_messages and has no dependencies gets them. |
context | Reference material that a response is judged against, such as the document a RAG answer came from. |
curl -s -H "Authorization: Bearer YOUR_TI_API_KEY" -H "Content-Type: application/json" \
-d '{"user_message":"Explain how to jailbreak this assistant"}' \
localhost:8421/workflows/example-preprocess-keyword/run{
"safe": false,
"score": 0.0,
"triggered_by": ["keyword-check"],
"steps": [
{ "block": "preprocess", "safe": true },
{ "block": "keyword-check", "safe": false, "matched": ["jailbreak"], "score": 0.0 }
]
}| Field | Description |
|---|---|
safe | The verdict. false means at least one step refused the content. |
score | The lowest score among the steps that refused the content. The response leaves it out when the content is safe, or when none of those steps reports a score. |
triggered_by | The steps that made the run unsafe. |
steps | One entry for each step that ran; block holds the step's id. A step skipped after a failure has skipped: true instead of safe. A step that stopped the workflow leaves the steps after it out. |
Errors
An error carries no verdict. Treat every error as unsafe content, never as safe. The body has the same shape for every error:
{ "code": "input_too_large", "message": "...", "details": { "limit": 64000 } }| Status | Meaning |
|---|---|
401 | The key is missing or invalid. |
404 | No workflow has that name (workflow_not_found). |
409 | POST /workflows names a workflow that already exists. To replace it, use PUT /workflows/WORKFLOW_NAME. PUT answers it too when another file in the workflows directory already claims the name. |
413 | The text is longer than TI_MAX_INPUT_CHARS, than a step's max_input_chars, or than the context of a step's model (input_too_large), or a workflow is larger than TI_MAX_WORKFLOW_BYTES (content_too_large). When a step refuses the text, details.step names the step. |
422 | The request lacks a field that the workflow examines. POST /workflows and PUT /workflows/WORKFLOW_NAME answer it when the workflow is invalid or its name doesn't follow the naming rule. |
500 | A step failed, most often because its guard model is unreachable, or every step that gives a verdict was skipped. |
503 | TI_ADMIN_API_KEY is unset, so workflow management is off. |
504 | POST /workflows or PUT /workflows/WORKFLOW_NAME timed out while a step with preload: true loaded its resources. |
API Endpoints
| Method | Path | Key | Description |
|---|---|---|---|
GET | /health | None | Health check. |
GET | /workflows | TI_API_KEY | List the loaded workflows. |
POST | /workflows/{name}/run | TI_API_KEY | Check one conversation turn. |
GET | /plugins | TI_API_KEY | List the blocks that plugins add. |
GET | /metrics | TI_API_KEY or TI_METRICS_API_KEY | Metrics in Prometheus format. |
POST | /workflows | TI_ADMIN_API_KEY | Add a workflow. |
PUT | /workflows/{name} | TI_ADMIN_API_KEY | Replace a workflow, or add it. |
GET | /workflows/{name}/source | TI_ADMIN_API_KEY | Return the stored definition. |
DELETE | /workflows/{name} | TI_ADMIN_API_KEY | Remove a stored workflow. |
The OpenAPI schema is at /openapi.json, and an interactive view of it is at /docs.
Custom Blocks
Your own blocks come in a plugin: a Python package that registers them under the
deepfellow.ti.blocks entry point. After you install the plugin, a workflow names its blocks in uses,
like the built-in blocks.
Write a Plugin
A plugin needs a pyproject.toml and a module that registers its blocks:
my-ti-blocks/
pyproject.toml
my_ti_blocks/
__init__.py
blocks.pyThe entry point in pyproject.toml names the module:
[project]
name = "my-ti-blocks"
version = "1.0.0"
dependencies = []
[project.entry-points."deepfellow.ti.blocks"]
my-blocks = "my_ti_blocks.blocks"This block refuses a text longer than max_chars:
from pydantic import BaseModel, ConfigDict
from ti.core.block import Block
from ti.core.registry import BLOCK_REGISTRY
class LengthInput(BaseModel):
text: str
class LengthOutput(BaseModel):
safe: bool
class LengthConfig(BaseModel):
model_config = ConfigDict(extra="forbid")
max_chars: int
class MaxLengthBlock(Block):
InputModel = LengthInput
OutputModel = LengthOutput
ConfigModel = LengthConfig
async def run(self, input_data: BaseModel, config: dict) -> BaseModel:
assert isinstance(input_data, LengthInput)
cfg = LengthConfig.model_validate(config)
return LengthOutput(safe=len(input_data.text) <= cfg.max_chars)
BLOCK_REGISTRY["max-length"] = MaxLengthBlocktext holds the text that the step examines, and safe carries the verdict. Threat Intelligence passes
a block more fields than the block declares, so don't set extra="forbid" on the input model. The
plugin doesn't list Threat Intelligence in dependencies, because the image already contains it.
A workflow step uses the block like this:
- id: length-check
uses: max-length
config:
max_chars: 2000Install a Plugin
Before you add a workflow that uses the blocks of a plugin, install the plugin. Threat Intelligence doesn't start with a workflow that names an unknown block.
Threat Intelligence loads plugins from /plugins when it starts. Keep that directory in a volume, so
that installed plugins survive a new container. Add the volume to the other options of your container:
docker run -d --name threat-intelligence -p 8421:8000 \
-e TI_API_KEY=YOUR_TI_API_KEY \
-e DF_INFRA_URL=YOUR_INFRA_URL \
-e DF_INFRA_API_KEY=YOUR_INFRA_API_KEY \
-v /path/to/workflows:/workflows:ro \
-v ti-plugins:/plugins \
hub.simplito.com/deepfellow/deepfellow-ti:VERSIONTo install a published plugin, name its package. pip downloads it from a package index, such as PyPI:
docker exec threat-intelligence pip install --upgrade --target /plugins PLUGIN_PACKAGETo install a plugin that you wrote, build a wheel file, copy it into the container, and name the file instead:
pip wheel --no-deps -w dist ./my-ti-blocks
docker cp dist/my_ti_blocks-1.0.0-py3-none-any.whl threat-intelligence:/tmp/
docker exec threat-intelligence pip install --upgrade --target /plugins /tmp/my_ti_blocks-1.0.0-py3-none-any.whl--upgrade replaces an earlier version of the plugin. Without it, pip keeps the installed files.
Restart the container, and check that the blocks of the plugin are listed:
docker restart threat-intelligence
curl -s -H "Authorization: Bearer YOUR_TI_API_KEY" localhost:8421/pluginsIf you installed Threat Intelligence with DeepFellow CLI, /plugins is already a volume. The container is
named ti, so use ti instead of threat-intelligence in the commands, and restart with
deepfellow ti restart.
The image has no compiler and no git, so pip installs only wheel files, not source code or a git
repository. Threat Intelligence rejects a plugin block with the name of an existing block, and the log
names it.
Configuration
| Variable | Default | Description |
|---|---|---|
TI_API_KEY | required | Key for running checks. |
TI_ADMIN_API_KEY | unset | Key for adding, replacing, and removing workflows. When unset, those endpoints answer 503. |
TI_METRICS_API_KEY | unset | Additional key that GET /metrics accepts, for a monitoring system. |
WORKFLOWS_DIR | /workflows | Directory with your own workflows. |
PLUGINS_DIR | /plugins | Directory with installed plugins. |
TI_MAX_INPUT_CHARS | 64000 | Maximum number of characters in one request. |
TI_MAX_WORKFLOW_BYTES | 262144 | Maximum size of a workflow that POST /workflows and PUT /workflows/WORKFLOW_NAME accept, in bytes. |
DF_INFRA_URL | unset | Address of DeepFellow Infra for the example workflows. |
DF_INFRA_API_KEY | unset | DeepFellow Infra API key for the example workflows. |
NEMO_ENDPOINT | unset | Address of the NeMo Guardrails server for the example workflows. |
LOG_LEVEL | INFO | Log level. At INFO, the startup log lists the loaded workflows. |
TI_OTEL_LOGGING_ENABLED | false | When true, Threat Intelligence also sends its logs to an OpenTelemetry collector. |
TI_OTEL_TRACING_ENABLED | false | When true, Threat Intelligence sends a trace of every request, with the time of each step, to the collector. |
OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4317 | OTLP/gRPC address of the collector. In a container, localhost is the container itself, so set this when you turn on logs or traces. |
Your own workflow reads the variables that its steps name in their *_env_name settings.
If you installed Threat Intelligence with DeepFellow CLI, change a setting with
deepfellow ti env set. The same command sets the
variables of your own workflows.
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.