Prompt injection protection for AI applications
Project description
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
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 safeprompt-1.4.0.tar.gz.
File metadata
- Download URL: safeprompt-1.4.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d4c21d4a0a6ce05f19dc4c2e1df0a699ffdb4c1611858431aa4145ce2c7dd83
|
|
| MD5 |
49ad25c12b7a1451869dcd40e556ff52
|
|
| BLAKE2b-256 |
26c0e2bd7a3b7a71cddc98d3249c5e0c8e62d2a3cb051c5eb47daa7441182c20
|
Provenance
The following attestation bundles were made for safeprompt-1.4.0.tar.gz:
Publisher:
publish-pypi.yml on ianreboot/safeprompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safeprompt-1.4.0.tar.gz -
Subject digest:
1d4c21d4a0a6ce05f19dc4c2e1df0a699ffdb4c1611858431aa4145ce2c7dd83 - Sigstore transparency entry: 1452413244
- Sigstore integration time:
-
Permalink:
ianreboot/safeprompt@5fb96db4c21392f7e5ad424fa24f18dba5b8cd35 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/ianreboot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5fb96db4c21392f7e5ad424fa24f18dba5b8cd35 -
Trigger Event:
push
-
Statement type:
File details
Details for the file safeprompt-1.4.0-py3-none-any.whl.
File metadata
- Download URL: safeprompt-1.4.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aff037f21d42b39ff70db0890b99f26640169b7c6f96a99eb5c702a3423702d
|
|
| MD5 |
0044dd14de34b8e1f1e5654998d84895
|
|
| BLAKE2b-256 |
2b8e2acfc0e03e463f0e30e075c746c126394d7d455e4ae6c43c0d73db80084a
|
Provenance
The following attestation bundles were made for safeprompt-1.4.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on ianreboot/safeprompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safeprompt-1.4.0-py3-none-any.whl -
Subject digest:
9aff037f21d42b39ff70db0890b99f26640169b7c6f96a99eb5c702a3423702d - Sigstore transparency entry: 1452413375
- Sigstore integration time:
-
Permalink:
ianreboot/safeprompt@5fb96db4c21392f7e5ad424fa24f18dba5b8cd35 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/ianreboot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5fb96db4c21392f7e5ad424fa24f18dba5b8cd35 -
Trigger Event:
push
-
Statement type: