RelAI now supports x402 payment flows over WebSocket. If you publish APIs on RelAI, this unlocks lower-latency transport for buyers and agents, while keeping your existing provider integration unchanged.
The short version: buyers can use a shared WS gateway, but providers still expose normal HTTP APIs.
Why add WebSocket transport to x402?
HTTP x402 works great and remains fully supported. WebSocket adds a second transport optimized for interactive and high-frequency usage.
Main benefits
- Lower overhead per request - fewer TCP/TLS handshakes with persistent sockets
- Lower latency - especially when making many paid calls in sequence
- Better fit for agents - one live connection can handle many request/reply cycles
- Backward compatibility - HTTP fallback remains available
The key model: shared WS endpoint + per-API relay URL
On RelAI, each published API has an HTTP relay URL:
https://api.relai.fi/relay/{apiId}/...
WebSocket uses one shared endpoint:
wss://api.relai.fi/api/ws/relay
The buyer sends method relay.call and specifies which API to target (apiId) and which route to call (path).
What providers need to implement
In most cases: nothing new.
If your API already works with RelAI HTTP relay, you do not need to run a dedicated WebSocket server. RelAI's WS relay forwards calls into the same HTTP relay and x402 middleware stack used today.
That means:
- same pricing config,
- same facilitator flow,
- same settlement behavior,
- same endpoint business logic.
How the 402 payment handshake works over WS
The flow remains identical to HTTP x402 semantics:
- Buyer sends
relay.callwithout payment payload. - RelAI responds with error code
402andpaymentRequireddetails. - Buyer signs payment payload with wallet.
- Buyer retries
relay.callwith top-levelpayment. - On success, buyer gets
resultand optionalpaymentResponse(settlement data).
Example WS request envelope
{
"id": "req-42",
"method": "relay.call",
"params": {
"apiId": "1769629274857",
"path": "/v1/chat/completions?model=gpt-4o-mini",
"requestMethod": "POST",
"requestHeaders": {
"Content-Type": "application/json",
"Accept": "application/json"
},
"requestBody": {
"messages": [{ "role": "user", "content": "Hello" }]
}
}
}
For buyers and agent builders
If you consume many paid endpoints in one session:
- keep a persistent WS connection,
- correlate responses by
id, - set request-level timeouts,
- fall back to HTTP when WS is unavailable.
Operational guidance for providers
Even though providers do not run WS infrastructure in this model, you should still:
- monitor settlement hashes (
paymentResponse.transaction) for observability, - keep endpoint responses deterministic and fast,
- ensure relay targets are stable under bursty agent traffic,
- document your endpoint rate limits clearly for buyers.
Final takeaway
RelAI's WebSocket relay gives buyers and autonomous agents a faster path for x402 payments, while preserving the provider experience you already have today.
No new provider-side WS server. No separate payment stack. Just an additional transport that improves throughput and UX for paid API consumption.
Need protocol context first? Read the x402 overview and the RelAI documentation hub.
If your API is already monetized through RelAI HTTP relay, you're already compatible with WS relay consumption.
