New to Kestra?
Use blueprints to kickstart your first workflows.
Redact PII from documents with a local Ollama model in Kestra. The text never leaves your network, and only the sanitized artifact moves downstream.
Using a cloud API to remove personal data from a document has an obvious flaw: the unredacted document, PII included, must be sent to the cloud first. This blueprint inverts that. io.kestra.plugin.ollama.cli.OllamaCLI runs the redaction model on your own infrastructure, so the sensitive original never crosses the network boundary, and only the sanitized redacted.txt artifact is available for downstream steps that talk to external tools, vendors, or larger cloud LLMs.
redact receives the document through inputFiles (inline here for the demo; map it from internal storage in real use) and runs ollama run {{ inputs.model }} with a prompt that names the PII categories to strip, mandates the [REDACTED] placeholder, and forbids any other changes to the text.redacted.txt, and outputFiles uploads it to internal storage as the execution's sanitized artifact, addressable as {{ outputs.redact.outputFiles['redacted.txt'] }} by any downstream task.enableModelCaching: true persists the model between runs, so recurring redaction jobs skip the download.notify posts a completion pointer to Slack. Deliberately, neither the original nor the redacted content is interpolated into the payload, since the notification channel itself may leave the compliance boundary.errors block posts a distinct alert that explicitly warns against sharing the source document when the run fails.A redaction policy is only as good as its enforcement point. Running the model inside a Kestra flow makes the sanitized artifact the only thing downstream tasks can conveniently reference, gives every redaction an execution record for audits, and alerts the moment a run fails instead of letting an unsanitized file slip through a broken script. LLM-based redaction is probabilistic, so keep a human review step for high-stakes documents; the execution artifact gives reviewers exactly one file to check.
containerImage runs Ollama inside Docker, so the Kestra worker needs access to a Docker daemon. On self-hosted workers that already have Ollama installed locally, set the task's taskRunner to Process to keep inference on that machine.SLACK_WEBHOOK_URL: Slack incoming webhook URL.SLACK_WEBHOOK_URL secret to your Kestra namespace.redacted.txt; all three names, emails, and the phone number in the sample should read [REDACTED].redacted.txt to a cloud LLM for summarization, combining local privacy with hosted model quality.redacted.txt that fails the execution if an email or phone pattern survived.ForEach over file names, reusing the warmup pattern from the Ollama model warmup blueprint.