pydantic-ai-enkrypt#
Warning
This project is a proof of concept. There is no guarantee that it will be maintained, and APIs may change or disappear without notice. You are welcome to discuss it in the issue tracker.
pydantic-ai-enkrypt checks what goes into and comes out of a pydantic-ai agent with Enkrypt AI. It provides guards for the pydantic-ai-harness guardrails:
Enkrypt decides whether a prompt, an answer, a tool call or a tool result contains an attack, toxic content, a secret, personal data or a breach of your own rules.
The harness guardrails (
InputGuardrail,OutputGuardrail,ToolGuardrail) run guards at those points in a run.This package’s guards connect the two: each sends a value to Enkrypt, then allows it, blocks it, raises, asks the model to try again, or redacts personal data, as you choose.
from pydantic_ai import Agent
from pydantic_ai_harness import InputGuardrail
from pydantic_ai_enkrypt import Enkrypt
enkrypt = Enkrypt() # reads ENKRYPTAI_API_KEY
agent = Agent(
"openai:gpt-6.1-sol",
capabilities=[InputGuardrail(guard=[enkrypt.injection_attack(on_violation="block")])],
)
An attack in the prompt never reaches the model; the run returns Enkrypt’s refusal instead.
Where to go next#
Install, set up your Enkrypt key, and guard a first agent.
Edges, actions, the order guards run in, and what happens when Enkrypt is unreachable.
One page per guard: what it checks, its options and its defaults.
Redact personal data, restore it for tools and users, and keep it across a conversation.
Rate limits, connections, and observing guards before they act.
Runnable scripts, each showing one use, with their output.