§ Free tier wake-up — first request may take ~30 seconds

MicroAI Paygate docs

Build against the paygate.
Developer documentation for the SDK, gateway API, custom x402-style flow, operations, and current production limits.

Gateway API

The gateway is the public HTTP surface. In local development it runs at http://localhost:3000.

The gateway also serves OpenAPI at GET /openapi.yaml and Swagger UI at GET /docs.

Endpoints

POST /api/ai/summarize

Summarizes text after payment authorization. The first unsigned request receives a 402 Payment Required response with a paymentContext. The signed retry includes the EIP-712 signature headers.

GET /api/receipts/{id}

Fetches a stored signed receipt until the configured receipt TTL expires.

GET /healthz

Liveness check for the gateway process.

GET /readyz

Readiness check for verifier reachability, the active AI provider, Redis when required, and the gateway's own metrics.

Request Headers

Unsigned first request:

HTTP
POST /api/ai/summarize HTTP/1.1
Content-Type: application/json

Signed retry:

HTTP
POST /api/ai/summarize HTTP/1.1
Content-Type: application/json
X-402-Signature: 0x...
X-402-Nonce: ...
X-402-Timestamp: 1766611200

Response Headers

Successful paid responses include:

HTTP
X-402-Receipt: <base64 SignedReceipt JSON>

The receipt is intentionally returned in a header so the response body hash can match the body the client receives.

Error Categories

  • Missing or malformed payment challenge.
  • Invalid signature.
  • Chain ID mismatch.
  • Expired or future timestamp.
  • Replayed nonce.
  • Verifier timeout or unavailable.
  • AI provider timeout or unavailable.
  • Receipt generation, encoding, or storage failure.

OpenAPI

The canonical API contract is available in the repo and from a running gateway: