BlockRun

AgentKit Integration

Use BlockRun with Coinbase AgentKit for wallet-enabled AI agents — AgentKit holds assets and executes on-chain actions, BlockRun pays for the intelligence.

Community integration

BlockRun's primary paths are Franklin, the BlockRun MCP, and the SDKs. Framework integrations like this one are community-maintained.

AgentKit is Coinbase's framework for building AI agents with wallet capabilities. Combined with BlockRun, your agents can both hold assets AND pay for AI intelligence.

Overview

AgentKit provides:

  • Wallet management (CDP server wallets, or a local key via EthAccountWalletProvider)
  • Action providers (wallet, ERC-20, swaps, DeFi protocols, …) exposed as agent tools
  • Framework extensions (coinbase-agentkit-langchain, …)

BlockRun adds:

  • 78 chat models (95 in the full catalog)
  • Pay-per-request intelligence
  • No API key management

Setup

1
Install both packages
pip install coinbase-agentkit blockrun-llm eth-account

coinbase-agentkit 0.7.x requires Python 3.10+.

2
Initialize AgentKit and BlockRun on one key

The simplest setup shares a single Base private key: AgentKit signs transactions with it, BlockRun signs x402 payments with it. (Use a separate BLOCKRUN_WALLET_KEY if you want AI spend accounted apart from trading capital.)

import os
from eth_account import Account
from coinbase_agentkit import (
    AgentKit,
    AgentKitConfig,
    EthAccountWalletProvider,
    EthAccountWalletProviderConfig,
)
from blockrun_llm import LLMClient

private_key = os.environ["BLOCKRUN_WALLET_KEY"]   # 0x-prefixed

# AgentKit — local key on Base mainnet (chain 8453)
wallet_provider = EthAccountWalletProvider(
    config=EthAccountWalletProviderConfig(
        account=Account.from_key(private_key),
        chain_id="8453",
    )
)
agent_kit = AgentKit(AgentKitConfig(wallet_provider=wallet_provider))

# BlockRun — same key pays for AI
blockrun = LLMClient(private_key=private_key)

Prefer CDP-managed keys? Construct CdpEvmWalletProvider with your CDP API credentials instead and keep BlockRun on its own local key — CDP server wallets do not expose a private key for the SDK to sign with.

Usage

AI-Powered Trading Agent

# Get AI analysis of what the wallet holds
address = wallet_provider.get_address()
balance = wallet_provider.get_balance()   # native balance, in wei

analysis = blockrun.chat(
    "openai/gpt-5.4",
    f"Wallet {address} holds {balance} wei of ETH on Base. "
    "Should it rotate into USDC? Answer BUY, SELL or HOLD with one reason."
)

# Execute through AgentKit's action providers
actions = {a.name: a for a in agent_kit.get_actions()}
print(sorted(actions))          # e.g. WalletActionProvider_native_transfer, ERC20ActionProvider_transfer, ...

if "SELL" in analysis.upper():
    # pick the swap/transfer action you have enabled and invoke it with its schema
    ...

Multi-Model Decision Making

# Get opinions from multiple models
gpt_opinion = blockrun.chat("openai/gpt-5.4", market_question)
claude_opinion = blockrun.chat("anthropic/claude-sonnet-4.6", market_question)
deepseek_opinion = blockrun.chat("deepseek/deepseek-chat", market_question)

# Aggregate and decide
final_decision = blockrun.chat(
    "openai/gpt-5.4",
    f"Synthesize these opinions: {gpt_opinion}, {claude_opinion}, {deepseek_opinion}"
)

AgentKit tools + BlockRun as the model (LangChain)

AgentKit's LangChain extension turns every action provider into a tool. Run the BlockRun LiteLLM sidecar (Path 1 on the LangChain page) and point ChatOpenAI at it, and the whole ReAct loop — reasoning and on-chain execution — pays per request with no OpenAI key:

pip install coinbase-agentkit-langchain langchain-openai langgraph 'blockrun-litellm[proxy]'
export BLOCKRUN_WALLET_KEY=0x...
blockrun-litellm-proxy --port 4001 &
from coinbase_agentkit_langchain import get_langchain_tools
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI

tools = get_langchain_tools(agent_kit)
llm = ChatOpenAI(model="openai/gpt-5.4", base_url="http://127.0.0.1:4001/v1", api_key="dummy")

agent = create_react_agent(llm, tools)
result = agent.invoke({"messages": [("human", "What is my wallet balance?")]})
print(result["messages"][-1].content)

Wallet Architecture

┌─────────────────────────────────────────────────┐
│                 Your Agent                       │
├─────────────────────┬───────────────────────────┤
│    AgentKit Wallet  │     BlockRun Wallet       │
│    (Trading/Assets) │   (AI Payments)           │
│                     │                           │
│  • Hold ETH, USDC   │  • Pay for GPT-5.4        │
│  • Execute swaps    │  • Pay for Claude         │
│  • Transfer assets  │  • Pay for images         │
└─────────────────────┴───────────────────────────┘

You can use the same wallet for both, or separate wallets for accounting.

Example: Autonomous Trading Bot

import asyncio
import os
from eth_account import Account
from coinbase_agentkit import (
    AgentKit, AgentKitConfig, EthAccountWalletProvider, EthAccountWalletProviderConfig,
)
from blockrun_llm import LLMClient

class TradingBot:
    def __init__(self):
        key = os.environ["BLOCKRUN_WALLET_KEY"]
        self.wallet = EthAccountWalletProvider(
            config=EthAccountWalletProviderConfig(account=Account.from_key(key), chain_id="8453")
        )
        self.agent_kit = AgentKit(AgentKitConfig(wallet_provider=self.wallet))
        self.actions = {a.name: a for a in self.agent_kit.get_actions()}
        self.blockrun = LLMClient(private_key=key)

    async def analyze_market(self, asset: str) -> dict:
        """Get AI analysis of an asset."""
        prompt = f"""
        Analyze {asset} for trading:
        1. Technical indicators
        2. Sentiment
        3. Risk assessment
        4. Recommendation (buy/hold/sell)
        """

        response = self.blockrun.chat("openai/gpt-5.4", prompt)
        return {"analysis": response, "asset": asset}

    async def execute_trade(self, decision: dict):
        """Execute trade based on AI decision via an AgentKit action."""
        action = self.actions.get(decision["action_name"])
        if action:
            action.invoke(decision["args"])

    async def run(self):
        """Main trading loop."""
        while True:
            analysis = await self.analyze_market("ETH")
            # Parse analysis into {"action_name": ..., "args": {...}} and execute
            await asyncio.sleep(3600)  # Check hourly

# Run the bot
bot = TradingBot()
asyncio.run(bot.run())

Cost Optimization

AgentKit handles gas fees for transactions. BlockRun handles AI costs.

# Use cheap models for routine analysis
routine_analysis = blockrun.chat(
    "deepseek/deepseek-chat",  # $0.14/M input tokens
    "Quick market check..."
)

# Use premium models for important decisions
important_decision = blockrun.chat(
    "openai/gpt-5.4",  # $2.50/M input tokens
    "Should I execute this $10k trade?"
)

# Or let the bundled router decide per request
routed = blockrun.smart_chat("Quick market check...")

Security

AspectAgentKitBlockRun
Key storageCDP server wallet or local eth_account keyLocal (BLOCKRUN_WALLET_KEY or ~/.blockrun/.session)
TransactionsOn-chain signedEIP-712 x402 signatures
VerificationBasescanBasescan

Links

What's next?