videogen/docs/apps-vision/turnstile.md
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

24 KiB
Raw Permalink Blame History

Turnstile — the drop-in agent-paywall SDK (Stripe for AI agents)

Status: PLANS ONLY. No code yet. App slug: turnstile · App dir: apps/turnstile · Depends on: Mint (apps/mint, AITP-402) · Relay (apps/relay) · ReelForge (apps/api).

One-liner: Turnstile is the drop-in SDK + reference verifier that makes any HTTP endpoint or MCP tool paid-per-call in under 10 lines — the agent pays with a fiat-backed, gasless, success-only AITP-402 handshake and the money settles on Mint.

Billion-dollar thesis: whoever owns the agent↔service payment handshake owns a toll on every machine-to-machine API call. Turnstile is the developer-led wedge that seeds that two-sided network — funded ait1… agent wallets on one side, paywalled tools/MCP servers on the other — and Mint is the rail they all settle on. Own the handshake, tax the traffic.


1. Problem & thesis

Agents are starting to call tools, APIs, and each other autonomously. There is no clean, default way for a service to charge an agent per call and no clean way for an agent to pay without a human, a pre-negotiated contract, or a crypto wallet full of volatile tokens. Today a developer who wants a paid API/MCP tool must: run Stripe subscriptions (human-checkout shaped, not per-call), issue API keys and reconcile usage out-of-band, or adopt a crypto rail (x402/Coinbase, Skyfire, Payman) that drags gas, chains, KYC-on-chain, and price volatility into a simple "pay 0.004 USD for this call" moment.

The thesis: the durable platform value in the agent economy is the payments rail (Mint + AITP-402) plus the marketplaces that settle on it. Turnstile is the sharpest, most developer-led wedge into that rail — it is not a marketplace, not a standards committee first; it is a library a developer drops into their server. AITP-402 is already specified and x402-shaped but fiat-backed, off-chain, gasless, and success-only (docs/mint/AITP-402-SPEC.md). Turnstile productizes that spec into: (a) a server middleware ("gate this route/tool"), (b) a client/agent payer ("pay any 402 I hit, within budget"), and (c) the reference verifier + conformance vectors that make "AITP-402 compliant" mean something.

Why this specific bet: it is the purest core-thesis play — own the agent → service payment handshake. The differentiator vs every crypto rival is that the money is boring on purpose: 1 AIT = 1 USD, integer microdollars (ADR-0001), captured only on success (ADR-0002), no chain, no gas, instant.


2. Why now

  • MCP is exploding but has no money layer. Thousands of MCP servers/tools are being published with zero native monetization. The first credible "make your MCP tool paid in 10 lines" wins developer mindshare during the land-grab.
  • HTTP 402 is being revived industry-wide (x402/Coinbase, agent-pay efforts). The standard slot is open but contested — being early with a working reference verifier + SDK matters more than the RFC.
  • We already have the rail. Mint's AITP-402 spec, holds→capture/release, allowances, hash-linked receipts, and reserve-backing are planned/being built. Relay already treats 402 as its flagship reference integration. Turnstile is the thin, high-leverage packaging on top — most of the hard settlement work is reused.
  • Fiat-backed is a wedge, not a footnote. Enterprises and indie devs both balk at holding volatile crypto to call an API. A gasless, USD-denominated, success-only handshake is the version a normal backend team will actually adopt.

3. The narrowest wedge + first customer

Wedge: "Make any MCP tool (or HTTP endpoint) paid-per-call in <10 lines." Ship a middleware for the two runtimes developers are actually shipping MCP servers and agent backends in — Python (turnstile PyPI, reusing ReelForge's Python provider-adapter discipline) and TypeScript/Node (the dominant MCP-server language). One decorator/wrapper turns a free tool into a metered, paid one; one client wrapper turns an agent into a payer with a budget.

First customer (design partner): an indie MCP-tool author shipping a useful but costly tool — e.g. a web-scrape, a premium-data lookup, a specialized inference tool — who today has no way to charge the agents calling it. Turnstile lets them price it at, say, 2,000 µ$/call and start earning into an ait1…3 provider address on Mint. Their cold-start cost is ~zero (add a wrapper), and Turnstile covers the payer side so the calling agent "just works" if it holds AIT.

Bottoms-up landing motion: land the first 100 paid MCP tools and the first cohort of funded agent wallets before spending a dollar on "the standard." Adoption count is the north star; the RFC follows the install base, not vice versa.

Cold-start-killer — Turnstile is its own first customer: every paid surface we already run becomes an AITP-402 endpoint on day one, so the network isn't empty when the first external tool arrives:

  • Relay model endpoints (already the flagship 402 reference integration).
  • ReelForge paid operations (render, publish, gateway model calls) exposed as agent-payable tools.
  • The ReelForge clipmarket and Relay model-author payouts become the first provider-side ait1… earners.

4. How it reuses ReelForge / Relay / Mint (concrete)

Turnstile is thin by design — it owns developer ergonomics, the verifier reference, and conformance, and delegates all money to Mint.

4.1 Mint (the rail — Turnstile is a first-class client of it)

Turnstile calls only documented Mint primitives; it never touches balances:

  • Challenge/authorize/verify — the server middleware emits the 402 + AITP-Challenge and calls POST /v1/aitp/verify (mint-protocol, AP3). Wire format is exactly docs/mint/AITP-402-SPEC.md §5.
  • aitp-hold scheme → hold.create → hold.capture/hold.release — the success-only path (ADR-0002). Metered tools reserve up to amount_micros, then capture actual usage; failures release in full so the agent pays nothing.
  • aitp-transfer scheme → transfer — for fixed-price tools where the price is known up front.
  • Allowances (allowance.grant/spend) — the client/payer SDK spends within a delegated per-agent budget/window (mint-accounts, AP3). This is the "agent has a wallet with a spend cap" story.
  • Receipts (GET /v1/receipts/:id, per-account hash-linked log) — Turnstile returns the AITP-Receipt header and exposes a one-call receipt lookup so both sides get a verifiable, tamper-evident record for free.
  • Reserve proof (GET /v1/reserve) — surfaced in Turnstile's dashboard as the "your balance is 1:1 backed" trust signal.
  • Fee economics — Turnstile's take-rate rides Mint's exact-µ$ fee split (docs/mint/IMPLEMENTATION.md §5): markup_bps / byok_fee_bps / creator_bps are journal transfers, so the platform fee and the tool-author payout are both auditable ledger entries, not off-ledger accounting.
  • mint-sdk — Turnstile's Python and TS SDKs wrap mint-sdk (Rust + generated Python from AP5) rather than re-implementing signing/verify.
  • mint-testkit conformance vectors (docs/mint/IMPLEMENTATION.md §9) — become Turnstile's cross-language conformance suite; passing them is what "AITP-402 compliant" means for a third-party SDK.

4.2 Relay (the reference integration + first paid endpoints)

  • Relay's model endpoints are the canonical AITP-402 server — Turnstile's server middleware is essentially the extraction of Relay's 402 handling into a reusable library, then Relay consumes it back (dogfood).
  • relay-billing settling on Mint (AP5) is the pattern Turnstile generalizes to "any endpoint," not just inference.
  • Relay's provider-manifest onboarding ergonomics inspire Turnstile's "tool-manifest" (price, scheme, scope) registration UX.

4.3 ReelForge / apps/api (Python ergonomics + first tools + payout rails)

  • Python SDK discipline — mirror the injectable-transport provider-adapter pattern (fake transport in tests) already used across ReelForge's 11 model adapters, so Turnstile's Python client is testable the same way.
  • First paid tools — ReelForge's render/publish/gateway operations get wrapped as agent-payable MCP tools, seeding the tool side of the network.
  • Payout rails reuse — the clipmarket CPM creator-payout machinery and its fraud checks are the same shape as tool-author payouts settling to ait1…4/…3 addresses; Turnstile reuses that instead of inventing a payout path.
  • Gateway markup/reseller — the existing markup + reseller concept maps directly onto Turnstile's take-rate on third-party paid tools.

4.4 Shared infra & invariants

  • ADR-0001 (integer microdollar) and ADR-0002 (success-only) are inherited verbatim — success-only is literally the hold→capture primitive.
  • Neon/Postgres, Cloudflare for Turnstile's own (small) metadata store; the authoritative money store is always Mint's journal, never Turnstile's.

5. Architecture sketch (prose + text diagram)

Turnstile has four parts and holds no money — it is middleware + SDKs + a thin control-plane, all settling through Mint.

  1. turnstile-server (middleware/adapters): framework adapters that gate a route or MCP tool. Emits 402 + AITP-Challenge, verifies the returned AITP-Authorization via Mint, runs the handler, then captures/releases the hold and attaches the AITP-Receipt. Adapters for: MCP servers (TS + Python), FastAPI/Starlette, Express/Hono, and a generic reverse-proxy sidecar for languages without a native adapter.
  2. turnstile-client (payer): wraps an agent's HTTP/MCP calls; on a 402, it builds and signs the authorization (via mint-sdk), enforces the agent's local budget/allowance, retries, and records the receipt. "Pay any 402 I hit, within my cap."
  3. turnstile-registry (control-plane, thin): where a tool author registers a tool manifest (resource id, price/scheme, scope, payout ait1… address), gets keys, and sees a dashboard (calls, revenue, receipts, reserve proof). Stores only metadata + pointers to Mint, never balances. Neon/Postgres + Cloudflare.
  4. turnstile-conformance (reference): hosts the AITP-402 conformance vectors (from mint-testkit), a public "is my endpoint compliant?" checker, and the spec docs. This is the credibility engine for the standard.
        AGENT SIDE                         TOOL / SERVICE SIDE
  ┌───────────────────────┐          ┌──────────────────────────────┐
  │  Agent / MCP client   │          │  Paid MCP tool or HTTP API   │
  │  + turnstile-client   │          │  + turnstile-server (gate)   │
  └───────────┬───────────┘          └───────────────┬──────────────┘
              │  1) call tool                         │
              │──────────────────────────────────────▶│
              │  2) 402 + AITP-Challenge (price,scheme)│
              │◀──────────────────────────────────────│
              │  3) sign AITP-Authorization            │
              │   (within local allowance/budget)      │
              │──────────────────────────────────────▶│
              │                                        │ 4) POST /v1/aitp/verify
              │                                        │────────────┐
              │                                        │            ▼
              │                                        │     ┌───────────────┐
              │                                        │     │     MINT      │
              │                                        │     │ mint-protocol │
              │                                        │     │ verify sig +  │
              │                                        │     │ hold.create   │
              │                                        │     └──────┬────────┘
              │                                        │◀───────────┘ ok(hold_id)
              │                                        │ 5) run handler
              │                                        │ 6) success→hold.capture(actual)
              │                                        │    failure→hold.release
              │  7) 200 + result + AITP-Receipt        │            │
              │◀──────────────────────────────────────│     ┌───────▼────────┐
              │                                        │     │ receipts (hash │
              │                                        │     │ -linked) +     │
              │                                        │     │ reserve 1:1    │
              │                                        │     └────────────────┘
  ┌───────────┴───────────┐          ┌──────────────────────────────┐
  │  turnstile-registry (control-plane): tool manifests, keys,       │
  │  dashboards, revenue — METADATA ONLY, money lives in Mint        │
  └─────────────────────────────────────────────────────────────────┘

Key boundary: Turnstile is stateless w.r.t. money. Every value-bearing action is a Mint op with a receipt. If Turnstile's control-plane vanished, the ledger and all balances would be intact in Mint. This keeps Turnstile safe to ship fast and keeps the moat (the ledger) in the audited component.


6. Monetization (fees/markup/take-rate on Mint)

All revenue is a journal transfer on Mint — auditable, exact µ$, success-only.

  • Take-rate on third-party paid calls (core): a platform fee in bps on each successful paid call, split at capture via Mint's fee math (creator_bps → tool author's ait1…3 address, platform fee → treasury). Free tier for tiny volume to keep cold-start friction near zero; fee kicks in above a threshold or on the paid plan.
  • Float on prepaid AIT: agents pre-fund ait1… wallets (minted 1:1 against Stripe/crypto deposits, reserve-gated). Standard prepaid-balance economics on the reserve, disclosed and compliant (closed-loop credit).
  • BYOK-style fee: for tools that meter their own upstream cost, Turnstile charges only a thin platform fee (byok_fee_bps) rather than marking up the whole call — matches Relay/gateway BYOK economics.
  • Payout rails: tool authors redeem earnings via Mint redeem (KYC-tiered) — same rail as ReelForge clipmarket and Relay model-author payouts. Turnstile takes no extra cut here beyond the per-call fee.
  • Enterprise/registry plan: private tool catalogs, SSO, higher rate limits, SLA on the verifier, and org treasuries/allowances (Mint AP6 governance) — seat + volume pricing.

Because every fee is a ledger transfer, the take-rate is transparent and the "we never overcharge beyond the ceil rule" invariant (IMPLEMENTATION §5) holds.


7. Moat & network effects

  • Two-sided network (winner-take-most if it wins): funded agent wallets pull tool authors ("agents here can pay you"), paid tools pull agent funding ("useful paid tools live here"). Each side compounds the other. The 100-paid-tools wedge is the first flywheel turn.
  • Standard + reference verifier: owning the conformance vectors and the "is my endpoint compliant?" checker makes AITP-402 mean Turnstile's behavior. Reference implementations, not committees, win protocol fights early.
  • The rail is the deep moat: Mint's reserve-backed, hash-linked, conservation- invariant ledger is genuinely hard to replicate and is the audited system of record. Turnstile is the friendly front door; Mint is the vault.
  • Fiat-backed/gasless/success-only is a durable differentiator vs x402/Coinbase, Skyfire, Payman — normal backend teams adopt USD-denominated, no-chain, pay-only- on-success far more readily than a crypto rail.
  • Data/trust flywheel: receipts + reserve proofs give both sides verifiable history; enterprises get solvency proofs. That trust is sticky and portable across the whole product family (one balance, every product).

Honest moat caveat (this is the highest-variance bet): standards fights are brutal and the agent-payment market may form slowly. The moat is "high IF it wins," so the strategy is fund the SDK, watch adoption, and do not over-invest in "the standard" until the install base justifies it.


8. GTM — first 100 users

  1. Dogfood first (make the network non-empty): wrap Relay model endpoints and ReelForge render/publish/gateway ops as AITP-402 paid tools before any external pitch. The catalog is already populated on day one.
  2. MCP-registry land-grab: publish turnstile on PyPI and npm; open-source the MCP adapters. Target MCP-tool authors directly with "make your tool paid in 10 lines" content, example repos, and a one-command demo.
  3. Design-partner cohort (10 tools): hand-hold the first ~10 indie tool authors to price and ship a paid tool, earning into ait1… addresses. Fix ergonomics against real usage.
  4. Fund the payer side: seed a batch of agent-dev wallets with promotional AIT so the calling side "just works," de-risking the classic two-sided cold start.
  5. Conformance as marketing: the public "AITP-402 compliant?" checker + spec site drives inbound and positions Turnstile as the reference, not a vendor.
  6. Expand runtimes: add Express/Hono, FastAPI, and the reverse-proxy sidecar as demand appears, then land the next ~90 tools bottoms-up.

North-star for GTM: # of paid tools live and # of funded, actively-paying agent wallets — not signups.


9. Key risks + kill-criteria

Risk Detail Kill / pivot signal
Market doesn't form Agent-to-agent paid API calls stay a demo, not a habit. Earliest-market risk of the deep-plan set. After 2 quarters post-launch: < ~25 paid tools with repeat paying traffic, or GMV flat near zero. Pivot Turnstile to internal-only settlement UX for Relay/ReelForge; shelve the "standard."
Standards war lost x402/Coinbase, Stripe agent-pay, Skyfire, Payman set the default; Turnstile is a non-standard island. A rival rail hits critical mass in the MCP ecosystem while Turnstile lags. Pivot to interoperability adapter (accept x402 on the tool side, settle on Mint) rather than fighting head-on.
Fiat-backing seen as weaker than crypto composability Buyers want on-chain settlement/composability we can't offer. Design partners consistently demand on-chain settlement. Mitigation: Mint's crypto on-ramp + optional merkle anchoring; kill only if fiat-backing is a dealbreaker for the majority.
Compliance drag Prepaid AIT + payouts trip money-transmission/KYC rules that slow shipping. Counsel flags AIT as regulated money transmission in key markets pre-GA. Mitigation: closed-loop posture, KYC tiers, reserve segregation (IMPLEMENTATION §7); constrain payout geographies first.
Turnstile too thin / disintermediated Devs skip Turnstile and hit Mint's AITP-402 directly. Fine, arguably — Mint still wins. But if Turnstile adds no ergonomic value, fold it into mint-sdk and stop funding a separate app.
Over-investing early Building "the standard" before adoption exists. Guardrail, not a kill: cap spend on registry/governance until the 100-paid-tools gate (S×2) is cleared.

10. Phased roadmap (S×0 → S×4 with acceptance gates)

Depends on Mint AP3 (AITP-402 + allowances) and AP5 (SDK + settlement) landing. Same recon→design→build→review→fix workflow shape as ReelForge waves / Relay RP0 / Mint AP-phases. TDD, injectable transport (fake Mint in tests).

  • S×0 — Spec lock + conformance harness. Freeze Turnstile's use of AITP-402 §5; import mint-testkit vectors into a cross-language conformance suite; stub SDKs with a fake Mint transport. Gate: conformance vectors (happy transfer, hold+capture, release-on-failure, expired auth, replayed nonce, bad sig, allowance exceeded, idempotent retry) run red→green against the fake transport in both Python and TS.

  • S×1 — Server middleware + client payer (MCP first). turnstile-server MCP adapter (TS + Python) that gates a tool; turnstile-client that pays a 402 within an allowance. Wire to real Mint aitp/verify + hold.create/capture/release. Gate: an agent completes an end-to-end aitp-hold paid MCP tool call — capture-on-success, release-on-failure, AITP-Receipt returned — against a live Mint (dev), settling to the µ$.

  • S×2 — Dogfood + land the first 100 paid tools. Wrap Relay + ReelForge operations as paid tools; ship the registry (manifests, keys, dashboard); add FastAPI/Express adapters + the reverse-proxy sidecar; seed agent wallets. Gate: 100 paid tools live and a cohort of funded wallets with repeat paying traffic; revenue (platform fee) is a real, auditable Mint journal split.

  • S×3 — Conformance-as-standard + interop. Public "AITP-402 compliant?" checker and spec site; certify third-party SDKs against the vectors; ship an interop/x402 shim (accept a rival scheme on the tool side, settle on Mint). Gate: ≥1 external SDK passes conformance; the interop shim accepts a non- Turnstile payer and settles correctly on Mint.

  • S×4 — Governance, enterprise & GA. Org treasuries/allowances (Mint AP6), private catalogs, SSO, verifier SLA, redeem/payout at scale with KYC tiers, OTel dashboards + reserve/solvency status. Gate: SLOs green (verify p99 < 15 ms per Mint §8); zero conservation/chain violations under chaos; a paying enterprise on org treasuries + allowances.


11. Success metrics

  • Adoption (north star): # paid tools live; # funded, actively-paying agent wallets; weekly repeat-paying tools.
  • GMV & take: paid-call GMV (µ$), platform-fee revenue, creator payout volume — all read straight off Mint journal splits.
  • Ergonomics: median lines-of-code + time-to-first-paid-call for a new tool (target: <10 lines, <30 min).
  • Reliability: verify p99 latency (< 15 ms, Mint SLO); success-only correctness (failures that captured: 0); receipt/chain integrity violations: 0.
  • Ecosystem/standard: # external SDKs passing conformance; # tools passing the public compliance checker; interop rails accepted.
  • Trust: reserve cushion ≥ buffer at all times (1:1 backing proof green).

12. Open decisions (resolve before / during S×1)

  1. Turnstile-as-library vs Turnstile-as-app: how much control-plane (registry/dashboard) is warranted before adoption proves out, vs folding into mint-sdk (see §9 disintermediation risk).
  2. Runtime priority order: MCP-TS first (largest MCP surface) vs MCP-Python (reuses ReelForge adapter discipline) — plan says both at S×1; confirm sequencing.
  3. Default scheme: lead with aitp-hold (metered, success-only) vs aitp-transfer (fixed price) in the quickstart, and how pricing is declared in a tool manifest.
  4. Free-tier fee threshold: the volume below which Turnstile takes 0% to protect cold-start, and the paid-plan fee bps defaults (ties to Mint fee defaults, open decision IMPLEMENTATION §10.5).
  5. Interop posture: how aggressively to build the x402 shim (S×3) — hedge against the standards war vs stay pure AITP-402.
  6. Custody for agent wallets: platform-KMS default vs self-custody keys for agents (Mint open decision §10.1) — affects the client payer signing path.