Use paid APIs like they were free.
No wallets. No signatures. Just an API key.
Pay per request — automatically, in the background.
You just call APIs. We turn any API into pay-per-request with a single API key.
How it works
We handle payments automatically.
curl "https://api.relai.fi/metered/x?url=https://api.example.com/data" \
-H "X-API-Key: rpx_..."Why Metered API?
AI agents need dynamic access. Usage is unpredictable, traffic spikes randomly, and subscriptions don't fit.
Built-in spending control
Every API key has configurable limits. Enterprise buyers love this. No unexpected costs.
Reject any single payment above a threshold
"maxPerTransactionUsd": 1.00Hard cap on total spending over a time window
"maxPerPeriodUsd": 50.00, "periodType": "daily"Exceeded limits return 402 — no silent overspend
PATCH https://api.relai.fi/metered/keys/rpx_...
{ "maxPerTransactionUsd": 1.00, "maxPerPeriodUsd": 50.00, "periodType": "daily" }Built for AI agents
Combined with Agent Budget Vault, you can give agents both a payment method and a hard spending cap.
Compared to traditional APIs
| Model | Setup | Agent-compatible | Risk |
|---|---|---|---|
| API keys + billing | Medium | ✗ requires account | Medium |
| Wallet + x402 | Complex | ⚠ needs key management | High |
| RelAI Metered API | Simple | ✓ works out of the box | Low (capped) |
Integration examples
Replace the target URL with the proxy URL. Add one header. That's it.
const PROXY = "https://api.relai.fi/metered/x";
const KEY = process.env.RELAI_PROXY_KEY;
async function callX402(url, options = {}) {
const res = await fetch(`${PROXY}?url=${encodeURIComponent(url)}`, {
method: options.method || "GET",
headers: { "X-API-Key": KEY, "Content-Type": "application/json", ...options.headers },
body: options.body ? JSON.stringify(options.body) : undefined,
});
return res.json();
}
const data = await callX402("https://api.example.com/data");
const result = await callX402("https://api.example.com/generate", {
method: "POST",
body: { prompt: "Hello world" },
});import os, requests
PROXY = "https://api.relai.fi/metered/x"
KEY = os.environ["RELAI_PROXY_KEY"]
def call_x402(url, method="GET", json=None):
return requests.request(
method, PROXY,
params={"url": url},
headers={"X-API-Key": KEY},
json=json,
).json()
data = call_x402("https://api.example.com/data")
result = call_x402("https://api.example.com/generate", method="POST",
json={"prompt": "Hello world"})# GET
curl "https://api.relai.fi/metered/x?url=https://api.example.com/data" \
-H "X-API-Key: $RELAI_PROXY_KEY"
# POST with JSON body
curl -X POST "https://api.relai.fi/metered/x?url=https://api.example.com/submit" \
-H "X-API-Key: $RELAI_PROXY_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "value"}'How it actually works
Your Code RelAI Proxy x402 API
| | |
|--- GET /metered/x --->| |
| X-API-Key: rpx_... | |
| |--- GET /data -------->|
| |<-- 402 Payment Req ---|
| | |
| | [auto-sign payment] |
| | |
| |--- GET + X-PAYMENT -->|
| |<-- 200 OK + data -----|
| | |
|<-- 200 OK + data ------| |402, proxy parses PAYMENT-REQUIRED headerX-PAYMENT headerAPI Reference
Authentication
| Endpoints | Auth | Header |
|---|---|---|
| register, keys, delete | JWT Bearer | Authorization: Bearer <JWT> |
| balance, usage, proxy | API Key | X-API-Key: rpx_... |
/metered/registerCreate API key + custodial wallets. Max 5 keys per user.
/metered/keysList all API keys. Secrets never returned.
/metered/keys/:apiKeyRevoke a key immediately.
/metered/keys/:apiKeyUpdate label and spending limits.
/metered/balanceUSDC balance across all networks. Auth: X-API-Key
/metered/usageSpending summary + recent request logs. Auth: X-API-Key
/metered/keys/:apiKey/withdrawWithdraw USDC to an external address.
/metered/keys/:apiKey/export-keyExport private keys (handle with care). Requires 2FA.
/metered/x?url=<target>Core proxy endpoint. Forwards request, auto-handles x402 payment.
{
"apiKey": "rpx_a1b2c3d4...",
"wallets": {
"solana": { "address": "4KuwK7vP...", "network": "solana" },
"evm": { "address": "0x0787F7...", "networks": ["base", "skale-base", "avalanche"] }
}
}{
"totalBalance": 10.50,
"balances": {
"solana": { "balance": 5.00 },
"base": { "balance": 3.50 },
"skale-base": { "balance": 2.00 },
"avalanche": { "balance": 0.00 }
}
}Supported Networks
| Network | Type | Token | Payment method |
|---|---|---|---|
| Solana | SVM | USDC (SPL) | Signed SPL transfer |
| Base | EVM | USDC (ERC-20) | EIP-3009 transferWithAuthorization |
| SKALE Base | EVM | USDC (bridged) | EIP-3009 transferWithAuthorization |
| Avalanche | EVM | USDC (ERC-20) | EIP-3009 transferWithAuthorization |
All EVM networks share one custodial wallet address. Deposit USDC on the specific chain you plan to use.
Error Handling
| Status | Meaning |
|---|---|
401 | Missing or invalid API key |
402 | Payment failed — insufficient balance, signing error, or spending limit exceeded |
400 | Missing url parameter or invalid URL |
502 | Target returned 402 without valid x402 requirements, or proxy failed |
Private agent payouts
If your agent needs to pay another wallet privately (hide amount + sender), pair Metered API Access with the Shielded Links API in the Management API. Both use the same X-Service-Key — you can fund a shielded link with one call, share its payload, and the claimant redeems with a zero-knowledge proof.
Currently on solana-devnet, base-sepolia, skale-base-sepolia. Mainnet rollout after testnet trials. V4 pools (Privacy Pools / ASP) require a 7-input Groth16 proof — GET /v1/shielded-links/:id/proof-inputreturns the ASP witness and circuit URLs so your agent can generate it with snarkjs in Node.
Receive private payments
Reverse direction: your agent issues an invoice and the counterparty pays it privately. The Shielded Payment Requests API lets you mint a quote, share its opaque relai:quote:… string, and watch for the on-chain match — all gated by the same X-Service-Key. Once the buyer pays, your agent generates a redeem proof and pulls the USDC out via the payout router. Buyer cannot clawback after pairing — their pool nullifier is burned atomically with the match record.
On Solana the redeem path adds two extras for free: a 5% platform fee split atomically inside the payout-router transaction (seller receives 95%, operator collects 5%), and a per-quote stealth recipient so the on-chain payout never references the seller's main wallet — a follow-up relayer-co-signed transfer hops the funds from the stealth ATA to wherever the seller wants. EVM SPR ships fee-free for now.
Live on base-sepolia, skale-base-sepolia, and solana-devnet. End-to-end agent flow is one issue call, one poll call, one redeem call: POST /v1/shielded-payment-requests → GET /facilitator/.../:quoteId/match-status → GET /v1/.../redeem-proof-input → payout_to_seller. Node reference client (with paySPR() + redeemSPR() one-call helpers) lives at examples/spr-agent/.
FAQ
The proxy returns a 402 explaining which network needs funding and how much.
Yes. Each key comes with Solana and EVM wallets. The proxy picks the right one automatically.
You only pay the x402 price set by the API. RelAI does not add any markup.
Both x402 v1 and v2 payment requirements are supported.
Yes — if the target doesn't return 402, the response is forwarded directly. The proxy is transparent for non-x402 endpoints.
Private keys are stored encrypted server-side using envelope encryption and Azure Key Vault. Never exposed through the API.