Overview
ChainStream CLI can automatically purchase a subscription when it encounters a 402 (Payment Required) response. After a successful purchase, the returned API Key is saved to your config — all subsequent calls use the key without further wallet signatures.How It Works
When any CLI command receives a 402 error, the auto-payment flow activates:- CLI fetches available plans from
/x402/pricingand displays a selection table - You choose a plan interactively
- CLI asks for payment method: x402 (USDC on Base/Solana) or MPP (stablecoin on Tempo / Stripe card)
- If x402: signs and sends payment automatically, saves the returned API Key
- If MPP: prints the
tempo requestcommand for manual purchase - Retries the original command with the new API Key
If you only have an API Key (no wallet), the CLI skips x402 and prints MPP instructions instead.
Wallet Setup
x402 payment requires a funded wallet:View Plans
After Purchase
- The API Key (
cs_live_...) is automatically saved to~/.config/chainstream/config.json - The CLI client is re-initialized with the new key
- The original command is retried and succeeds
- All subsequent commands use the API Key — no further wallet signatures needed
Troubleshooting
| Issue | Solution |
|---|---|
| ”Insufficient USDC balance” | Fund your wallet with USDC on Base or Solana |
| 402 persists after purchase | Check chainstream config get to verify API Key was saved |
| Wrong chain selected | Use chainstream config set --key walletChain --value base |
| Want to change plan | Purchase a new plan — it replaces the existing subscription |
Learn More
x402 Payment Protocol
How the x402 protocol works, detailed flow, and manual integration
MPP Payment Protocol
How MPP works with Tempo stablecoin and Stripe card payments

