crewai-paysafe
PaySafe payment security for CrewAI agents — crews inherit "scan before you pay" by default.
pip install crewai-paysafe
Two additions
from crewai import Agent
from paysafe_x402 import PaySafeClient
from crewai_paysafe import paysafe_tools, register_paysafe_provenance
paysafe = PaySafeClient(agent_id="my-agent") # free API key auto-minted (100 free scans)
register_paysafe_provenance(paysafe) # ← the important line (call once at startup)
agent = Agent(
role="Purchasing agent",
goal="Buy data over x402 safely",
tools=paysafe_tools(paysafe),
# ...
)
Every x402 payment the agent scans gets an allow / flag / block verdict with machine-readable reasons: prompt-injection-triggered payments, replayed nonces, overpayment vs the quote, secrets/PII leaking in payment metadata, lookalike-token contracts, address poisoning, counterparty reputation.
Why the provenance registration is the important line
PaySafe's strongest detector catches payments whose decision came from content the agent just read — a prompt-injected page or tool result that says "send payment to 0x…". That check needs to know what the agent read. register_paysafe_provenance installs a CrewAI after-tool-call hook that observes every tool output automatically, so the very next scan is provenance-tagged and the injection check runs with real input. No prompt engineering, no developer learning what "provenance" means. (PaySafe's own tool outputs are excluded, so verdicts never pollute the signal.) CrewAI's tool-call hooks are process-global — call it once at startup.
Enforcement: payments that can't execute when blocked
Tools rely on the model choosing to scan. guarded_payment doesn't:
from crewai.tools import BaseTool
from crewai_paysafe import guarded_payment
safe_pay = guarded_payment(execute_x402_payment, paysafe) # strict=True to refuse flags too
# build your payment tool's _run from safe_pay — on a block verdict it raises
# PaySafeBlockedError BEFORE execute_x402_payment is ever invoked.
For wallet-level enforcement (the signer itself refuses unscanned payments), see PaySafeEnforcer in the paysafe-x402 SDK.
The toolset
| Tool | When the agent is told to use it |
|---|---|
paysafe_scan_payment |
ALWAYS, immediately before settling any x402 payment (or before paying a received 402 offer with direction="incoming") |
paysafe_check_reputation |
Before dealing with an unfamiliar counterparty address |
paysafe_report_counterparty |
After a bad payment experience (always free) — warns other agents |
Verdicts are Ed25519-signed and payment-bound; the underlying client verifies them against a pinned key automatically.
MIT. PaySafe is advisory and non-custodial: it never touches keys, wallets, or funds.
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 crewai_paysafe-0.1.0.tar.gz.
File metadata
- Download URL: crewai_paysafe-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8698dfaf0864cb3c7d1da48dbcd3d385feec9ab15e83aa72d5b8b5d363b9563
|
|
| MD5 |
a67d4fea94e9684099222973a3cee653
|
|
| BLAKE2b-256 |
af08c19bdb37afb54501e72335bbfa2cdf002e499675cdfb0a49b9c0af5f7e92
|
Provenance
The following attestation bundles were made for crewai_paysafe-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on corbinallison/paysafe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crewai_paysafe-0.1.0.tar.gz -
Subject digest:
b8698dfaf0864cb3c7d1da48dbcd3d385feec9ab15e83aa72d5b8b5d363b9563 - Sigstore transparency entry: 2216218003
- Sigstore integration time:
-
Permalink:
corbinallison/paysafe@7f54cd1846b21d565bb16b65eb8d09be029245d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/corbinallison
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7f54cd1846b21d565bb16b65eb8d09be029245d4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file crewai_paysafe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: crewai_paysafe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13ab6f630fa7973692c61b472668b5581acda5a0b5727a4ac94090777165a03e
|
|
| MD5 |
90dedfbf147464c6ccff87413beee2ff
|
|
| BLAKE2b-256 |
c91882db35aed0ddcf2022a7e7ff9dba44ae00e181fa879d1d7eaaa7877efcf3
|
Provenance
The following attestation bundles were made for crewai_paysafe-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on corbinallison/paysafe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crewai_paysafe-0.1.0-py3-none-any.whl -
Subject digest:
13ab6f630fa7973692c61b472668b5581acda5a0b5727a4ac94090777165a03e - Sigstore transparency entry: 2216218032
- Sigstore integration time:
-
Permalink:
corbinallison/paysafe@7f54cd1846b21d565bb16b65eb8d09be029245d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/corbinallison
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7f54cd1846b21d565bb16b65eb8d09be029245d4 -
Trigger Event:
workflow_dispatch
-
Statement type: