Skip to main content
AgentKit is Coinbase’s developer toolkit for building AI agents that can interact with onchain services. This guide gets you from zero to a running agent that can check balances and send transactions on Base Sepolia. What you’ll need:
  • Node 18+ (TypeScript) or Python 3.10+ (Python)
  • A CDP API key (free to create)
  • An LLM API key (OpenAI or compatible)

Install AgentKit

Terminal
npm create onchain-agent@latest
cd my-agent
cp .env-local .env
Install dependencies:
Terminal
npm install

Configure your API keys

Open .env and fill in your credentials:
.env
CDP_API_KEY_NAME=your_cdp_key_name
CDP_API_KEY_PRIVATE_KEY=your_cdp_private_key
OPENAI_API_KEY=your_openai_key
NETWORK_ID=base-sepolia
Get your CDP API key from the CDP Portal. The key grants access to Coinbase’s wallet infrastructure — your agent never touches private keys directly.

Create a wallet

AgentKit creates and manages a wallet through the CDP API. On first run, the scaffolded project automatically creates a wallet and saves it locally:
index.ts
import { AgentKit } from "@coinbase/agentkit";

const agentkit = await AgentKit.from({
  cdpApiKeyName: process.env.CDP_API_KEY_NAME!,
  cdpApiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY!,
  networkId: "base-sepolia",
});

const wallet = agentkit.wallet;
console.log("Wallet address:", wallet.getDefaultAddress());

Check your balance

const balances = await wallet.listBalances();
console.log("Balances:", balances);
Fund your wallet on Base Sepolia using the Base faucet, then re-run the balance check to confirm receipt.

Send a transaction

const transfer = await wallet.createTransfer({
  amount: 0.001,
  assetId: "eth",
  destination: "0xRecipientAddress",
});

await transfer.wait();
console.log("Transaction hash:", transfer.getTransactionHash());

Run the agent

Start the interactive chatbot that the scaffold provides:
Terminal
npm run start

Next steps

Wallet setup

Learn about CDP Agentic Wallet options and production configuration.

x402 payments

Let your agent pay for API access per-request using stablecoins.

LangChain integration

Combine AgentKit with LangChain for more complex agent workflows.

Identity with SIWA

Register and verify your agent’s identity onchain.