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:
- GitHub repo: https://github.com/Adxzer/defend
- Docs: https://www.pydefend.com/docs
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.yamlinto your repo and load it withDefend.from_yaml("defend.yaml").
Links
- Repository / issues: https://github.com/Adxzer/defend
- Documentation: https://www.pydefend.com/docs
License
Apache-2.0 — see LICENSE in the GitHub repo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7099b9c492c52296aa8c3c2ac03069db6c900b5ab4b488c8337ee7b3d878c328
|
|
| MD5 |
2d0dd01af23b01a52304608b976cddd3
|
|
| BLAKE2b-256 |
c1025ba8624a6390d11797f7d819f88cc45d5daebf5be142540970c4c6f8dc86
|
Provenance
The following attestation bundles were made for pydefend-1.0.0.tar.gz:
Publisher:
release.yml on Adxzer/defend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydefend-1.0.0.tar.gz -
Subject digest:
7099b9c492c52296aa8c3c2ac03069db6c900b5ab4b488c8337ee7b3d878c328 - Sigstore transparency entry: 1205944545
- Sigstore integration time:
-
Permalink:
Adxzer/defend@1e77c61e78ec66a405d029e99a8b4cc3dba40896 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Adxzer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1e77c61e78ec66a405d029e99a8b4cc3dba40896 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e74226706af8e195dc9af0cfb7ecc79fea7bb77ca16329fcba8f58615a62e29
|
|
| MD5 |
671d2a6c845134809c3a6845872da20c
|
|
| BLAKE2b-256 |
08cbcc20bef068dd8e2c79283e89573ae6c732e383ae503833abfa5cfc507ea7
|
Provenance
The following attestation bundles were made for pydefend-1.0.0-py3-none-any.whl:
Publisher:
release.yml on Adxzer/defend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydefend-1.0.0-py3-none-any.whl -
Subject digest:
8e74226706af8e195dc9af0cfb7ecc79fea7bb77ca16329fcba8f58615a62e29 - Sigstore transparency entry: 1205944564
- Sigstore integration time:
-
Permalink:
Adxzer/defend@1e77c61e78ec66a405d029e99a8b4cc3dba40896 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Adxzer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1e77c61e78ec66a405d029e99a8b4cc3dba40896 -
Trigger Event:
workflow_dispatch
-
Statement type: