Skip to main content Switch to mobile version safeprompt 1.4.1 Prompt injection protection for AI applications
pip install safeprompt==1.4.1 Copy PIP instructions
Protect your AI application from prompt injection attacks with one function call.
pip install safeprompt Quick Start
from safeprompt import SafePrompt sp = SafePrompt(api_key="YOUR_API_KEY") # user_ip is your END USER's address, not your server's. The API requires it. result = sp.check(user_input, user_ip=request.remote_addr) if not result["safe"]: raise ValueError(f"Blocked: {result['threats'][0]}") check() takes prompt, then keyword arguments user_ip and session_token. If you omit user_ip the SDK sends 127.0.0.1, which makes the call succeed but attributes every attack to localhost in threat intelligence; always pass the real address. There is no mode argument. session_token is accepted for older integrations and does not change the verdict: each check is judged on its own, so send turns that must be judged together in one prompt.
from safeprompt import AsyncSafePrompt async with AsyncSafePrompt(api_key="YOUR_API_KEY") as sp: result = await sp.check(user_input, user_ip=request.remote_addr) if not result["safe"]: raise ValueError(f"Blocked: {result['threats'][0]}") Response Format
{ "safe": True, "threats": [], "confidence": 0.99, "processingTime": 45 } Error Handling
Both files in this release have provenance metadata.
ai jailbreak llm llm-security owasp-llm prompt-injection safeguard safeprompt security
Development Status 4 - Beta
Intended Audience Developers
License OSI Approved :: MIT License
Programming Language Python :: 3
Software Development :: Libraries :: Python Modules
Release files for safeprompt 1.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 8.6 kB
Release files / safeprompt-1.4.1.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Release files / safeprompt-1.4.1-py3-none-any.whl
Security for safeprompt 1.4.1
Both files in this release have been uploaded with provenance metadata.
With provenance safeprompt-1.4.1.tar.gz Nov 25, 2026
With provenance safeprompt-1.4.1-py3-none-any.whl Nov 25, 2026
Attestation for safeprompt-1.4.1.tar.gz
Attestation for safeprompt-1.4.1-py3-none-any.whl
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 25, 2026 2 release files Full provenance
May 6, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




