Page cover

πŸ’»Initialization & Basic Setup

Project Setup

Refer this link to open up the sample repository. The project setup is as follows -

  • First, create a new directory and initialize a new npm project:

mkdir cdp-agentkit
cd cdp-agentkit
npm init -y
  • Install TypeScript as a dev dependency:

npm install typescript --save-dev
  • Initialize TypeScript configuration:

npx tsc --init
  • Paste the below package.json file in your local repository & install it with npm install:

{
  "name": "cdp-agentkit",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node chatbot.js",
    "build": "tsc",
    "dev": "nodemon chatbot.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@coinbase/cdp-agentkit-core": "^0.0.14",
    "@coinbase/cdp-langchain": "^0.0.15",
    "@langchain/langgraph": "^0.2.21",
    "@langchain/openai": "^0.3.14",
    "@langchain/core": "^0.3.19",
    "dotenv": "^16.4.5",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@types/express": "^5.0.0",
    "@types/node": "^22.10.10",
    "nodemon": "^3.1.9",
    "ts-node": "^10.9.2",
    "typescript": "^5.7.3"
  }
}
  • Create .env file and paste the below keys into it:

  • Create a file called chatbot.ts, which we'll be using later on.

API Credentials

Coinbase CDP API Key

  1. Go to CDP Portal.

  2. Generate an API key and save both the key name and private key.

OpenAI API Key

  1. Go to OpenAI Platform (AgentKit is model-agnostic, but we'll use OpenAI for this guide).

  2. Sign up or log in to your account.

  3. Navigate to API keys section.

  4. Create a new API key.

  5. Fund your account with at least $1-2 for testing.

Creating Your First Agent

Create achatbot.ts file, which contains the logic of your agent:

Adding Agent Functionality

Extend your agent with chat capabilities. To add more functionality, see the Add Custom Capabilities guide.

Last updated