Overview
Gate an HTTP service for stablecoin payments — with the pay CLI (no code) or a language SDK (in-process). When to use which, and what each SDK supports.
There are two ways to add stablecoin payment gating to an HTTP service:
- the
payCLI — declare your endpoints and pricing in a YAML spec and run a gateway, no code; or - a language SDK — gate routes inside your own server process, when you need deeper integration.
Both speak the same 402 Payment Required handshake (MPP and x402) and the same gate model — an amount, the protocols you accept, and optional fees — so you can move from one to the other (or run both) without changing the payment model.
Start with the CLI
For most APIs the CLI is the fastest path and needs no code. Point it at a provider YAML and it runs a gateway that issues 402 challenges, verifies and settles payments, and (optionally) proxies paid requests to your upstream:
pay server start provider.ymlThe YAML declares routing, pricing and metering, subscriptions, and payment splits — see Building with pay. Reach for the CLI when you're gating an existing or upstream API, want the pay-skills catalog and discovery, or simply don't want payment logic in your application code.
Reach for an SDK when you need deeper integration
An SDK gates routes inside your application process, so you can:
- price or meter a request from your own app state — tokens generated, bytes served, rows returned;
- run logic in the paid handler and read the verified payment;
- embed gating in your existing framework's middleware;
- act as a paying client, not just a server.
The CLI and the SDKs are the same engine: a gate is an amount plus the protocols it accepts, settled over MPP or x402. Choosing an SDK doesn't change the wire protocol — it just moves the gate into your code.
The SDKs
| Language | Package | Frameworks | Guide |
|---|---|---|---|
| TypeScript | @solana/pay-kit | Express, Hono, Fetch (Workers / Next / Bun) | TypeScript → |
| Rust | solana-pay-kit | axum | Rust → |
| Go | github.com/solana-foundation/pay-kit/go | net/http | Go → |
| Python | solana-pay-kit | FastAPI, Flask, Django | Python → |
Every SDK ships a paying client of some form; TypeScript is the reference surface and the most complete.
Scheme support
Which payment schemes each SDK exposes as a one-line gate today. Where a cell is —, the protocol is often still reachable through that SDK's lower-level protocol layer — see the per-language guide.
| Scheme | TypeScript | Rust | Go | Python |
|---|---|---|---|---|
| Fixed charge | ✅ | ✅ | ✅ | ✅ |
Usage (upto) | ✅ | ✅ | ✅ | ✅ |
| Session | ✅ | — | — | ✅ |
| Subscription | ✅ | — | — | — |
| Batch-settlement | — | ✅ | — | — |
Next
- Building with pay — the CLI + YAML path, end to end.
- Toolchain — the full
payCLI reference. - Per-language guides: TypeScript, Rust, Go, Python.