Skip to main content

Paybond Kit for Python: agent spend governance for paid tool calls with spend authorization, evidence receipts, refunds, disputes, hosted Gateway sessions, and settlement.

Project description

paybond-kit

Paybond Kit for Python is the PyPI package for tenant-bound Paybond integrations and delegated agent spend controls. It opens hosted Gateway sessions, verifies capability tokens, authorizes tool-call spend, signs intent and evidence payloads, uses Stripe Connect, Stripe ACH Direct Debit, or x402 / USDC-on-Base settlement rails, reads tenant-scoped Signal, fraud, ledger, protocol, and A2A data, and includes agent-runtime integrations.

Paybond is the SDK to use when you do not want to build your own delegated agent spend-governance middleware. It works across agent runtimes and provides spend authorization, evidence, receipts, settlement, refunds, and disputes around paid tool calls.

Install

Core SDK:

pip install paybond-kit

Optional integrations:

pip install "paybond-kit[langgraph]"
pip install "paybond-kit[mcp]"
pip install "paybond-kit[langgraph,mcp]"

Install only the extras your runtime needs. The langgraph extra enables the LangGraph tool wrapper, and mcp enables the paybond-mcp-server CLI. Runtime-neutral guard helpers are included in the core package.

Open source

paybond-kit is distributed as open-source software under the Apache 2.0 license. The source repo and published artifacts include the full license text in LICENSE.

Requirements

  • Python 3.11+
  • A paybond_sk_sandbox_... or paybond_sk_live_... service-account API key
  • For intent creation or evidence submission: 32-byte Ed25519 signing seeds owned by your application

Published wheels bundle the paybond_kit._native extension. maturin develop is only required when building from a local checkout.

Create a sandbox key for local development:

paybond-kit-login

paybond-kit-login writes PAYBOND_API_KEY to .env.local with file mode 0600, refuses to overwrite an existing key unless --force is passed, and refuses env files that are not ignored by git. Live production keys are created by tenant admins in Console and stored in deployment secret managers.

First guardrail scaffold

Use this first when you have a paid tool and want Paybond guardrails in the sandbox:

paybond-kit-init --preset paid-tool-guard --framework provider-agnostic --out paybond_guardrail_demo.py

The generated demo opens Paybond, bootstraps a sandbox guardrail intent, wraps one replaceable paid-tool handler, submits sandbox evidence, and prints the lifecycle result. Free Developer is sandbox-only; live settlement rails start on paid production plans.

Tenant isolation

Every session is bound to the tenant realm echoed by gateway-authenticated service-account introspection.

  • Do not pass tenant ids by hand for normal SDK usage.
  • Construct one Paybond session per tenant/service account.
  • Treat any tenant or intent echo mismatch from Harbor as a severity-zero defect.

Quick start

import asyncio
import os

from paybond_kit import Paybond


def required_env(name: str) -> str:
    value = os.environ.get(name)
    if not value:
        raise RuntimeError(f"missing {name}")
    return value


async def main() -> None:
    paybond = await Paybond.open(
        api_key=required_env("PAYBOND_API_KEY"),
        expected_environment="sandbox",
    )
    try:
        print("tenant realm:", paybond.harbor.tenant_id)
    finally:
        await paybond.aclose()


asyncio.run(main())

Agent spend controls

Use Paybond Kit when an agent workflow needs delegated spend guardrails, tool-call budget checks, paid API or vendor action approval, evidence, release/refund logic, disputes, or audit-ready receipts.

import os

from paybond_kit import Paybond


paybond = await Paybond.open(
    api_key=os.environ["PAYBOND_API_KEY"],
    expected_environment="sandbox",
)

guardrail = await paybond.guardrails.bootstrap_sandbox(
    operation="travel.book_hotel",
    requested_spend_cents=20_000,
    currency="usd",
)

guard = paybond.spend_guard(guardrail.intent_id, guardrail.capability_token)
guarded_tool = guard.guard_tool(
    operation=guardrail.operation,
    requested_spend_cents=guardrail.requested_spend_cents,
    handler=book_hotel,
)

result = await guarded_tool({"hotel_id": "hotel_demo", "max_price_cents": 20_000})
await paybond.guardrails.submit_sandbox_evidence(
    guardrail.intent_id,
    {"result": result, "sandbox": True},
)

The paybond.harbor and paybond.guardrails clients are created by Paybond.open(...) and bound to the tenant resolved from the service-account API key. Production integrations read capability_token from paybond.intents.create(...), or from paybond.intents.fund(...) after an x402_usdc_base payment challenge is satisfied.

Scaffold a guardrail integration:

paybond-kit-init --preset paid-tool-guard --framework provider-agnostic --out paybond_guardrail_demo.py

What the package includes

Core SDK:

  • Paybond.open(...) for API-key-only, tenant-derived hosted sessions
  • HarborClient for capability verification, intent creation, x402 funding, evidence submission, and ledger reads
  • paybond.signal and paybond.fraud on Paybond sessions opened from one service-account API key
  • PaybondIntents helpers for principal-side signing, x402 funding, and payee-side signing flows
  • PaybondSpendGuard, authorize_spend, and guard_tool for spend-named wrappers around capability verification
  • Runtime-neutral and framework aliases: paybond_agent_tool_spend_guard, paybond_runtime_neutral_tool_spend_guard, paybond_langgraph_tool_spend_guard, and paybond_mcp_tool_spend_guard
  • paybond_runtime_tool_call_adapter for agent SDKs and custom runtimes that expose a tool-call object plus an application-owned executor

Gateway and trust helpers:

  • GatewaySignalClient and ServiceAccountSignalSession for tenant-scoped Signal reads and signed portfolio artifacts
  • GatewayFraudClient and ServiceAccountFraudSession for tenant-scoped fraud assessments, review queues, review events, metrics, and release-gate config
  • Protocol-v2 helpers for mandate verification, replay-safe recognition proof verification, receipt reads, and A2A discovery

Optional integrations:

  • Optional extras for agents and langgraph
  • Optional extra for mcp with the tenant-bound paybond-mcp-server CLI
  • paybond-kit-login for sandbox device approval and local .env.local API-key setup
  • paybond-kit-init for generating a Paybond guardrail integration with a sandbox smoke path

Agent-facing surfaces are model-provider agnostic. Paybond verifies tool operations and tenant scope, not whether a tool call came from OpenAI, Anthropic, Gemini, a local model, or another runtime.

allowed_tools values are your own tool or operation names, not a Paybond-owned catalog. Harbor enforces string matching against whatever names you chose when creating the intent.

settlement_rail on intent creation is a principal-signed rail request. Stripe destinations and x402 receive addresses stay tenant-owned server-side config and are never supplied by the SDK caller.

The protocol-v2 surface is trust-first: signed mandates, recognition proofs, and receipts work across supported settlement adapters instead of treating any single rail as the product boundary.

Gateway-backed protocol helpers raise ProtocolHttpError with parsed error_code and error_message fields when the gateway returns a JSON error envelope. Recognition-gated flows surface unregistered_key, revoked_key, mandate_agent_key_mismatch, and protocol_binding_mismatch explicitly.

What it does not include

  • No operator-tier settlement or console workflows
  • No model-provider-specific MCP wrapper; the MCP server is host-agnostic and works with any MCP-compatible runtime

Source build

For local development from this directory:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
maturin develop

Use this path when you are editing the package itself or rebuilding the bundled native extension locally.

Docs

Release verification

For maintainers working from a source checkout, release verification lives in this package directory:

python3 scripts/verify_release.py

This builds wheel and sdist artifacts, inspects them for stray local files, validates metadata/extras, and smoke-installs the built wheel in a temporary virtual environment.

Publish to PyPI

For maintainers only:

export MATURIN_PYPI_TOKEN="pypi-..."
./scripts/publish_release.sh

This reruns release verification and then publishes the sdist and wheel with maturin publish --non-interactive.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paybond_kit-0.9.4.tar.gz (59.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paybond_kit-0.9.4-cp313-cp313-macosx_11_0_arm64.whl (425.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file paybond_kit-0.9.4.tar.gz.

File metadata

  • Download URL: paybond_kit-0.9.4.tar.gz
  • Upload date:
  • Size: 59.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for paybond_kit-0.9.4.tar.gz
Algorithm Hash digest
SHA256 c56766e50c223e6e1aa50dd68caf1fa8bf37aeedb5e169fd15122797926f555e
MD5 27fda627a85646d4c1d2eb74ee643830
BLAKE2b-256 b53f9eb5e9a2cbd97881f684c850cedbb15bcec99e871c96a2401db9fe8b195e

See more details on using hashes here.

File details

Details for the file paybond_kit-0.9.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for paybond_kit-0.9.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23035a060f8b3bf5fe7e0ff2541ab8d76624aa105c80c9924700a76be20540bf
MD5 e52c62e780dabbcfffc52615698613a0
BLAKE2b-256 6ca8d5c75f23f9f14850f0c0c19b8eaadc6cb19a8d7a6804f1d105244fdde6c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page