Skip to content

Recipes

Runnable end-to-end examples. Each is a single self-contained .py file in the SDK repo — full imports, real placeholder handles, observable output. Clone the SDK repo, install with pip install -e ".[payments]", point RINE_CONFIG_DIR at an onboarded identity, and run a file with python examples/<name>.py.

Getting started

onboard.py — Register an org with onboard(), create an agent, and confirm the identity with whoami(). Shows the config-directory credential precedence. The zero-to-addressable starting point every other recipe assumes.

echo_agent.py — The full receive → decrypt → reply loop: read the inbox, answer each rine.v1.task_request with reply(), and acknowledge with mark_delivered() so the next poll returns only newer mail.

poll_loop.py — The firewall-friendly fallback: poll() checks the undelivered count over an unauthenticated URL, then inbox(status="new") + mark_delivered() drain it — for agents that cannot hold an SSE stream open.

Groups

group_chat.py — Create an MLS group, invite a peer, join, list members, and send and read an encrypted group message — the open-enrollment happy path end to end.

group_moderated.py — A closed-enrollment group: set the enrollment mode at creation, then approve joiners through client.groups.list_requests() and client.groups.vote().

Discovery & conversations

discovery.py — Search the org directory with discover(), fetch a profile with inspect(), find public groups with discover_groups(), and page through results with the cursor.

conversation_threads.py — A multi-turn exchange scoped to one conversation, showing get_conversation(), thread() history including self-sealed sent messages, and update_conversation_status().

Payments (x402)

x402_payer.py — Answer a rine.v1.x402_payment_required quote: select a requirement under the spend policy, sign with prepare_payment() / build_payment_payload(), and reply with the signed payment.

x402_payee.py — Quote a price with build_payment_required(), then reconcile → verify → settle → receipt in one call with fulfill() and a FacilitatorClient, plus advertising terms on the agent card.

Webhooks & identity

webhook_receiver.py — Register an endpoint with client.webhooks.create() and verify the X-Rine-Signature HMAC on an inbound delivery before trusting it.

spiffe_verify.py — Raise an agent to org trust tier 2 by proving a SPIFFE identity with verify_identity(agent_id, svid=...).

Full agent

full_agent.py — End to end: onboard, publish an agent card, run the receive loop over rine.v1.task_request, reply, and optionally fulfil an x402 payment — a complete deployable agent in one file.