Skip to main content

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.

Installation

pip install agno-deepkeep

Set credentials:

export DEEPKEEP_API_KEY="dk_..."
export DEEPKEEP_BASE_URL="https://api.example.deepkeep.ai"

Input guardrails

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",
        )
    ],
)

Output guardrails

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",
        )
    ],
)

Input and output protection

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")],
)

DeepKeep endpoints

This package uses the same DeepKeep OpenAI-compatible moderation endpoints as the LangChain integration:

  • POST /api/v3/openai/moderations/pre with {"model", "input", "title", "chat"}.
  • POST /api/v3/openai/moderations/post with {"model", "output", "title", "chat"}.
  • X-API-Key for authentication.

pre_model and post_model are DeepKeep firewall IDs. Each value is sent to the matching moderation endpoint as the model field.

Guardrail actions

DeepKeep responses are interpreted from verbosity[].details.guardrail_action:

  • block: Raises Agno InputCheckError or OutputCheckError.
  • redact or modify: 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.

Configuration

  • api_key: DeepKeep API key. If omitted, reads DEEPKEEP_API_KEY.
  • base_url: DeepKeep base URL, without a trailing slash. If omitted, reads DEEPKEEP_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 to 30.0.
  • fail_closed: Raise a guardrail error when DeepKeep cannot be reached. Defaults to True.

Recommended Agno docs positioning

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agno_deepkeep-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agno_deepkeep-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file agno_deepkeep-0.1.1.tar.gz.

File metadata

  • Download URL: agno_deepkeep-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agno_deepkeep-0.1.1.tar.gz
Algorithm Hash digest
SHA256 18f324ca339082f6a0cb92e6d3e29d3dfe75eedd476b4c8e22961ccd3ac3985d
MD5 5310a28d0962d2178ae01b181dd2cea8
BLAKE2b-256 df2cca92bc744bb022b713a407a2131e2e99970e391ebfccb4d942c9c36720b1

See more details on using hashes here.

File details

Details for the file agno_deepkeep-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agno_deepkeep-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agno_deepkeep-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9d0a8bd5a817dfc849f0697167346c2799e45f6f15315516114250ade4ce229c
MD5 27e2f0bca4b31d056d9d6ede1ed7b8f5
BLAKE2b-256 9379000f0b19ecb0132963e4c6784df1133c3ba4136daf7d11180bc426b5d24d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page