Pay-per-request AI for ElizaOS agents via x402 micropayments on Base.
This plugin enables ElizaOS agents to make LLM API calls using the x402 protocol, paying with USDC micropayments on Base chain. No API keys required - just a wallet with USDC.
Supported Models:
- OpenAI: gpt-4o, gpt-4o-mini
- Anthropic: claude-sonnet-4, claude-3.5-haiku
- Google: gemini-2.0-flash
- And more via BlockRun gateway
npm install @elizaos/plugin-blockrun
# or
pnpm add @elizaos/plugin-blockrunSet your Base chain wallet private key:
BASE_CHAIN_WALLET_KEY=0x...Or in agent settings:
const agent = new Agent({
plugins: [blockrunPlugin],
settings: {
BASE_CHAIN_WALLET_KEY: '0x...',
},
});import { blockrunPlugin } from '@elizaos/plugin-blockrun';
const agent = new Agent({
plugins: [blockrunPlugin],
});Make a pay-per-request AI call:
// The action is triggered when the agent needs to query an AI model
// Payments are handled automatically via x402Provides wallet context to the agent:
// Returns wallet address and USDC balance on Base
// Useful for agents to understand their payment capacity- Agent makes an AI request via BLOCKRUN_CHAT action
- BlockRun gateway returns 402 Payment Required with price
- Plugin automatically signs USDC payment (EIP-712)
- Request is retried with payment signature
- AI response is returned to the agent
All payments use USDC on Base chain. Typical cost: $0.001-0.01 per request.
| Variable | Description | Required |
|---|---|---|
BASE_CHAIN_WALLET_KEY |
Private key for Base chain wallet | Yes |
BLOCKRUN_API_URL |
Custom API URL (default: https://blockrun.ai/api) | No |
BLOCKRUN_DEFAULT_MODEL |
Default model (default: openai/gpt-4o-mini) | No |
- BlockRun - Pay-per-request AI gateway
- x402 Protocol - HTTP 402 micropayment standard
- ElizaOS - AI agent framework
MIT