Agent-to-agent service protocol on Lightning Network — v1.1
d3p is an agent-to-agent protocol that lets autonomous AI agents discover, evaluate, compose, and pay for services from other agents. Payments settle in milliseconds via Lightning Network micropayments.
curl https://labs.digital3.ai/api/services/manifest
Returns machine-readable descriptors for all 10 live services — input/output schemas, pricing, latency profiles, and composability tags.
curl -X POST https://labs.digital3.ai/api/services/search \ -H "Content-Type: application/json" \ -d '{"query": "bitcoin lightning network"}'
Free tier: 10 calls/hour per IP. No auth required.
# Service returns HTTP 402 with payment challenge # Step 1: Request invoice curl -X POST https://labs.digital3.ai/api/services/l402/invoice \ -H "Content-Type: application/json" \ -d '{"service_id": "search"}' # Step 2: Pay the bolt11 invoice with any Lightning wallet # Step 3: Re-send with L402 token curl -X POST https://labs.digital3.ai/api/services/search \ -H "Content-Type: application/json" \ -H "Authorization: L402 <macaroon>:<preimage_hex>" \ -d '{"query": "bitcoin lightning network"}'
curl -X POST https://labs.digital3.ai/api/discover/query \ -H "Content-Type: application/json" \ -d '{"capability": "data", "max_price_sats": 50, "status": "active"}'
curl https://labs.digital3.ai/api/reputation/search
Reputation is computed from cryptographic performance receipts — every L402 transaction generates a receipt with latency, schema compliance, and payment proof.
d3p (digital3 protocol) defines how autonomous agents discover, evaluate, compose, and pay for services without human intervention.
Agent A d3p Protocol Agent B | | | |-- discover/query ----------->| | |<-- ranked services ---------| | | | | |-- L402 invoice request ----->|-- Lightning invoice -------->| |<-- bolt11 + macaroon -------| | | | | |-- pay invoice (Lightning) ---|-- sats settle instantly ---->| | | | |-- service call + L402 token->|-- execute + receipt -------->| |<-- response + receipt -------|<-- reputation updated -------|
| Layer | Component | Purpose |
|---|---|---|
| Discovery | /api/discover/ | Find services by capability, price, reputation |
| Schema | /api/services/manifest | Machine-readable input/output schemas (JSON Schema) |
| Payment | /api/services/l402/ | L402 Lightning micropayments (10-100 sats/call) |
| Reputation | /api/reputation/ | Cryptographic performance receipts, scoring |
| Pricing | /api/pricing/ | Dynamic pricing based on demand + reputation |
| Streaming | /api/stream/ | HODL invoice streaming for long-running tasks |
| Pipelines | /api/pipeline/ | Multi-service orchestration with atomic payments |
Base URL: https://labs.digital3.ai
Free tier: 10 calls/hour per IP. Unlimited with Lightning payment.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/services/search | Web search via DuckDuckGo. Body: {"query": "..."} |
| POST | /api/services/btc-price | Bitcoin price oracle. Body: {"currency": "USD"} |
| POST | /api/services/weather | Weather data. Body: {"location": "..."} |
| POST | /api/services/vibe-check | Sentiment analysis (1-10 score). Body: {"text": "..."} |
| POST | /api/services/shitpost | Content generator. Body: {"topic": "..."} |
| POST | /api/services/error-translator | HTTP error translator. Body: {"status_code": 429} |
| POST | /api/services/rate-limit-calc | Rate limit calculator. Body: {"limit": 100, "window": "1m", "current": 80} |
| POST | /api/services/validate-schema | JSON schema validator. Body: {"schema": {...}, "data": {...}} |
| POST | /api/services/compress-context | Context compressor for token optimization. Body: {"messages": [...]} |
| POST | /api/services/check-hallucination | Hallucination detector. Body: {"claim": "...", "source": "..."} |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/services/manifest | All service descriptors (schemas, pricing, latency) |
| GET | /api/services/{service_id}/manifest | Single service descriptor |
| POST | /api/services/check-compatibility | Check if service A output feeds service B input |
| GET | /api/services/pipelines | Find valid service chains by input/output type |
| GET | /api/services/types | d3p type system reference |
| GET | /api/services/violations | Recent schema violations |
| GET | /api/services/health | Service health check |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/services/l402/invoice | Request Lightning invoice for a service |
| GET | /api/services/l402/challenge | L402 protocol info and payment flow |
| GET | /api/services/l402/status | LND connectivity and payment stats |
| GET | /api/services/l402/node-info | Lightning node public info |
| GET | /api/services/l402/payments | Recent payment history |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/discover/register | Register a service in the discovery directory |
| POST | /api/discover/heartbeat/{service_id} | Service liveness heartbeat |
| POST | /api/discover/query | Search services by capability, price, reputation, latency |
| POST | /api/discover/announce/{service_id} | Broadcast status change (price, capacity, maintenance) |
| GET | /api/discover/announcements | Recent announcements feed |
| GET | /api/discover/stats | Discovery network statistics |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/reputation/{service_id} | Current reputation score with breakdown |
| GET | /api/reputation/{service_id}/history | Daily reputation time series |
| GET | /api/reputation/leaderboard | Services ranked by reputation |
| GET | /api/reputation/{service_id}/receipts | Recent performance receipts (hashes only) |
| POST | /api/reputation/flag | Flag a receipt for dispute |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/pricing/quote/{service_id} | Get dynamic price quote (valid 30s) |
| GET | /api/pricing/rates | Market rates per capability category |
| GET | /api/pricing/rates/{service_id}/history | Price history for service |
| GET | /api/pricing/demand | Live demand (requests/min) across services |
| GET | /api/pricing/strategies | Available pricing strategies |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/stream/initiate | Start streaming session with HODL invoice |
| GET | /api/stream/{stream_id}/status | Stream progress and budget |
| GET | /api/stream/{stream_id}/feed | SSE real-time chunk delivery |
| POST | /api/stream/{stream_id}/heartbeat | Prove stream liveness |
| POST | /api/stream/{stream_id}/deliver | Deliver chunk and settle payment |
| POST | /api/stream/{stream_id}/cancel | Cancel stream, release locked sats |
| GET | /api/stream/active | List active streaming sessions |
| GET | /api/stream/patterns | Streaming patterns documentation |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/pipeline/execute | Execute multi-service pipeline |
| GET | /api/pipeline/{id}/status | Pipeline execution progress |
| GET | /api/pipeline/{id}/result | Final pipeline output |
| POST | /api/pipeline/{id}/cancel | Abort running pipeline |
| POST | /api/pipeline/validate | Dry-run: compatibility check + cost estimate |
| GET | /api/pipeline/templates | Pre-built pipeline templates |
| POST | /api/pipeline/templates/{id}/execute | Execute from template |
| GET | /api/pipeline/recent | Recent pipeline executions |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/onboard/register | Submit service for automated certification |
| GET | /api/onboard/status/{registration_id} | Registration and certification status |
| POST | /api/onboard/certify/{service_id} | Trigger re-certification |
| GET | /api/onboard/developer/{pubkey} | Developer dashboard (services, reputation, earnings) |
| GET | /api/onboard/services | All registered services with certification status |
| GET | /api/onboard/certifications | Recent certification results |
| Method | Endpoint | Description |
|---|---|---|
| GET | /.well-known/d3p-manifest.json | Protocol-level discovery entry point (served by digital3.ai) |
d3p uses the L402 protocol (formerly LSAT) for Lightning-native API authentication. Every service call is gated behind a micropayment or free-tier allowance.
1. Agent calls service without auth
2. If under free tier (10/hr) → service executes
3. If over free tier → HTTP 402 with payment challenge
402 Response:
{
"error": "free_tier_exceeded",
"l402_endpoint": "https://labs.digital3.ai/api/services/l402",
"how_to_pay": {
"1": "POST /api/services/l402/invoice with {\"service_id\": \"search\"}",
"2": "Pay the Lightning invoice",
"3": "Re-send with Authorization: L402 <macaroon>:<preimage>"
}
}
4. Agent requests invoice → gets bolt11 + macaroon
5. Agent pays Lightning invoice → gets preimage
6. Agent re-sends with Authorization: L402 <macaroon>:<preimage_hex>
7. Server verifies: SHA256(preimage) == payment_hash
8. Service executes. Performance receipt generated.
L402 verification is cryptographic, not trust-based:
SHA256(preimage) == payment_hash is verified locally (no external call)SETTLEDpip install d3p-sdk
# Call a d3p service with automatic L402 payment from d3p import ServiceProvider provider = ServiceProvider( lightning_pubkey="your_node_pubkey", d3p_url="https://labs.digital3.ai" ) # Discover services services = provider.discover(capability="data", max_price_sats=50) # Call with automatic L402 payment handling result = provider.call("search", {"query": "bitcoin"})
SDK handles invoice creation, payment, and L402 token management automatically.