Skip to main content

💧 haystack-spraay

PyPI License

Spraay x402 Gateway integration for Haystack — multi-chain batch payments, balance checks, RPC calls, and oracle prices for AI agents and pipelines.

What is Spraay?

Spraay is a multi-chain batch payment protocol and x402 gateway that lets AI agents make USDC micropayments across 16+ blockchains. The gateway exposes 76+ paid endpoints covering payments, RPC, oracles, AI inference, storage, and more — all payable via the x402 HTTP payment protocol.

What is Haystack?

Haystack is an open-source AI orchestration framework by deepset for building production-ready LLM applications with modular pipelines and agent workflows.

Installation

pip install haystack-spraay

Quick Start — Agent with Payment Tools

import os
from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack_spraay.tools import spraay_batch_payment, spraay_check_balance, spraay_oracle_price

os.environ["OPENAI_API_KEY"] = "<YOUR_KEY>"

# Create an agent with Spraay payment tools
agent = Agent(
    chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
    tools=[spraay_batch_payment, spraay_check_balance, spraay_oracle_price],
    system_prompt="You are a helpful blockchain payment assistant. You can send payments, check balances, and look up token prices across 16+ blockchains.",
)

# Run it
result = agent.run(
    messages=[ChatMessage.from_user("What's the current price of ETH in USD?")]
)
print(result["last_message"].text)

Quick Start — Pipeline Component

from haystack import Pipeline
from haystack_spraay.components import SpraayBalanceCheck, SpraayBatchPayment

# Use components directly
balance_checker = SpraayBalanceCheck(chain="base")
result = balance_checker.run(address="0xAd62f03C7514bb8c51f1eA70C2b75C37404695c8")
print(result)

# Or in a pipeline
pipeline = Pipeline()
pipeline.add_component("balance", SpraayBalanceCheck(chain="base"))
result = pipeline.run({"balance": {"address": "0x1234...", "token": "USDC"}})

Available Components

Component Description
SpraayBatchPayment Send batch USDC payments to multiple recipients
SpraayBalanceCheck Check token balances on any chain
SpraayGasPrice Get real-time gas prices
SpraayRPCCall Make raw JSON-RPC calls to any chain
SpraayOraclePrice Get real-time token prices

Available Tools (for Agents)

Tool Description
spraay_batch_payment Send multi-recipient payments
spraay_check_balance Query wallet balances
spraay_gas_price Estimate transaction costs
spraay_rpc_call Raw blockchain queries
spraay_oracle_price Token price lookups

Supported Chains

Base, Ethereum, Arbitrum, Polygon, BNB Chain, Avalanche, Solana, Stellar, XRP Ledger, Bitcoin, BOB, Unichain, Plasma, Bittensor, Stacks.

Advanced: Multi-Step Payment Pipeline

from haystack import Pipeline
from haystack_spraay.components import (
    SpraayBalanceCheck,
    SpraayGasPrice,
    SpraayBatchPayment,
)

# Build a payment pipeline: check balance → estimate gas → send payment
pipeline = Pipeline()
pipeline.add_component("balance", SpraayBalanceCheck(chain="base"))
pipeline.add_component("gas", SpraayGasPrice())
pipeline.add_component("payment", SpraayBatchPayment(chain="base"))

# Run steps individually or connect them with custom routing logic
balance_result = pipeline.run(
    {"balance": {"address": "0xSenderAddr", "token": "USDC"}}
)

Advanced: Use with Haystack Agent + Other Tools

from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.tools import ComponentTool
from haystack.components.websearch import SerperDevWebSearch
from haystack_spraay.tools import spraay_batch_payment, spraay_oracle_price

# Combine Spraay tools with web search
search_tool = ComponentTool(
    component=SerperDevWebSearch(api_key=Secret.from_env_var("SERPERDEV_API_KEY")),
    name="web_search",
    description="Search the web for information",
)

agent = Agent(
    chat_generator=OpenAIChatGenerator(model="gpt-4o"),
    tools=[spraay_batch_payment, spraay_oracle_price, search_tool],
    system_prompt=(
        "You are a crypto research assistant that can search the web, "
        "check token prices, and send payments when instructed."
    ),
)

Architecture

┌──────────────┐     ┌───────────────┐     ┌─────────────────┐
│  Haystack    │────▶│  Agent /       │────▶│  Spraay Tools   │
│  Pipeline    │     │  ToolInvoker   │     │  & Components   │
└──────────────┘     └───────────────┘     └────────┬────────┘
                                                     │
                                           ┌─────────▼─────────┐
                                           │  Spraay x402       │
                                           │  Gateway            │
                                           │  gateway.spraay.app │
                                           └─────────┬─────────┘
                                                     │
                                     ┌───────────────┼───────────────┐
                                     │               │               │
                               ┌─────▼───┐    ┌─────▼───┐    ┌─────▼───┐
                               │  Base    │    │  Solana  │    │  15+    │
                               │          │    │          │    │  more   │
                               └─────────┘    └─────────┘    └─────────┘

Contributing

  1. Clone: git clone https://github.com/plagtech/haystack-spraay.git
  2. Install dev deps: pip install -e ".[dev]"
  3. Run tests: pytest tests/ -v

Links

Payment Address

All x402 payments route to: 0xAd62f03C7514bb8c51f1eA70C2b75C37404695c8

License

Apache-2.0

Author

Built by @plagtech | @plag on Farcaster | @Spraay_app

Metadata

Release files for haystack-spraay 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for haystack-spraay 0.1.0
File Size Uploaded
haystack_spraay-0.1.0.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for haystack-spraay 0.1.0
File Interpreter ABI Platform
haystack_spraay-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / haystack_spraay-0.1.0.tar.gz

Download URL haystack_spraay-0.1.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
045423f24f1a0f20d781fda442ad073a650bc8b687de2a88d51f205fea7ede59
BLAKE2b-256 checksum
How to use checksums
5662c70b92cbbfb5f11616383c9fd7952a27b9df77a78464cda6c25bbf4a0ef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / haystack_spraay-0.1.0-py3-none-any.whl

Download URL haystack_spraay-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36fca04bf3ecbcd6be1eab983590e72aa42c6a707c56304a84e26181d86dcc6d
BLAKE2b-256 checksum
How to use checksums
b760e30b19195790c139f5bc3904e84e995b79f95538f57391c5dde54bf889c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page