JSPM

costillery

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 30
  • Score
    100M100P100Q72537F

Receipt collection SDK for AI agents — auto-capture MPP and x402 payment receipts and challenges

Package Exports

  • costillery
  • costillery/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (costillery) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Costillery

Receipt intelligence for AI agents.

Costillery automatically captures payment receipts from AI agents running on MPP and x402 payment protocols. Every transaction — search queries, API calls, compute requests — gets logged, enriched with service metadata, and organized for expense tracking and commerce analytics.


Install

npm install costillery

Requires Node.js 18+.


Quick Start

import { AgentLedger } from 'costillery';

const ledger = new AgentLedger({
  apiKey: 'al_live_your_api_key_here',
  projectTag: 'research-q1',
  departmentTag: 'engineering',
});

// Wrap global fetch — every MPP/x402 response is auto-captured
globalThis.fetch = ledger.wrapFetch(globalThis.fetch);

// Or use with axios (x402 ecosystem)
import { wrapAxios } from 'costillery';
const ledger = wrapAxios(axios.create(), {
  apiKey: 'al_live_your_api_key_here',
});

// Manual submission
await ledger.submitReceipt({
  receipt_raw: 'base64_encoded_payment_receipt',
  service_url: 'https://api.some-service.com/search',
  protocol: 'mpp',
});

Configuration

new AgentLedger({
  apiKey: string;                    // Required. Your Costillery API key.
  endpoint?: string;                  // Default: 'https://api.costillery.com'
  projectTag?: string;               // Optional project label for all receipts
  departmentTag?: string;            // Optional department label
  batchSize?: number;                // Flush after N receipts. Default: 10
  batchIntervalMs?: number;           // Flush interval. Default: 5000ms
  maxQueueSize?: number;             // Max receipts in memory. Default: 1000
  debug?: boolean;                   // Log submissions. Default: false
});

How It Works

1. wrapFetch (MPP Protocol)

When you wrap globalThis.fetch, every HTTP response is intercepted:

  • If the response has a Payment-Receipt header → receipt is extracted and submitted to Costillery
  • The header contains the actual amount paid, currency, settlement rail, and transaction reference

2. wrapFetch (x402 Protocol)

x402 payments use a challenge/response flow:

  1. Agent makes a request → server returns 402 Payment Required with a WWW-Authenticate: Payment header
  2. Costillery captures the challenge (which contains the requested amount — critical for x402 where the receipt has no amount)
  3. Agent pays on-chain
  4. Server returns 200 OK with a Payment-Response header (the receipt)
  5. Costillery attaches the captured challenge to the receipt and submits both

3. Manual Submission

For custom integrations:

await ledger.submitReceipt({
  receipt_raw: 'base64_encoded_receipt',    // From Payment-Receipt or Payment-Response header
  challenge_raw: 'base64_encoded_challenge',  // From WWW-Authenticate header (x402)
  service_url: 'https://api.service.com/',
  protocol: 'mpp',                           // 'mpp', 'x402', or 'manual'
  metadata: { project: 'q1-research', department: 'eng' }
});

Receipt Enrichment

Every receipt is enriched with:

Field Description
service_name e.g. "Parallel", "OpenAI"
service_category e.g. ["search", "ai"]
settlement_rail crypto_tempo, fiat_stripe, crypto_base, etc.
amount_usd Normalized to USD
protocol mpp, x402, or manual

The service directory syncs hourly from mpp.dev and maps real API URLs (e.g. api.openai.com) to service names, so receipts submitted with production URLs get matched correctly.


Dashboard

Track your agent spend at app.costillery.com.

Or query the API directly:

# Get spend summary
curl https://api.costillery.com/v1/dashboard/summary \
  -H "Authorization: Bearer al_live_your_key"

# Export as CSV
curl "https://api.costillery.com/v1/export?format=csv&from=2026-03-01" \
  -H "Authorization: Bearer al_live_your_key" \
  -o receipts.csv

API Docs

Full API reference: docs.costillery.com


Get an API Key

Sign up at costillery.com — free tier includes 500 receipts/month.


Protocol Support

Protocol Receipt Header Challenge Header
MPP Payment-Receipt N/A
x402 V1 X-Payment-Response WWW-Authenticate: Payment
x402 V2 Payment-Response WWW-Authenticate: Payment

License

Proprietary — The Skramme Company