beeai-spraay-tool
The first payment tool for BeeAI Framework agents. With it, agents can validate, estimate and prepare USDC batch payments on Base through the Spraay Protocol x402 gateway. One transaction can pay up to 200 recipients.
SpraayBatchPaymentTool is a subclass of BeeAI's Tool, so you can pass it to any BeeAI agent like a built-in tool.
Non-custodial by design: the tool never handles private keys and never signs or broadcasts anything. execute_batch returns unsigned transactions, and the sender signs them with their own wallet.
Install
pip install beeai-spraay-tool
You need Python 3.11–3.13, the same range as beeai-framework.
Quick usage
import asyncio
from beeai_framework.agents.requirement import RequirementAgent
from beeai_framework.backend import ChatModel
from beeai_spraay_tool import SpraayBatchPaymentTool
async def main() -> None:
agent = RequirementAgent(
llm=ChatModel.from_name("ollama:granite4:micro"),
# Give this agent read-only access: it can check and price a batch but not build one.
tools=[SpraayBatchPaymentTool(allowed_actions=["get_prices", "validate_batch", "estimate_batch"])],
)
response = await agent.run(
"Validate and estimate a USDC batch on Base: "
"0x2222222222222222222222222222222222222222 gets 150, "
"0x3333333333333333333333333333333333333333 gets 75.5"
)
print(response.last_message.text)
asyncio.run(main())
You can also call the tool directly:
result = await SpraayBatchPaymentTool().run(
{
"action": "estimate_batch",
"recipients": ["0x2222222222222222222222222222222222222222", "0x3333333333333333333333333333333333333333"],
"amounts": ["150", "75.5"],
}
)
print(result.get_text_content())
See examples/spraay_example.py for a multi-agent flow. In it, an analyst agent validates and estimates the batch, a reviewer agent approves it against a budget, and only then does a deterministic step build the unsigned transaction.
Actions
| Action | Gateway endpoint | What it does |
|---|---|---|
get_prices |
GET /free/prices |
Gets the current token price. |
validate_batch |
POST /free/validate-batch |
Checks recipients and amounts. |
estimate_batch |
GET /free/estimate-batch |
Estimates gas and the protocol fee. |
execute_batch |
POST /api/v1/batch/execute (x402-paid) |
Builds the unsigned batch transaction(s) for sender to sign. |
Every response includes a batch summary with the recipient count, the total, the protocol fee (0.3%) and the total including the fee. The summary also names the chain (Base, chain ID 8453) and the Spraay batch contract, 0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC.
Input rules
- Amounts are human-readable, for example
"1.5"USDC. The tool converts them to raw token units using exact decimal math. Amounts with more than 6 decimal places are rejected. - Addresses must be
0xfollowed by 40 hex characters. - A batch can have at most 200 recipients, and
recipientsandamountsmust have the same length. execute_batchrequiressender.
Configuration
SpraayBatchPaymentTool(
base_url="https://gateway.spraay.app", # Spraay gateway
http_client=None, # optional httpx.AsyncClient, e.g. an x402-enabled one
allowed_actions=None, # restrict actions per agent, e.g. ["get_prices"]
timeout=30, # HTTP timeout in seconds
)
The execute_batch endpoint charges an x402 micropayment. Without an x402-enabled http_client, the tool doesn't fail. Instead it returns status: "payment_required" along with the gateway's payment requirements.
Development
uv sync
uv run pytest
uv run ruff check . && uv run black --check .
uv run python -m build
The tests mock the gateway with httpx.MockTransport and need no network access.
Links
- Spraay docs: https://docs.spraay.app
- BeeAI Framework: https://github.com/i-am-bee/beeai-framework
License
Apache-2.0
Metadata
Release files for beeai-spraay-tool 0.1.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 | |
|---|---|---|---|---|
| beeai_spraay_tool-0.1.0.tar.gz | 13.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beeai_spraay_tool-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.9 kB
Release files / beeai_spraay_tool-0.1.0.tar.gz
| Download URL | beeai_spraay_tool-0.1.0.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
475b466524c97df09907696ed71cbbbbfd41f45fa20ac1815d09c808d31ceb09
|
|
BLAKE2b-256 checksum How to use checksums |
e7dab8b4474525b168395b7c88bdc8870e02766a3f46533113ffe011713d111b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / beeai_spraay_tool-0.1.0-py3-none-any.whl
| Download URL | beeai_spraay_tool-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
403fd4cea5c4d2de0604aa4fb2f246796f4973fdb09997c8ac1cab607b02bb17
|
|
BLAKE2b-256 checksum How to use checksums |
9686c42b965a6a60b6ce5574b4d6c0c93bacc9b0993e86d70149e0c005708cbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for beeai-spraay-tool 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.