deepkeep_ai_firewall.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run the example
Save the code above as
deepkeep_ai_firewall.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use DeepKeep AI Firewall as custom guardrails for Agno Agents.
"""
DeepKeep AI Firewall Guardrails
===============================
This example shows how to use DeepKeep AI Firewall as custom guardrails for
Agno Agents. DeepKeep runs before user input reaches the model and after model
output is generated.
Requirements:
- pip install agno-deepkeep
- DEEPKEEP_API_KEY and DEEPKEEP_BASE_URL set
Set credentials before running:
export DEEPKEEP_API_KEY="dk_..."
export DEEPKEEP_BASE_URL="https://api.example.deepkeep.ai"
Usage:
python cookbook/02_agents/08_guardrails/deepkeep_ai_firewall.py
"""
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno_deepkeep import DeepKeepGuardrail
agent = Agent(
name="DeepKeep Protected Agent",
model=OpenAIResponses(id="gpt-5.2"),
instructions="Answer user questions safely and concisely.",
pre_hooks=[
DeepKeepGuardrail(
pre_model="input-firewall-id",
)
],
post_hooks=[
DeepKeepGuardrail(
post_model="output-firewall-id",
)
],
markdown=True,
)
if __name__ == "__main__":
agent.print_response("Explain how to store API keys securely.")
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno agno-deepkeep openai
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run the example
deepkeep_ai_firewall.py, then run:python deepkeep_ai_firewall.py
Was this page helpful?