Let agents pay for APIs — without wallets.
Agents use a simple API key. RelAI handles payments, settlement, and billing automatically.
10-second example
curl https://relai.fi/metered/{apiId}/api/endpoint \
-H "X-Service-Key: sk-agent-123" \
-H "X-Agent-ID: 1"
→ 200 OK
→ payment handled by RelAIThe agent passes two headers. RelAI identifies it, finds the Metered account, and pays the x402 fee automatically.
Why this exists
How it works
The EVM network is only relevant once — when you link the agent to verify NFT ownership. After that, sk-agent-... is just a plain API key with no blockchain dependency.
Calling APIs as an agent
Agents call APIs through the Metered endpoint. RelAI handles x402 payment automatically.
Metered Relay — any RelAI-hosted API
curl https://relai.fi/metered/{apiId}/api/endpoint \
-H "X-Service-Key: sk-agent-..." \
-H "X-Agent-ID: 1"Metered Proxy — any external x402 API
curl "https://relai.fi/metered/x?url=https://api.example.com/data" \
-H "X-Service-Key: sk-agent-..." \
-H "X-Agent-ID: 1"Agent bootstrapping
The agent is configured at startup — the same way any API credential is passed (OpenAI key, DB URL, etc.).
Environment variables
RELAI_SERVICE_KEY=sk-agent-...
RELAI_AGENT_ID=1
RELAI_API_ID=1772665023009Config file
{
"paymentProvider": "relai",
"relai": {
"consentUrl": "https://relai.fi/agent-keys/consent/initiate",
"apiId": "1772665023009"
}
}Tip: The consent flow is only needed once per agent. After the key is issued, the agent stores and reuses it — no re-authentication required.
OAuth consent flow (advanced)
For autonomous agents that cannot open a browser. The agent requests access, the user approves via a link, and the agent retrieves the key — without ever seeing user credentials.
1. Initiate
curl -X POST https://relai.fi/agent-keys/consent/initiate \
-H "Content-Type: application/json" \
-d '{
"agentPubKey": "0xABC...",
"agentId": "1",
"contractAddress": "0x8004...",
"network": "skale-base",
"agentName": "My Trading Bot"
}'
→ {
"consentToken": "4f119402c96d15a08e3f27775aef0898",
"authorizeUrl": "https://relai.fi/authorize?token=4f119402...",
"expiresAt": "2026-03-06T14:00:00Z"
}3. Poll for approval
curl https://relai.fi/agent-keys/consent/status/4f119402...
→ { "status": "approved", "retrieveNonce": "abc123..." }Statuses: consent_pending · approved · rejected · expired · retrieved
4. Retrieve the key
import { ethers } from 'ethers';
const wallet = new ethers.Wallet(AGENT_PRIVATE_KEY);
const status = await fetch('/agent-keys/consent/status/' + token).then(r => r.json());
const sig = await wallet.signMessage(status.retrieveNonce);
const { key } = await fetch('/agent-keys/consent/retrieve', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ consentToken: token, signature: sig })
}).then(r => r.json());
// key = 'sk-agent-...'API Reference
/agent-keys/consent/initiatePublicStart the consent flow. Returns consentToken and authorizeUrl.
/agent-keys/consent/status/:tokenPublicPoll consent status. Returns retrieveNonce when approved.
/agent-keys/consent/retrievePublicRetrieve the service key. Requires agent signature of retrieveNonce.
/agent-keysBearer JWTList all agent keys linked to your account.
/agent-keys/:keyIdBearer JWTRevoke an agent key permanently. Immediate effect.
Security
Dashboard
Manage agent keys from Dashboard → Agent Keys.
Enter contract address, token ID, and network. Connect MetaMask and sign the challenge (no gas). Key issued immediately.
Click the trash icon next to a key. Confirmation dialog appears before permanent deletion. Effective immediately.