x402
Installation
bun add @regent/x402Basic Usage
import { createAgent } from '@regent/core';
import { http } from '@regent/http';
import { payments, paymentsFromEnv } from '@regent/x402';
const agent = await createAgent({
name: 'my-agent',
version: '1.0.0',
})
.use(http())
.use(payments({ config: paymentsFromEnv() }))
.build();API Reference
payments(options?)
PaymentsConfig
paymentsFromEnv()
Variable
Description
X402 Protocol Flow
Payment Storage
Storage Options
SQLite Storage (Default)
PostgreSQL Storage
In-Memory Storage
Policy Groups
PaymentPolicyGroup
Outgoing Limits
Incoming Limits
Policy Configuration File
Entrypoint Pricing
Setting Prices
Price Resolution
X402 Fetch
Creating X402-Enabled Fetch
Account from Private Key
Runtime Payment Context
RuntimePaymentContext
X402-Enabled LLM Client
PaymentsRuntime
Payment Tracker
Rate Limiter
HTTP Headers
402 Payment Required Response
Header
Description
Successful Payment Response
Header
Description
Amount Units
Utility Functions
parsePriceAmount
extractPayerAddress
validatePaymentsConfig
Supported Networks
EVM Networks
SVM Networks
Exports
Last updated