npm.io
1.0.0 • Published 4d ago

@blockrun/elizaos-plugin

Licence
MIT
Version
1.0.0
Deps
2
Size
32 kB
Vulns
0
Weekly
0

@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-blockrun

Configuration

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 x402
Available Providers
BLOCKRUN_WALLET

Provides wallet context to the agent:

// Returns wallet address and USDC balance on Base
// Useful for agents to understand their payment capacity

How It Works

  1. Agent makes an AI request via BLOCKRUN_CHAT action
  2. BlockRun gateway returns 402 Payment Required with price
  3. Plugin automatically signs USDC payment (EIP-712)
  4. Request is retried with payment signature
  5. 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

License

MIT

Keywords