API Reference
Micropay exposes an OpenAI-compatible surface with x402 payment headers. Clients pay USDC on Algorand; Micropay settles via the GoPlausible facilitator, then fulfills inference through its server-side provider gateway.
Realtime
- SSE — chat token streaming (
stream:true) and image job progress (GET …/jobs/:id?stream=1). - WebSocket — not used (HTTP SSE fits TanStack Start routes without a custom upgrade server).
- JSON poll — optional fallback for image jobs without
stream=1.
/api/v1/chat/completionsChat completion (OpenAI-compatible, streaming supported). Anthropic-only models (e.g. Claude) are auto-routed via /v1/messages. x402 settle then Micropay runs inference. Provider keys stay server-side.
/api/v1/modelsList available models. Add ?raw=1 for the upstream catalog payload.
/api/v1/images/generationsImage generation (requires Supabase Storage). Default waits for the job; ?async=1 returns jobId after payment (Studio then uses SSE).
/api/v1/images/jobs/:jobIdJob status. JSON poll by default; ?stream=1 (or Accept: text/event-stream) for SSE progress until done. On completion persists images to Supabase (no extra payment).
/api/v1/audio/transcriptionsSpeech-to-text multipart transcription (50 MB max).
/api/v1/storage/uploadUpload a file to Supabase Storage (multipart field: file; optional folder). Hard 50 MB limit. Server-side only.
/api/v1/activitiesUsage history from settled x402 requests (Postgres). Optional ?wallet= & X-Wallet-Address.
/api/v1/chat/sessionsList chat sessions for a wallet (?wallet=&modelId=&latest=1).
/api/v1/chat/sessionsCreate a session or append messages (persist chat turn).
/api/v1/chat/sessions/:sessionIdFetch a session and its messages.
/api/v1/chat/sessions/:sessionIdDelete a session (or ?clear=1 to wipe messages only).
/api/v1/puya-ts/compileCompile Algorand TypeScript (puya-ts) source to TEAL approval/clear programs. Body: { source: string }. Free (not x402).
# Browser clients: use @x402/fetch + Algorand wallet (auto PAYMENT-SIGNATURE).
# Agents: handle 402 → sign → retry with PAYMENT-SIGNATURE.
curl http://localhost:3000/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "PAYMENT-SIGNATURE: <signed-payload>" \
-d '{
"model": "glm-5.2",
"messages": [{"role":"user","content":"Hello"}]
}'