Skip to main content
ARouter supports the x402 payment protocol, the open standard for HTTP-native payments. AI agents with crypto wallets can authenticate, pay for credits, and make LLM requests — all without registering an account or logging into a dashboard.

Three Entry Points

ARouter provides three ways for agents to get started. API key users and wallet users now follow separate long-term paths:
Entry PointAuth MethodUse Case
Standard x402 PaymentPAYMENT-SIGNATURE header onlyAny x402 client — first wallet payment registers account and returns a wallet JWT
SIWx AuthenticationSIGN-IN-WITH-X headerProve wallet ownership → get wallet JWT (no payment)
API KeyAuthorization: Bearer lr_live_xxxxExisting API key users — insufficient balance returns 403, no x402 auto-topup
Standard x402 mode works with any x402-compatible tool@x402/fetch, awal, MCP wallets, Chrome extensions. No ARouter SDK required.

How It Works

Standard x402 (Any x402 Client)

The simplest entry point. Any wallet with USDC can make LLM requests immediately:
  1. Send a request with no API key — the gateway returns HTTP 402 with payment options.
  2. The x402 client signs a USDC payment (gasless via EIP-3009).
  3. Retry the request with the PAYMENT-SIGNATURE header.
  4. The gateway verifies, settles, creates your account, and returns the response.
  5. The PAYMENT-RESPONSE header contains a jwt extension for future wallet-authenticated requests.

SIWx Authentication (Wallet Sign-In)

Prove wallet ownership to get a wallet JWT without paying first: SIWx follows the CAIP-122 standard — the same protocol used by QuickNode and other x402-enabled services.

API Key Users

Existing API key users continue to use the standard ARouter API key flow:

Supported Networks

NetworkCAIP-2 IdentifierToken
Base Mainneteip155:8453USDC
Base Sepolia (testnet)eip155:84532USDC
Solana Mainnetsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpUSDC
Solana Devnetsolana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1USDC

Wallet Compatibility

All wallets work — no private key export required:
WalletPayment (EIP-3009)Auth (SIWx)Needs Private Key?
MetaMaskNo
Coinbase WalletNo
Coinbase Agent WalletNo (CDP API)
Phantom (Solana)No
Local private keyYes

SDK Usage

Standard x402 (No ARouter SDK Needed)

Use Coinbase’s official @x402/fetch directly:
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(signer));

const paidFetch = wrapFetchWithPayment(fetch, client);

const resp = await paidFetch("https://api.arouter.ai/v1/chat/completions", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "openai/gpt-5.4",
    messages: [{ role: "user", content: "Hello" }],
  }),
});

SIWx Authentication (Get Wallet JWT)

Node.js SDK

import { ARouter, authenticateWithSIWx } from "@arouter/sdk";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);

const { jwt } = await authenticateWithSIWx(
  "https://api.arouter.ai",
  { address: account.address, signMessage: (msg) => account.signMessage({ message: msg }) },
);

const client = new ARouter({ baseURL: "https://api.arouter.ai", apiKey: jwt });

Go SDK

import arouter "github.com/arouter-ai/arouter-go"

signer := arouter.NewEvmWalletSigner(privateKey)
result, err := arouter.AuthenticateWithSIWx(ctx, "https://api.arouter.ai", signer, nil)

client := arouter.NewClient("https://api.arouter.ai", result.JWT)

Go SDK — EVM (Base)

import (
    "github.com/ethereum/go-ethereum/crypto"
    arouter "github.com/arouter-ai/arouter-go"
)

key, _ := crypto.HexToECDSA("your-private-key-hex")

client := arouter.NewClient(
    "https://api.arouter.ai",
    "",  // no API key needed
    arouter.WithX402CoinbasePayment(key),
)
WithX402CoinbasePayment sets up wallet x402 payment with JWT caching:
  • first successful payment returns a wallet JWT inside PAYMENT-RESPONSE
  • subsequent requests use Bearer <jwt>
  • 401 triggers SIWx re-authentication
  • 402 triggers x402 payment

Go SDK — Solana

solanaKey := ed25519.PrivateKey(yourKeyBytes)
client := arouter.NewClient("https://api.arouter.ai", "",
    arouter.WithX402SolanaPayment(solanaKey),
)

Node.js SDK — EVM (Base)

import { ARouter, withX402EvmPayment } from "@arouter/sdk";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = withX402EvmPayment(
  new ARouter({ baseURL: "https://api.arouter.ai", apiKey: "" }),
  signer,
);

Node.js SDK — Dual-Chain (EVM + Solana)

import { ARouter, withX402Payment } from "@arouter/sdk";

const client = withX402Payment(
  new ARouter({ baseURL: "https://api.arouter.ai", apiKey: "" }),
  {
    evm: { signer: evmAccount },
    solana: { signer: solanaSigner },
  },
);

GET Endpoint for CLI Tools

For x402 CLI tools like awal that cannot send POST bodies:
GET /v1/x402/chat?model=openai/gpt-5.4&message=Hello&system=Be+brief&max_tokens=100
ParameterRequiredDescription
modelYesModel name, e.g. openai/gpt-5.4
messageYesUser message text
systemNoSystem prompt
max_tokensNoMaximum output tokens
temperatureNoTemperature parameter
streamNoSet to true for streaming

Payment Headers

HeaderDirectionDescription
PAYMENT-REQUIREDServer → ClientBase64-encoded payment options (amount, wallet, network).
PAYMENT-SIGNATUREClient → ServerBase64-encoded signed payment payload.
SIGN-IN-WITH-XClient → ServerBase64-encoded SIWx authentication proof.
PAYMENT-RESPONSEServer → ClientBase64-encoded settlement result. ARouter adds a jwt field for wallet users.

How Credits Work

  • x402 payments are deposited as credits into your tenant balance — the same pool used by Stripe and Helio payments.
  • All x402 transactions appear in the Billing page under transaction history with the x402_topup reference type.
  • The gateway deducts credits per-request as usual after the balance is topped up.
  • Wallet users are billed by tenant, authenticated by wallet JWT, and can re-authenticate via SIWx without exposing raw API keys.

Security

  • Standard x402 protocol: Uses Coinbase’s official x402 SDK for verification and settlement.
  • Facilitator verification: Payments are cryptographically verified via the x402 Facilitator before credits are granted.
  • Gasless payments: EIP-3009 (TransferWithAuthorization) — users sign, the Facilitator submits on-chain.
  • Amount cap: Single payments are capped to prevent unexpectedly large charges.
  • Idempotency: Each payment payload has a unique nonce — the same signature cannot be replayed.
  • SIWx standard: Authentication follows CAIP-122 with EIP-4361 (EVM) and SIWS (Solana) message formats.
  • Audit trail: All x402 top-ups are recorded in transaction history alongside Stripe/Helio payments.
  • Non-custodial: USDC goes directly to the receiving wallet. The Facilitator never holds funds.