@blockrun/elizaos-plugin
v1.0.0
Published
BlockRun x402 pay-per-request AI plugin for ElizaOS - enables agents to make micropayments for AI API calls on Base
Maintainers
Readme
@elizaos/plugin-blockrun
Pay-per-request AI for ElizaOS agents via x402 micropayments on Base.
Overview
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
Installation
npm install @elizaos/plugin-blockrun
# or
pnpm add @elizaos/plugin-blockrunConfiguration
Set 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...',
},
});Usage
Plugin Registration
import { blockrunPlugin } from '@elizaos/plugin-blockrun';
const agent = new Agent({
plugins: [blockrunPlugin],
});Available Actions
BLOCKRUN_CHAT
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 x402Available Providers
BLOCKRUN_WALLET
Provides wallet context to the agent:
// Returns wallet address and USDC balance on Base
// Useful for agents to understand their payment capacityHow It Works
- 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.
Environment Variables
| 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 |
Links
- BlockRun - Pay-per-request AI gateway
- x402 Protocol - HTTP 402 micropayment standard
- ElizaOS - AI agent framework
License
MIT
