caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

394 lines
27 KiB
Markdown

# apps/vend — white-label AI SDK (Relay inference + Mint wallet + reseller control plane)
> A new **product / control-plane app**: "Stripe-meets-OpenRouter." A founder drops
> in one SDK and gets, in an afternoon, a resellable, metered, white-label AI stack:
> an OpenAI-compatible inference endpoint, a **reserve-backed wallet** their own
> customers top up, per-seat metering with **their** markup, provider failover, and
> dunning — with **zero new money infrastructure to build.**
>
> Vend is **~80% assembly, not a from-zero build.** Inference is **Relay**
> (`apps/relay`), white-labeled and multi-tenant. Wallet + settlement is **Mint**
> (`apps/mint` + [AITP-402](../mint/AITP-402-SPEC.md)): every metered charge is a
> `hold → capture-on-success`, every top-up a reserve-gated `mint`, every movement a
> hash-linked receipt. The **net-new** layer is tenancy: a reseller control plane
> (tenants → apps → sub-keys), a dunning state machine, per-tenant reserve
> segregation, and the drop-in SDK DX.
>
> Product family: **ReelForge** (video, demand) · **Relay** (inference gateway) ·
> **Mint** (AIT settlement + AITP-402) · **Vend** (this — white-label reseller SDK).
> App dir `apps/vend`; inference unit is Relay's µ$ cost; money unit is Mint's
> **AIT** (1 AIT = 1 USD = 1,000,000 µ$). Strategic prize: **every Vend tenant
> becomes an AITP-402 distribution channel.**
---
## 1. The core idea
- **Vend = Relay + Mint + a reseller control plane, packaged as an SDK.** The three
hard things a founder refuses to build — a **gateway**, **metered/marked-up
billing**, and **dunning + failover** — already exist as shipping infra. Vend
multi-tenants them and wraps them in a drop-in SDK plus a hosted top-up page.
- **The durable asset is the metered wallet + reserve ledger under thousands of
apps**, not any single gateway. Gateways commoditize; the **ledger-of-record for
spend** does not. Once a tenant's customers hold prepaid AIT balances in Vend and
the tenant's finance reconciles against Mint **receipts + reserve proof**, ripping
Vend out is a billing migration — the single most-avoided engineering project.
- **A tenant is a first-class reseller.** Each tenant sets **their own** markup
(`MarkupPolicy.markup_bps`) over base provider cost; Vend takes a thin platform
slice of the resulting margin. Both the tenant's take and the platform's take are
**double-entry `transfer` ops on Mint**, not spreadsheet math — auditable and
reserve-conserving by construction.
- **Everything settles on Mint via AITP-402.** A metered inference call is a `402`
challenge (price for this call) → signed authorization → `hold` → serve →
`capture` exact cost + markup on success / `release` on failure. Streaming meters
via `stream.tick`; per-seat budgets are `allowance.grant`/`spend`. **Success-only
(ADR-0002)** is native, **integer-µ$ (ADR-0001)** is inherited — "never charge on
a 500" and "no floats" are free.
- **Every tenant is a distribution channel for the rail.** The product founders
actually want (a resellable metered SDK) **is** the onboarding funnel for
AITP-402. Adoption of the payment standard comes bundled, not sold.
**Why it's a wedge, not a gateway play:** OpenRouter/Portkey own the gateway, but
neither ships a **white-label, reserve-backed wallet a tenant's customers top up
under the tenant's brand.** That gap is the wedge; Vend's job is distribution —
convert every "AI-for-X" SaaS into a settlement endpoint on Mint.
---
## 2. Where it sits (composes three planes it does not own)
Today the money + inference surfaces live in three places that already ship:
- `apps/relay` — OpenAI-compatible inference gateway (routing, BYOK, markup, Cost API).
- `apps/mint` — canonical AIT ledger, holds/streams/allowances, reserve, AITP-402.
- `apps/api` (ReelForge `gateway` + `wallet`) — the reseller/provisioning-key +
µ$-ledger patterns that prove the shape end-to-end.
**Vend is the multi-tenant control plane that composes them.** It owns *no* new
money math and *no* new inference dialect — it owns **tenancy, provisioning,
markup routing, dunning, and DX.** Each downstream plane becomes a Vend client:
```
┌──────────────────────────────────────────┐
Tenant app end-users ──┤ VEND SDK (thin, multi-language) │
(via tenant + sub-key) └─────────────────┬────────────────────────┘
▼
┌───────────────────────────────────────────────────────────────────────┐
│ VEND CONTROL PLANE (net-new: tenants→apps→sub-keys, markup, dunning) │
│ resolve tenant/app/sub-key · price call · pick policy · route │
└───────┬───────────────────────────────┬───────────────────────────────┘
│ inference (white-labeled) │ money (wallet + settlement)
▼ ▼
┌────────────────────────┐ ┌─────────────────────────────────────────┐
│ RELAY (apps/relay) │ │ MINT (apps/mint + AITP-402) │
│ OpenAI-compat surface │ │ hold.create/capture/release │
│ provider manifests │◄─────│ stream.tick (streaming meter) │
│ routing + failover │ cost │ allowance.grant/spend (per-seat) │
│ BYOK, Cost API │ │ transfer(margin→tenant treasury) │
│ per-key spend/rate │ │ mint (reserve-gated top-up) │
└────────────────────────┘ │ reserve: Σbal+Σholds==reserve/tenant │
│ hash-linked RECEIPT per op · /audit │
└─────────────────────────────────────────┘
│ balance low
▼
Hosted white-label TOP-UP PAGE (tenant brand)
```
- **Inference plane = Relay, white-labeled + multi-tenant.** Vend exposes Relay's
`/api/v1/chat/completions` (+ completions/embeddings, SSE, tools, structured
outputs, multimodal) per-tenant. Routing (`provider.order`, `allow_fallbacks`,
`sort`, `:nitro`/`:floor`), BYOK-with-fee, and the Cost API (`/generation?id=`,
the exact per-request spend Vend meters) are Relay's — consumed, not reimplemented.
- **Money plane = Mint, per-tenant.** Balances are Mint accounts; top-ups are
reserve-gated `mint` ops; metered charges are `hold → capture`; per-seat budgets
are `allowance`; margin/platform take are `transfer`s; audit/solvency are Mint
`GET /v1/receipts/audit` + `GET /v1/reserve`.
- **Reseller patterns = ReelForge lineage.** `domains/gateway/provisioning.py`
(`ProvisioningKey` daily-cap `check_spend`/`remaining`, `MarkupPolicy.apply_markup`
with `markup_bps`+`min_fee_micros`) and `domains/wallet/policy.py` (versioned fee
schedule, top-up bounds — already **config-not-const**) are the proven templates
Vend multi-tenants.
**Language/isolation boundary (inherited discipline):** Vend is its own service.
It talks to Relay and Mint over **HTTP + AITP-402**, never a shared in-process lib —
same rule Mint and Relay already follow (no code shared across the Python/Rust
boundary; only the money math ADR-0001 and Neon/Cloudflare infra are common).
Standalone workspace, **excluded from the root Cargo workspace** so it never
triggers the `apps/desktop` GPUI/Metal build. Inherits **ADR-0001** and **ADR-0002**.
---
## 3. Primitives
The **net-new** primitives are tenancy, sub-keys, metered-usage attribution,
reserve-backed per-tenant balances, and the dunning state machine. Each **maps
onto** a Relay or Mint primitive rather than reinventing it.
| Primitive | What it does | Backed by (Relay/Mint) | Net-new? |
|---|---|---|---|
| **Tenant** | The reseller (an AI-SaaS customer). Owns a `MarkupPolicy` (their take-rate), a model allowlist, data-logging/ZDR defaults, a **treasury account**, and a **segregated reserve slice**. Root of all scoping. | Mint account (`type=org`/`treasury`); Relay org/RBAC | **Yes** |
| **App** | A product/environment under a tenant. Owns default caps, brand config for the top-up page, and its own key namespace. | — (control-plane row) | **Yes** |
| **Sub-key** (`tenant → app → end-user`) | Scoped provisioning key. Secret returned once (hash-resolved), with per-key daily cap, rate limit, allowed models, ZDR flag. The unit end-user apps call with. | Relay `relay-keys` (argon2 hash, scopes, spend/rate) + ReelForge `ProvisioningKey` cap engine, **multi-tenanted** | **Yes** (tenant scoping) |
| **Metered-usage** | Exact per-request cost captured from Relay's Cost API, attributed `tenant/app/sub-key/end-user`, marked up per policy, rolled up per tenant. Success-only. | Relay Cost API (`/generation?id=`) → Mint `hold.capture`; ReelForge `MarkupPolicy.apply_markup` | **Yes** (attribution + rollups) |
| **Reserve-backed balance** | Each end-user holds an AIT balance, 1:1 reserve-backed, **segregated per tenant** so one tenant can never draw another's reserve. Display `$`, integer µ$ truth. | Mint account balance + `mint-reserve`; ReelForge `wallet` µ$ ledger | Composed (tenant segregation is **new**) |
| **Dunning state machine** | On low/failed balance: deterministic states `HEALTHY → GRACE → RETRYING → SOFT_LIMIT → HARD_LIMIT → RECOVERED`, with retry schedule, notifications, and soft/hard caps. Never double-charges, never charges-on-failure. | Stripe webhooks (ReelForge `wallet/webhooks.py`) + Mint `mint`/`allowance` gating | **Yes** |
| **Auto top-up** | When balance < threshold, trigger a reserve-gated `mint`; multiple payment methods tried in order on failure (feeds dunning). | Relay Auto-Top-Up pattern; Mint `mint` | Composed |
| **Markup / take-rate** | Tenant markup over base cost + platform slice of margin. Both are ledger moves, not config drift. | ReelForge `MarkupPolicy`; Mint `transfer` to tenant + platform treasuries | Composed |
| **AITP-402 channel** | Every metered call is an AITP-402 op; every tenant therefore exposes AITP-402-payable inference to its users **and their agents**. | Mint `mint-protocol` (AITP-402) | Composed (distribution is **new**) |
Every money movement stays **double-entry + append-only** on Mint. Vend's
control-plane rows (tenant/app/sub-key/dunning-state) are authoritative for
*policy*; Mint's log is authoritative for *money*.
---
## 4. API surface
Two faces: a **tenant-facing management/control API** (net-new) and a **data-plane
inference surface** (Relay's, exposed per-tenant). Money endpoints are thin proxies
to Mint.
**Tenant & app management (control plane, net-new)**
- `POST /v1/tenants` · `GET /v1/tenants/:id` · `PATCH /v1/tenants/:id`
(markup policy, model allowlist, ZDR defaults, brand)
- `POST /v1/tenants/:id/apps` · `GET /v1/apps/:id` · `PATCH /v1/apps/:id`
- `GET /v1/tenants/:id/usage` · `GET /v1/tenants/:id/reserve` (per-tenant solvency)
**Provisioning keys (sub-keys, net-new scoping over Relay/ReelForge)**
- `POST /v1/apps/:id/keys` → secret **returned once** · `GET /v1/keys/:id`
- `POST /v1/keys/:id/quote` (price a call under this key's policy)
- `POST /v1/keys/:id/revoke` · `PATCH /v1/keys/:id` (cap, rate, models, ZDR)
**Inference data plane (Relay surface, white-labeled per tenant)**
- `POST /api/v1/chat/completions` (+ `/completions`, `/embeddings`) — SSE, tools,
`json_schema`, multimodal; `provider` routing object; model suffixes
- `GET /api/v1/models` (per-tenant allowlist) · `GET /api/v1/generation?id=` (Cost API)
**Wallet & top-up (proxies to Mint; brand from App)**
- `POST /v1/wallets/:end_user/top-up` → reserve-gated Mint `mint`
- `GET /v1/wallets/:end_user/balance` · `GET /v1/wallets/:end_user/receipts`
- `POST /v1/wallets/:end_user/auto-top-up` (threshold + method order)
- Hosted white-label page: `GET /pay/:app_slug` (tenant-branded top-up UI)
**Dunning (net-new)**
- `GET /v1/wallets/:end_user/dunning` (current state + schedule)
- Stripe webhook sink → drives the dunning state machine (payment failed/recovered)
**Settlement (AITP-402, delegated to Mint)**
- Metered endpoints reply `402 Payment Required` + `AITP-Challenge`; SDK responds
`AITP-Authorization`; Vend verifies via Mint `POST /v1/aitp/verify`, opens a
`hold`, serves, `capture`s on success. Idempotency via AITP `nonce` +
`idempotency_key`.
SDKs generated multi-language (TypeScript first, then Python/Go) mirroring OpenAI
ergonomics so `npm i` → first metered call is a one-liner.
---
## 5. Services / crates (`apps/vend/*`) — explicit reuse vs net-new
Vend's own workspace is deliberately **thin**: it is a control plane + SDK, not a
re-implementation. Each unit is tagged **[Mint client]**, **[Relay client]**, or
**[NET-NEW]**.
| Service / crate | Role | Provenance |
|---|---|---|
| `vend-server` (bin) | axum HTTP: control-plane routes + data-plane proxy; tower middleware (tenant resolution, auth, metering) | **[NET-NEW]** |
| `vend-core` | domain types: `Tenant`, `App`, `SubKey`, `UsageRecord`, µ$ amount re-export, error model | **[NET-NEW]** (money math from ADR-0001) |
| `vend-tenancy` | tenant/app CRUD, per-tenant `MarkupPolicy`, model allowlist, ZDR/data-logging defaults, brand config | **[NET-NEW]** (ports ReelForge `MarkupPolicy`) |
| `vend-keys` | sub-key mint (secret-once, hash-resolve), `tenant→app→end-user` scoping, daily cap/rate/model gates | **[Relay client]** over `relay-keys` + ReelForge `ProvisioningKey` — **scoping is NET-NEW** |
| `vend-inference` | white-label proxy to Relay: forwards OpenAI-compat calls, injects per-tenant routing/allowlist, pulls exact cost from Relay Cost API | **[Relay client]** (owns no dialect/routing code) |
| `vend-metering` | attribute exact cost `tenant/app/sub-key/end-user`, apply markup, emit per-tenant rollups, drive `hold.capture` | **[NET-NEW]** attribution over **[Mint client]** capture |
| `vend-wallet` | balances, top-up, auto-top-up threshold, receipts view — all proxied to Mint accounts + `mint` | **[Mint client]** (reuses ReelForge `wallet/policy.py` fee-schedule semantics) |
| `vend-dunning` | the dunning **state machine**: retry schedule, notifications, soft/hard limits; consumes Stripe webhooks; never double-charges | **[NET-NEW]** |
| `vend-reserve` | per-tenant **reserve segregation** + solvency view; enforces one tenant can't draw another's slice; wraps Mint reserve | **[NET-NEW]** guard over **[Mint client]** `mint-reserve` |
| `vend-settlement` | AITP-402 challenge/authorize/verify glue; opens holds, captures, records receipts — all via Mint `mint-protocol` | **[Mint client]** |
| `vend-billing-router` | maps a captured charge into the four moves (provider cost, tenant markup→tenant treasury, platform take→platform treasury) as Mint `transfer`s | **[NET-NEW]** orchestration over **[Mint client]** transfers |
| `vend-onboarding` | self-serve tenant signup, quickstart provisioning, hosted top-up page backend, brand config | **[NET-NEW]** |
| `vend-sdk` | thin multi-language client (TS → Python/Go): OpenAI-ergonomic call + wallet/top-up helpers + AITP-402 retry handling. **The DX moat.** | **[NET-NEW]** |
| `vend-store` | `sqlx` Postgres (Neon): control-plane rows (tenants/apps/keys/dunning-state/rollups) only — **no money ledger** (that's Mint) | **[NET-NEW]** |
| `vend-telemetry` | `tracing` → OpenTelemetry; per-tenant usage/latency dashboards | **[NET-NEW]** (thin) |
| `vend-testkit` | fake Relay + fake Mint transports, per-tenant isolation property harness, dunning-state simulator | **[NET-NEW]** |
**Stack:** tokio · axum · tower · reqwest (to Relay + Mint) · sqlx(Postgres/Neon) ·
serde · figment · tracing/opentelemetry. Injectable Relay-client and Mint-client
seams (fake in tests, real in prod). **No ledger, no receipts, no dialect code
lives in Vend** — those are Mint's and Relay's respectively.
---
## 6. Invariants (property-tested, non-negotiable)
Money invariants are **inherited from Mint** and re-asserted at the tenant
boundary; the net-new invariants are about **tenancy isolation** and **dunning
determinism**.
1. **Per-tenant reserve segregation:** for every tenant, `Σ balances(tenant) +
Σ active holds(tenant) == reserve_slice(tenant)`; no op can draw another
tenant's slice. (Extends Mint conservation to the tenant boundary.)
2. **No cross-tenant leak:** a sub-key scoped to tenant A can never resolve, meter,
charge, or read balances/receipts of tenant B. (Property-tested.)
3. **Success-only (ADR-0002):** hold on start, capture on success, release on any
failure/failover — an end-user never pays for a 500 or a failover.
4. **Integer-µ$ (ADR-0001):** all amounts `amount_micros` end-to-end; the top-up
page's `$` is display-only; no float, no rounding drift.
5. **Idempotency/replay-safe:** AITP `nonce` (single-use) + `idempotency_key` make
SDK retries no-ops returning the original receipt.
6. **Dunning determinism + no double-charge:** the dunning state machine is a pure
function of (state, event, clock); a failed recharge never captures, never
double-charges, and always converges to a terminal state.
7. **Markup conservation:** for each capture, `end_user_paid == provider_cost +
tenant_margin`; `tenant_margin == tenant_take + platform_take`; all four are
double-entry Mint moves that sum to zero.
8. **Policy/money separation:** Vend rows are authoritative for policy; Mint's log
is authoritative for money — the two never disagree after reconciliation.
These become the acceptance gates (§7) and a continuous property/chaos suite in
`vend-testkit`, with fake Relay/Mint transports for determinism.
---
## 7. Phased build (Vx0 → Vx5, with acceptance gates)
Each gate is a hard go/no-go. Because money math and inference dialects are
inherited (ADR-0001/0002, Relay, Mint), gates focus on **tenancy, attribution,
dunning, and settlement wiring** — not on re-proving money or routing.
- **Vx0 — Multi-tenant spike (internal).**
Stand up `vend-core` + `vend-tenancy` + `vend-keys` + `vend-store`; a `Tenant`
boundary over Relay keys + Mint accounts; scope sub-keys `tenant→app→end-user`;
per-tenant `MarkupPolicy` + daily cap. Mock inference + mock capture.
**Gate:** two isolated tenants mint sub-keys, meter a mock charge with **distinct
markups**, and their usage/balances **never cross**; per-tenant reserve
segregation property test green (invariants §6.1, §6.2).
- **Vx1 — Real metered request through all three planes.**
Wire `vend-inference` → Relay (one real provider) and `vend-settlement` →
AITP-402 `hold` → `capture` on success / `release` on failure → Mint receipt;
`vend-metering` attributes exact Relay cost + tenant markup.
**Gate:** a live `chat/completions` call is priced, held, served, **captured at
exact Relay cost + tenant markup**, and yields a valid hash-linked Mint receipt; a
**forced provider failure bills the end-user nothing** (ADR-0002 verified
end-to-end, invariant §6.3).
- **Vx2 — Hosted top-up page + Stripe + dunning.**
`vend-wallet` + `vend-onboarding` hosted white-label page → reserve-gated Mint
`mint` on confirmed deposit; auto-top-up threshold; `vend-dunning` state machine
(retry failed cards, notify, soft/hard limit) off Stripe webhooks.
**Gate:** an end-user tops up **under the tenant's brand**, balance updates
µ$-exact, per-tenant reserve conservation holds, and a **failed recharge runs the
full dunning sequence** to a terminal state **without double-charging or
charging-on-failure** (invariants §6.4, §6.6).
- **Vx3 — SDK + self-serve onboarding + failover/routing.**
Ship `vend-sdk` (TypeScript first) with OpenAI-ergonomic calls + wallet/top-up
helpers + AITP-402 retry handling; self-serve tenant signup; per-tenant provider
routing (`allow_fallbacks`/`sort`), model allowlist, ZDR flags via Relay.
**Gate:** a **brand-new developer goes from signup to a metered, marked-up,
successfully-billed request in under one afternoon** with no manual setup;
provider failover reroutes transparently with **no erroneous charge**.
- **Vx4 — Platform take + billing-router + solvency proof.**
Turn on `vend-billing-router`: each capture fans into four Mint `transfer`s
(provider cost, tenant take→tenant treasury, platform take→platform treasury);
`vend-reserve` exposes per-tenant receipts export + `GET /v1/tenants/:id/reserve`.
**Gate:** platform take accrues to platform treasury as **auditable ledger
entries**, each tenant can export a **verifiable receipt log + reserve proof**,
and `end_user_paid == provider_cost + tenant_take + platform_take` for every
capture (invariant §6.7).
- **Vx5 — Design-partner GA + AITP-402 distribution.**
Onboard first paying design partners; harden multi-language SDK (Python/Go);
expose **AITP-402-payable inference per tenant** so a tenant's users **and their
agents** can pay per call; wire the network loop (agent funded in one Vend-app's
wallet pays any AITP-402 resource).
**Gate:** ≥3 paying tenants live; ≥1 design partner has **deleted their old
proxy**; ≥1 tenant's **agent completes an AITP-402-paid call** with no pre-funded
session; chaos suite green on all §6 invariants at multi-tenant scale.
> Build harness: own multi-agent workflow chain (Vx0 → Vx5), TDD, same
> recon → design → build → review → fix shape as the ReelForge waves, Relay RP0, and
> Mint AP0. Greenfield and disjoint from running workflows — safe to launch in
> parallel; sequences **after** Relay RP3 (billing) and Mint AP3 (AITP-402 +
> allowances) exist to consume.
---
## 8. Product surfaces it unlocks
- **Resellable AI SDK in an afternoon** — `npm i` → OpenAI-compatible endpoint +
reserve-backed wallet + dunning + failover, all white-labeled. The wedge.
- **Per-seat metered billing with your markup** — vertical apps meter each end-user
and mark up token cost per seat (Mint `allowance` + `MarkupPolicy`), something raw
OpenAI billing can't do.
- **Hosted white-label top-up page** — a tenant's own users buy AIT credit under the
tenant's brand; "powered by Vend" optional (a discovery growth loop).
- **Dunning + failover for free** — retry failed cards, soft/hard-limit gracefully,
reroute around provider 500s — the billing plumbing founders refuse to build.
- **Verifiable spend + solvency proof per tenant** — exportable, hash-linked Mint
receipts + `GET /reserve` proof, keyed to the tenant's finance/reconciliation —
the switching-cost anchor.
- **Compounding take-rate** — as a tenant's users grow, spend grows, Vend's platform
slice grows, **with no new sales** (target NRR > 120%).
- **Agent-ready billing** — because every call is an AITP-402 op, a tenant's users
*and their autonomous agents* can pay per call with no pre-funded session.
---
## 9. Every tenant becomes an AITP-402 distribution channel
This is the strategic core, not a side effect. The product founders want (a
resellable metered SDK) **is** the onboarding funnel for the payment rail.
- **Adoption comes bundled.** A founder installs Vend for the SDK/wallet/dunning
value. In doing so, every metered call in their app becomes an **AITP-402 op on
Mint** — the app is now a settlement endpoint on the rail without the founder
"adopting a standard." Distribution of AITP-402 rides the product's own value prop.
- **Two-sided rail per tenant.** Each tenant brings **demand** (its end-users +
agents spending on metered inference) and, via Relay's creator/provider payout
addresses, **supply** (providers/models paid through the same receipts). More
AITP-402 endpoints → an agent funded in one Vend-app's wallet can pay **any**
AITP-402 resource via cross-app `allowance`/`transfer`.
- **The ledger is the moat, the gateway is the funnel.** Gateway revenue caps at "a
% of inference we proxy." The durable value is **being the reserve-backed ledger
under the agent economy** — Mint + AITP-402 — with Vend as the wedge that installs
that rail under thousands of apps. Every tenant onboarded is one more app (and its
agents) transacting on the rail; the reserve/receipt layer compounds in value with
each one, and running a parallel ledger gets costlier the more that settles here.
- **Leading indicator.** The north-star metric is **reserve-backed AIT spend settled
through Vend per month** (gateway usage + top-ups + take-rate in one number);
the network-effect indicator is **# of AITP-402 endpoints seeded** (apps + agents
transacting on the rail). Vend is the fastest, cheapest way to grow both, because
each customer-turned-distribution-channel arrives via a product they already want.
---
## 10. Compliance & safety (design-in, not bolt-on)
- **Closed-loop, fiat-backed, 1:1 redeemable** — AIT is a prepaid credit, not a
security or cryptocurrency (Mint §9). Vend never changes this posture; it inherits
Mint's KYC/AML thresholds on `mint`/`redeem` and sanctions screening on payouts.
- **Per-tenant reserve segregation is a ship-blocker** — one tenant's bug or fraud
must never drain a shared reserve. Invariants §6.1/§6.2 + property tests gate
onboarding of any paying tenant (kill-criterion R5 in the vision doc).
- **Money-transmission posture** — holding prepaid balances risks MTL/e-money
exposure; keep strictly closed-loop, region-gate top-ups where a jurisdiction
requires licensing, and continue elsewhere. Custody cost must stay below take-rate
at target scale.
- **Ledger is authoritative** — Vend rows drive policy only; Stripe/Relay/Mint never
bypass Mint's conservation or success-only guarantees. Reconciliation
(policy-vs-money, invariant §6.8) runs continuously.
---
## 11. Summary
Vend productizes infra that already ships — **Relay** (inference), **Mint +
AITP-402** (reserve-backed wallet + settlement), and ReelForge's reseller/wallet
patterns — into a multi-tenant, white-label metered-billing SDK. The **net-new**
build is narrow and sharp: a reseller control plane (tenants → apps → sub-keys), a
dunning state machine, per-tenant reserve segregation, and the drop-in SDK DX. The
wedge is a resellable AI SDK a founder installs in an afternoon; the moat is the
reserve-backed wallet + receipt ledger that becomes their record-of-truth; the
prize is **seeding AITP-402 as the payments rail for the agent economy**, one
AI-SaaS customer-turned-distribution-channel at a time.