π»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 -yInstall TypeScript as a dev dependency:
npm install typescript --save-devInitialize TypeScript configuration:
npx tsc --initPaste the below
package.jsonfile in your local repository & install it withnpm 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
.envfile 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
Go to CDP Portal.
Generate an API key and save both the key name and private key.
OpenAI API Key
Go to OpenAI Platform (AgentKit is model-agnostic, but we'll use OpenAI for this guide).
Sign up or log in to your account.
Navigate to API keys section.
Create a new API key.
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
