DeepFellow DOCS

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.

BlockWhat it doesRequires
keyword-classifierMatches keywords in the text.Nothing
dictionary-filterMatches whole words against a dictionary file and reports threat categories.Nothing
unicode-normalizerReplaces look-alike letters and removes zero-width characters before other steps match the text.Nothing
preprocessorLemmatizes the text before other steps match it.Nothing
pii-detectorDetects personal data, such as names and organizations.Nothing
text-anonymizerReplaces personal data with placeholders before other steps see the text.Nothing
verdict-mergerMerges the verdicts of several steps into one.Nothing
llama-guardClassifies the text with Llama Guard 3.A guard model
qwen3guardClassifies the text in 119 languages, with a severity level.A guard model
granite-guardianChecks harm risks, or the groundedness of a response against context.A guard model on Ollama or DeepFellow Infra
llm-judgeJudges the text against a policy that the workflow itself contains.A guard model
nemo-guardrailRuns 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:

WorkflowWhat it checksRequires
example-guard-pocA keyword filter in front of llama-guard, on the user message.A guard model
example-layered-guardNormalization, then keywords, a dictionary, and llama-guard, merged into one verdict.A guard model
example-qwen3guard-inputMultilingual moderation of the user message.A guard model
example-qwen3guard-outputMultilingual moderation of the model response, and whether the model refused.A guard model
example-granite-guardian-groundednessWhether a response sticks to the context it was based on.A guard model
example-document-safety-scanA standalone document, judged by llm-judge.A guard model
example-three-way-mergeKeywords, 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: 30

A 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:

KeyDefaultDescription
subjectuser_messageWhat the step examines: user_message, assistant_message, or document, a standalone text in the request.
dependenciesnoneSteps whose output this step reads. A step without dependencies reads the request.
halt_on_unsafetrueWhen true, an unsafe result stops the workflow. When false, the step reports and the workflow continues.
timeout_secondsnoneTime limit for the step.
on_failureabortWhat 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.
preloadfalseWhen 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:VERSION

A 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.

FieldDescription
user_messageWhat the user said.
assistant_messageWhat the model replied.
documentA standalone text, such as the contents of a file.
conversation_historyEarlier 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.
contextReference 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 }
  ]
}
FieldDescription
safeThe verdict. false means at least one step refused the content.
scoreThe 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_byThe steps that made the run unsafe.
stepsOne 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 } }
StatusMeaning
401The key is missing or invalid.
404No workflow has that name (workflow_not_found).
409POST /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.
413The 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.
422The 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.
500A step failed, most often because its guard model is unreachable, or every step that gives a verdict was skipped.
503TI_ADMIN_API_KEY is unset, so workflow management is off.
504POST /workflows or PUT /workflows/WORKFLOW_NAME timed out while a step with preload: true loaded its resources.

API Endpoints

MethodPathKeyDescription
GET/healthNoneHealth check.
GET/workflowsTI_API_KEYList the loaded workflows.
POST/workflows/{name}/runTI_API_KEYCheck one conversation turn.
GET/pluginsTI_API_KEYList the blocks that plugins add.
GET/metricsTI_API_KEY or TI_METRICS_API_KEYMetrics in Prometheus format.
POST/workflowsTI_ADMIN_API_KEYAdd a workflow.
PUT/workflows/{name}TI_ADMIN_API_KEYReplace a workflow, or add it.
GET/workflows/{name}/sourceTI_ADMIN_API_KEYReturn the stored definition.
DELETE/workflows/{name}TI_ADMIN_API_KEYRemove 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.py

The 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"] = MaxLengthBlock

text 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: 2000

Install 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:VERSION

To 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_PACKAGE

To 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/plugins

If 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

VariableDefaultDescription
TI_API_KEYrequiredKey for running checks.
TI_ADMIN_API_KEYunsetKey for adding, replacing, and removing workflows. When unset, those endpoints answer 503.
TI_METRICS_API_KEYunsetAdditional key that GET /metrics accepts, for a monitoring system.
WORKFLOWS_DIR/workflowsDirectory with your own workflows.
PLUGINS_DIR/pluginsDirectory with installed plugins.
TI_MAX_INPUT_CHARS64000Maximum number of characters in one request.
TI_MAX_WORKFLOW_BYTES262144Maximum size of a workflow that POST /workflows and PUT /workflows/WORKFLOW_NAME accept, in bytes.
DF_INFRA_URLunsetAddress of DeepFellow Infra for the example workflows.
DF_INFRA_API_KEYunsetDeepFellow Infra API key for the example workflows.
NEMO_ENDPOINTunsetAddress of the NeMo Guardrails server for the example workflows.
LOG_LEVELINFOLog level. At INFO, the startup log lists the loaded workflows.
TI_OTEL_LOGGING_ENABLEDfalseWhen true, Threat Intelligence also sends its logs to an OpenTelemetry collector.
TI_OTEL_TRACING_ENABLEDfalseWhen true, Threat Intelligence sends a trace of every request, with the time of each step, to the collector.
OTEL_EXPORTER_OTLP_ENDPOINThttp://localhost:4317OTLP/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.

On this page