Development moved: This integration is maintained in the DeepKeep integrations monorepo. Please open new issues and pull requests in the monorepo. Historical source and existing links remain available here. The PyPI package name remains
agno-deepkeep.
DeepKeep AI Firewall custom guardrails for Agno.
This package follows Agno's native guardrail extension point. Add DeepKeepGuardrail to an Agent or Team with pre_hooks to check input before it reaches the model, or with post_hooks to check output before it is returned.
pip install agno-deepkeepSet credentials:
export DEEPKEEP_API_KEY="dk_..."
export DEEPKEEP_BASE_URL="https://api.example.deepkeep.ai"Use pre_hooks to run DeepKeep pre-moderation before an Agno Agent or Team processes user input:
from agno.agent import Agent
from agno_deepkeep import DeepKeepGuardrail
agent = Agent(
name="DeepKeep Protected Agent",
model="openai:gpt-5.2",
pre_hooks=[
DeepKeepGuardrail(
pre_model="input-firewall-id",
)
],
)Use post_hooks to run DeepKeep post-moderation after the model response is generated:
from agno.agent import Agent
from agno_deepkeep import DeepKeepGuardrail
agent = Agent(
name="DeepKeep Protected Agent",
model="openai:gpt-5.2",
post_hooks=[
DeepKeepGuardrail(
post_model="output-firewall-id",
)
],
)Use separate instances when you want distinct firewall IDs for input and output checks:
from agno.agent import Agent
from agno_deepkeep import DeepKeepGuardrail
agent = Agent(
name="DeepKeep Protected Agent",
model="openai:gpt-5.2",
pre_hooks=[DeepKeepGuardrail(pre_model="input-firewall-id")],
post_hooks=[DeepKeepGuardrail(post_model="output-firewall-id")],
)This package uses the same DeepKeep OpenAI-compatible moderation endpoints as the LangChain integration:
POST /api/v3/openai/moderations/prewith{"model", "input", "title", "chat"}.POST /api/v3/openai/moderations/postwith{"model", "output", "title", "chat"}.X-API-Keyfor authentication.
pre_model and post_model are DeepKeep firewall IDs. Each value is sent to the matching moderation endpoint as the model field.
DeepKeep responses are interpreted from verbosity[].details.guardrail_action:
block: Raises AgnoInputCheckErrororOutputCheckError.redactormodify: Replaces Agno input or output when DeepKeep returns modified content.alert: Allows the run to continue.
If DeepKeep returns an unsupported action, the guardrail fails closed.
api_key: DeepKeep API key. If omitted, readsDEEPKEEP_API_KEY.base_url: DeepKeep base URL, without a trailing slash. If omitted, readsDEEPKEEP_BASE_URL.pre_model: DeepKeep firewall ID for pre-moderation.post_model: DeepKeep firewall ID for post-moderation.title: Optional title value sent to DeepKeep.chat: Optional chat value sent to DeepKeep.timeout: Request timeout in seconds. Defaults to30.0.fail_closed: Raise a guardrail error when DeepKeep cannot be reached. Defaults toTrue.
The official cookbook example was accepted in PR #9784. The separate overview proposal PR #760 remains open; it is not an accepted overview listing. The positioning below is retained for reference.
Position the public integration as DeepKeep AI Firewall in Agno's custom guardrails area:
DeepKeep AI Firewall
Use DeepKeep AI Firewall as custom guardrails for Agno Agents and Teams. Add DeepKeepGuardrail to pre_hooks or post_hooks to enforce runtime policies for prompt injection, jailbreaks, sensitive data leakage, unsafe content, and other AI risks.
For production enforcement, prefer Agno guardrails over agent-callable tools because guardrails run deterministically before or after model execution.