Skip to main content

AI security guardrails for LLM applications — scan inputs and check outputs with Claude, OpenAI, Gemini, Azure, or Ollama.

Project description

pydefend

AI security guardrails for LLM applications — scan inputs and check outputs with Claude, OpenAI, Gemini, Azure, or Ollama.

For the full project README, docs, and examples, see:

Install

pip install pydefend

Optional provider extras:

pip install "pydefend[openai]"      # OpenAI SDK integration
pip install "pydefend[anthropic]"   # Anthropic SDK integration
pip install "pydefend[gemini]"      # Gemini (google-genai) SDK integration
pip install "pydefend[fastapi]"     # FastAPI middleware/integration helpers
pip install "pydefend[langchain]"   # LangChain integration helpers
pip install "pydefend[all]"         # All optional integrations

Quick start

import asyncio
from pydefend import Defend

defend = Defend.default()

async def main():
    scanned = await defend.scan("User message here")
    if not scanned:
        return "Can't help with that."

    # ... call your LLM with scanned.text ...

    checked = await defend.check("Model reply here")
    return checked.text if checked else None

print(asyncio.run(main()))

Configuration

  • Code-first: use Defend.default() or the builder API to choose modules.
  • Config file: drop a defend.yaml into your repo and load it with Defend.from_yaml("defend.yaml").

Links

License

Apache-2.0 — see LICENSE in the GitHub repo.

Project details


Download files

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

Source Distribution

pydefend-1.0.0.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

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

pydefend-1.0.0-py3-none-any.whl (70.0 kB view details)

Uploaded Python 3

File details

Details for the file pydefend-1.0.0.tar.gz.

File metadata

  • Download URL: pydefend-1.0.0.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydefend-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7099b9c492c52296aa8c3c2ac03069db6c900b5ab4b488c8337ee7b3d878c328
MD5 2d0dd01af23b01a52304608b976cddd3
BLAKE2b-256 c1025ba8624a6390d11797f7d819f88cc45d5daebf5be142540970c4c6f8dc86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydefend-1.0.0.tar.gz:

Publisher: release.yml on Adxzer/defend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydefend-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydefend-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 70.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydefend-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e74226706af8e195dc9af0cfb7ecc79fea7bb77ca16329fcba8f58615a62e29
MD5 671d2a6c845134809c3a6845872da20c
BLAKE2b-256 08cbcc20bef068dd8e2c79283e89573ae6c732e383ae503833abfa5cfc507ea7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydefend-1.0.0-py3-none-any.whl:

Publisher: release.yml on Adxzer/defend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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