Metered API Access

Use paid APIs like they were free.

No wallets. No signatures. Just an API key.

Pay per request — automatically, in the background.

You don't manage payments.

You just call APIs. We turn any API into pay-per-request with a single API key.

Without RelAI
manage wallets
sign every request
handle payment logic
secure private keys
deal with crypto
With RelAI
one API key
one header
payments handled automatically
spending limits built-in
works for AI agents

How it works

01Generate an API key
02Fund your account (USDC)
03Set spending limits (optional)
04Call any API

We handle payments automatically.

That's it — one header
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.

Pay only for what you useNo monthly subscriptions. No prepaid credits. One request = one payment.
No payment logic in your codeThe proxy handles 402 detection, payment signing, and retry — invisibly.
Works across networksSolana, Base, SKALE, Avalanche — one key works everywhere automatically.

Built-in spending control

Every API key has configurable limits. Enterprise buyers love this. No unexpected costs.

Per-request cap

Reject any single payment above a threshold

"maxPerTransactionUsd": 1.00
Daily / monthly budget

Hard cap on total spending over a time window

"maxPerPeriodUsd": 50.00, "periodType": "daily"
Automatic blocking

Exceeded limits return 402 — no silent overspend

Set spending limits via API
PATCH https://api.relai.fi/metered/keys/rpx_...
{ "maxPerTransactionUsd": 1.00, "maxPerPeriodUsd": 50.00, "periodType": "daily" }

Built for AI agents

Agents can call paid APIs with zero friction.
No wallets — agents don't need private keys
No signing — the proxy handles it
No human interaction — fully autonomous
Just API calls

Combined with Agent Budget Vault, you can give agents both a payment method and a hard spending cap.

Compared to traditional APIs

ModelSetupAgent-compatibleRisk
API keys + billingMedium✗ requires accountMedium
Wallet + x402Complex⚠ needs key managementHigh
RelAI Metered APISimple✓ works out of the boxLow (capped)

Integration examples

Replace the target URL with the proxy URL. Add one header. That's it.

JavaScript / Node.js
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" },
});
Python
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"})
cURL
# 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

Request flow
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 ------|                       |
1.Request forwarded to target URL
2.If target returns 402, proxy parses PAYMENT-REQUIRED header
3.EVM: signs EIP-3009 transferWithAuthorization · Solana: signs SPL transfer
4.Re-sends request with X-PAYMENT header
5.Returns final API response to your code + logs payment

API Reference

Authentication

EndpointsAuthHeader
register, keys, deleteJWT BearerAuthorization: Bearer <JWT>
balance, usage, proxyAPI KeyX-API-Key: rpx_...
POST/metered/register

Create API key + custodial wallets. Max 5 keys per user.

GET/metered/keys

List all API keys. Secrets never returned.

DELETE/metered/keys/:apiKey

Revoke a key immediately.

PATCH/metered/keys/:apiKey

Update label and spending limits.

GET/metered/balance

USDC balance across all networks. Auth: X-API-Key

GET/metered/usage

Spending summary + recent request logs. Auth: X-API-Key

POST/metered/keys/:apiKey/withdraw

Withdraw USDC to an external address.

POST/metered/keys/:apiKey/export-key

Export private keys (handle with care). Requires 2FA.

ALL/metered/x?url=<target>

Core proxy endpoint. Forwards request, auto-handles x402 payment.

POST /metered/register — response
{
  "apiKey": "rpx_a1b2c3d4...",
  "wallets": {
    "solana": { "address": "4KuwK7vP...", "network": "solana" },
    "evm":    { "address": "0x0787F7...", "networks": ["base", "skale-base", "avalanche"] }
  }
}
GET /metered/balance — response
{
  "totalBalance": 10.50,
  "balances": {
    "solana":     { "balance": 5.00 },
    "base":       { "balance": 3.50 },
    "skale-base": { "balance": 2.00 },
    "avalanche":  { "balance": 0.00 }
  }
}

Supported Networks

NetworkTypeTokenPayment method
SolanaSVMUSDC (SPL)Signed SPL transfer
BaseEVMUSDC (ERC-20)EIP-3009 transferWithAuthorization
SKALE BaseEVMUSDC (bridged)EIP-3009 transferWithAuthorization
AvalancheEVMUSDC (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

StatusMeaning
401Missing or invalid API key
402Payment failed — insufficient balance, signing error, or spending limit exceeded
400Missing url parameter or invalid URL
502Target returned 402 without valid x402 requirements, or proxy failed

FAQ

What happens if I don't have enough USDC?

The proxy returns a 402 explaining which network needs funding and how much.

Can one API key work across multiple networks?

Yes. Each key comes with Solana and EVM wallets. The proxy picks the right one automatically.

Is there a fee for using the proxy?

You only pay the x402 price set by the API. RelAI does not add any markup.

What x402 versions are supported?

Both x402 v1 and v2 payment requirements are supported.

Can I use this for non-x402 APIs?

Yes — if the target doesn't return 402, the response is forwarded directly. The proxy is transparent for non-x402 endpoints.

Are my wallet keys safe?

Private keys are stored encrypted server-side using envelope encryption and Azure Key Vault. Never exposed through the API.