sync
05developer experience

Connect in a few lines.
Transparent to your agent logic.

Two surfaces: a gate middleware for providers, and an HTTP-client wrapper for consumers. The wrapper checks fleet memory, answers the 402, signs the voucher and retries — your code just calls fetch.

01

install

npm install vend-sdk

one package, both sides

02

gate

wrap your endpoint

provider replies 402 with a quote

03

fetch

use VendClient.fetch

it handles 402, vouchers & retries

04

reuse

fleet memory

the swarm reads purchases for free

provider side

Sell a service per call.

vendGate turns any route into a paid endpoint. Unpaid requests get a 402 with your quote; paid requests pass through and emit a PurchaseReceipt. You set both the single-call and fleet-license prices.

  • no billing code to write
  • fleet license priced by you
  • stake for reputation & ranking
  • disputes settle on-chain
provider.ts
import { vendGate } from 'vend-sdk';

// close an endpoint with a price — that's the whole integration
app.use('/inference', vendGate({
  price: '0.0004',        // single call
  fleetPrice: '0.0012',   // license for the owner's whole fleet
  token: 'USDC',
  recipient: providerPda,
  ttl: 3600,              // how long a result may be reused
}));
← 402 response
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "price": "0.0004",
  "fleet_price": "0.0012",
  "token": "USDC",
  "recipient": "prov_7f2...a91",
  "channel_id": "ch_18b2",
  "nonce": 1882,
  "expiry": 3600
}
agent.ts
import { VendClient } from 'vend-sdk';

const vend = new VendClient({
  wallet,
  fleet: fleetPda,   // shared memory — checked before any payment
  budget: '5.00',    // daily spend guardrail
});

// fleet cache hit → 0 cost; otherwise buy + record into memory
const res = await vend.fetch('https://provider.ai/inference', {
  method: 'POST',
  body: JSON.stringify({ prompt }),
});
consumer side

Just call fetch.

VendClient wraps your HTTP client. It checks fleet memory first (a cache hit costs nothing), then handles the 402 — signing a voucher against your channel, retrying with proof, and recording fleet-licensed results back into shared memory. A daily budget caps spend.

cache hit
$0.00
single call
$0.0004
fleet license
$0.0012

phase 1 · devnet

An agent buys inference from another agent — end to end.