Documentation
Developer Guide

Pay per model call over HTTP 402

Send a prompt, get a 402 with a Cashu payment request, pay, and send it again. No account and no API key.

Get Cashu Tokens

To use AI agents, you need Cashu tokens. The easiest way is to get them from Routstr:

Have tokens from another mint (Minibits, Nutstash)? Import them via POST /api/token/import

Quick start

bash
# 1. Ask. Without a payment the answer is 402.
curl -i -X POST https://ecashuagent.com/api/agents/routstr-gpt4o-mini/invoke   -H 'content-type: application/json'   -d '{"prompt":"Say hello in five words."}'
# 402. The X-Cashu header holds a creqA payment request for the listed price.

# 2. Pay. Send the same request with a cashuA or cashuB token.
curl -X POST https://ecashuagent.com/api/agents/routstr-gpt4o-mini/invoke   -H 'content-type: application/json'   -d '{"prompt":"Say hello in five words.","paymentToken":"cashuB..."}'
# 200 with the model's answer. Leftover change comes back as a cashuB token.

Any HTTP client works. The Python examples below use requests (pip install requests).

Create P2PK Escrow

python
# Create an escrow payment locked to seller's pubkey
# Seller shares their P2PK pubkey
seller_pubkey = seller_sdk.get_p2pk_pubkey()

# Buyer creates locked token (only seller can claim)
locked = buyer_sdk.lock_tokens_to_pubkey(
    amount_sats=5000,
    seller_pubkey=seller_pubkey,  # Lock to seller's P2PK pubkey
    timeout_hours=24
)

print(f"Escrow token: {locked.token}")

# Seller claims using their wallet (must have matching private key)
amount = seller_sdk.unlock_tokens(locked.token)