SafePrompt Python SDK
Protect your AI application from prompt injection attacks with one function call.
Install
pip install safeprompt
Quick Start
from safeprompt import SafePrompt
sp = SafePrompt(api_key="YOUR_API_KEY")
result = sp.check(user_input, user_ip=request.remote_addr)
if not result["safe"]:
raise ValueError(f"Blocked: {result['threats'][0]}")
Async Support
from safeprompt import AsyncSafePrompt
async with AsyncSafePrompt(api_key="YOUR_API_KEY") as sp:
result = await sp.check(user_input)
if not result["safe"]:
raise ValueError(f"Blocked: {result['threats'][0]}")
Response Format
{
"safe": True,
"threats": [],
"confidence": 0.99,
"processingTimeMs": 45,
"passesUsed": 1
}
Error Handling
from safeprompt import SafePromptError
try:
result = sp.check(user_input)
except SafePromptError as e:
print(e.status_code)
print(str(e))
Links
Metadata
Release files for safeprompt 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| safeprompt-1.4.0.tar.gz | 3.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| safeprompt-1.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / safeprompt-1.4.0.tar.gz
| Download URL | safeprompt-1.4.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d4c21d4a0a6ce05f19dc4c2e1df0a699ffdb4c1611858431aa4145ce2c7dd83
|
|
BLAKE2b-256 checksum How to use checksums |
26c0e2bd7a3b7a71cddc98d3249c5e0c8e62d2a3cb051c5eb47daa7441182c20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
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 Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 6, 2026.
Transparency logRelease files / safeprompt-1.4.0-py3-none-any.whl
| Download URL | safeprompt-1.4.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9aff037f21d42b39ff70db0890b99f26640169b7c6f96a99eb5c702a3423702d
|
|
BLAKE2b-256 checksum How to use checksums |
2b8e2acfc0e03e463f0e30e075c746c126394d7d455e4ae6c43c0d73db80084a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
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 Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 6, 2026.
Transparency logSecurity for safeprompt 1.4.0
Provenance
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for safeprompt-1.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 6, 2026.
Transparency logA 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.