x402 sdk

x402 SDK — Pay-Per-Intelligence

circle-exclamation

What is this?

Milo will use the x402 protocolarrow-up-right to let you pay for smarter AI models on-the-fly. Instead of fixed subscription tiers, you pay per request — upgrade the brain behind any API call by attaching a stablecoin micropayment.

No signup. No billing portal. Just an HTTP header.

How it will work

Every Milo API endpoint that involves AI reasoning (conversations, position analysis, auto-trade decisions) will accept an optional x402 payment. When you pay, Milo routes your request to a more capable model with deeper analysis, more tool calls, and longer context.

┌──────────┐                    ┌──────────┐                  ┌──────────┐
│  Client  │ ── request ──────► │   Milo   │ ── settle ─────► │  x402    │
│          │                    │   API    │                  │Facilitator│
│          │ ◄── 402 + price ── │          │                  │          │
│          │                    │          │                  │          │
│          │ ── request ──────► │          │ ◄── verified ─── │          │
│          │    + payment       │          │                  │          │
│          │ ◄── 200 + result ─ │          │                  │          │
└──────────┘                    └──────────┘                  └──────────┘
  1. You call a Milo endpoint as usual

  2. If you want the premium model, include the X-PAYMENT header with your x402 payment payload

  3. Milo verifies the payment via the x402 facilitator on Solana

  4. Your request is routed to the upgraded model

  5. If you don't pay, you still get the standard model — nothing breaks

Model Tiers (Planned)

Tier
Cost per request
What you get

Standard

Free (with API key)

Default model. Fast responses, good for routine tasks

Pro

~$0.01 USDC

Smarter model. Deeper analysis, more tool calls, better trade reasoning

Ultra

~$0.05 USDC

Best available model. Maximum context, multi-step research, institutional-grade analysis

Pricing is per-request and settled instantly on Solana in USDC. Final pricing will be announced closer to launch.

Which endpoints will support it?

Endpoint
Standard (free)
Pro
Ultra

Create conversation (market-analyst)

yes

yes

yes

Create conversation (auto-trader)

yes

yes

yes

Send message

yes

yes

yes

List positions (with PnL analysis)

yes

yes

Auto-trade rebalance decisions

automatic

The auto-trader agent will benefit the most from upgrades — Pro and Ultra models evaluate more signals, consider longer price history, and produce more detailed theses before entering or exiting positions.

Quick Example (Planned)

Once live, upgrading a request will look like this:

Standard request (free):

Pro request (with x402 payment):

Same endpoint. Same request body. The only difference is the X-PAYMENT header. None of this works yet — we'll announce when it's ready.

SDK Integration (Coming Soon)

We're building SDK wrappers that handle payment construction automatically. You'll set a budget and the SDK handles the rest.

JavaScript / TypeScript

Status: Coming soon. The SDK will wrap @x402/svm for Solana payment construction and handle retry logic when the facilitator returns settlement confirmation.

Python

Status: Coming soon.

Raw HTTP (via x402 libraries)

Once Milo endpoints support x402, you'll also be able to use any x402 client library (@x402/fetch, @x402/axios) directly without the Milo SDK:

The x402 fetch wrapper handles the 402 → payment → retry flow automatically.

Status: Coming soon. The x402 client libraries exist today, but Milo does not accept x402 payments yet.

Spending Controls (Coming Soon)

The SDK will include safety rails so autonomous agents don't overspend:

Setting
Description

maxSpendPerRequest

Max USDC per single API call

maxSpendPerHour

Hourly budget cap

maxSpendPerDay

Daily budget cap

modelTier

Default tier (standard, pro, ultra)

autoUpgrade

Auto-upgrade to Pro if Standard response quality is low

Why x402?

  • No subscriptions — Pay only for what you use

  • Instant settlement — Payments settle on Solana in ~400ms

  • Agent-native — Your trading bot can decide when to pay for better analysis

  • Transparent pricing — Cost is per-request, visible before you pay

  • Backward compatible — Standard tier always works without payment

Roadmap

Feature
Status

x402 payment verification on API

Coming soon

Pro tier (conversations, analysis)

Coming soon

Ultra tier (deep research, portfolio review)

Coming soon

TypeScript SDK (@milo/sdk)

Coming soon

Python SDK

Coming soon

Spending controls & budget caps

Coming soon

Auto-upgrade (smart tier selection)

Coming soon

Pay-per-trade execution priority

Planned

Get Notified

Want early access? Join our Discordarrow-up-right and ask about the x402 beta.

Last updated