Skip to content

plagtech/rtp-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spraay-rtp — Python SDK

Robot Task Protocol SDK for Python. Connect any robot to the x402 payment network in minutes.

RTP x402 Spraay PyPI Python License: MIT


What This Is

The Python implementation of the Robot Task Protocol (RTP) — the open standard for AI agents to discover, commission, and pay for physical robot tasks via x402 USDC micropayments.

Built for Raspberry Pi, Arduino bridges, industrial robots, IoT devices, and any Python-capable machine.


Install

pip install spraay-rtp

With Raspberry Pi GPIO support:

pip install spraay-rtp[pi]

With Arduino serial bridge support:

pip install spraay-rtp[serial]

Quick Start

Device Side — Register Your Robot

import asyncio
from rtp import RTPDevice, RTPDeviceConfig, ConnectionConfig, ConnectionType, TaskResult

config = RTPDeviceConfig(
    name="MyRobot-01",
    capabilities=["pick", "place", "scan"],
    price_per_task="0.05",
    payment_address="0xYourWallet",
    api_key="your-spraay-key",
    connection=ConnectionConfig(
        type=ConnectionType.WEBHOOK,
        webhook_url="https://yourserver.com/rtp/task",
        port=3100
    )
)

device = RTPDevice(config)

@device.on_task("pick")
async def handle_pick(params, task):
    await task.progress()
    # your robot code here
    await task.complete(TaskResult(
        success=True,
        output=f"Picked {params.get('item')}"
    ))

async def main():
    await device.register()
    await device.listen()

asyncio.run(main())

Agent Side — Hire a Robot

import asyncio
from rtp import RTPClient

async def main():
    client = RTPClient(wallet="0xYourAgentWallet")

    robots = await client.discover(capability="pick")

    result = await client.hire(
        robots[0],
        task="pick",
        parameters={"item": "SKU-421", "from_location": "bin_A3"}
    )

    print(result["status"])           # COMPLETED
    print(result["result"]["output"]) # Picked SKU-421

asyncio.run(main())

CLI

# Interactive setup wizard
rtp-device init

# Start your device
rtp-device start

# Check status
rtp-device status

Standard Capabilities

Verb Description
move Relocate robot or end effector
pick Grasp or retrieve an object
place Set down or deposit an object
scan Capture sensor data
sort Categorize and route objects
inspect Examine and report
deliver Transport from origin to destination
patrol Monitor an area over time
charge Return to charging cycle
capture Record video, audio, or image
transmit Send data to external endpoint
weld Perform welding operation
assemble Combine components
dispense Release measured quantity
print Output physical object or document

Custom capabilities via reverse-domain notation:

capabilities=["pick", "place", "com.acmerobotics.palletize"]

Connection Types

Type Description Best For
webhook HTTPS POST to your server Any internet-connected robot
xmtp Encrypted wallet messaging No open ports needed
wifi HTTP via local relay LAN robots
websocket Persistent WS connection Real-time control

Task Lifecycle

Agent pays (x402 USDC)
       ↓
Spraay validates + holds escrow
       ↓
Task envelope → your robot
       ↓
task.progress()    # optional
       ↓
[your robot code runs]
       ↓
task.complete()    # releases escrow to you
  or
task.fail()        # returns payment to agent

Examples

Raspberry Pi Servo Robot

pip install spraay-rtp[pi]
cp .env.example .env
# fill in .env
python examples/pi_servo_robot.py

See examples/pi_servo_robot.py


Arduino Serial Bridge

pip install spraay-rtp[serial]
python examples/arduino_bridge.py

Pattern:

Spraay Gateway ←WiFi→ Raspberry Pi (SDK) ←USB/Serial→ Arduino

See examples/arduino_bridge.py


Agent Test Script

python examples/agent_test.py

See examples/agent_test.py


Environment Variables

WALLET_ADDRESS=0xYourWalletAddress
SPRAAY_API_KEY=your-spraay-api-key
WEBHOOK_SECRET=any-random-secret-string
PUBLIC_IP=https://your-public-url.com

# Arduino bridge (optional)
SERIAL_PORT=/dev/ttyUSB0
BAUD_RATE=9600

Hardware Compatibility

Device SDK Direct Method
Raspberry Pi pip install
Any Linux machine pip install
Arduino / ESP32 ⚠️ Bridge Serial via Pi
Industrial robots ⚠️ Server Vendor API
Windows machines pip install

Full compatibility guide: device-compatibility.md


Project Structure

rtp-python-sdk/
├── rtp/
│   ├── __init__.py       — exports
│   ├── types.py          — dataclasses + enums
│   ├── device.py         — RTPDevice + TaskContext
│   ├── client.py         — RTPClient
│   └── cli.py            — rtp-device CLI
├── examples/
│   ├── pi_servo_robot.py — Raspberry Pi GPIO demo
│   ├── agent_test.py     — agent-side test client
│   └── arduino_bridge.py — Arduino serial bridge
├── setup.py
├── requirements.txt
└── .env.example

Publishing to PyPI

pip install build twine
python -m build
twine upload dist/*

Package name: spraay-rtp Import name: rtp


Related Repos

Repo Description
rtp-spec RTP 1.0 open standard
rtp-sdk TypeScript SDK
rtp-pi-demo Pi hardware demo
rtp-xmtp-mesh XMTP robot mesh
awesome-rtp Compatible devices list

License

MIT — build anything with it.


Built by Spraay Protocol · Part of the Robot Task Protocol ecosystem

About

Robot Task Protocol Python SDK — Raspberry Pi, Arduino, and industrial robot support

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages