Coinbase Agentkit Extension - Vercel AI SDK
This package is an extension used to easily plug AgentKit into AI SDK by Vercel.
Installation
For a single command to install all necessary dependencies, run:
npm install @coinbase/agentkit-vercel-ai-sdk @coinbase/agentkit ai @ai-sdk/openai
To break it down, this package is:
npm install @coinbase/agentkit-vercel-ai-sdk
This package is used alongside AgentKit and AI SDK, so these will need to be installed as well.
npm install @coinbase/agentkit ai
Finally, install the model provider you want to use. For example, to use OpenAI, install the @ai-sdk/openai
package. See here for a list of supported model providers.
npm install @ai-sdk/openai
Usage
The main export of this package is the getVercelAITools
function. This function takes an AgentKit instance and returns an object containing the tools for the AgentKit agent. This object can then be passed to AI SDK.
Here's a snippet of code that shows how to use the getVercelAITools
function to get the tools for the AgentKit agent.
chatbot.ts
import { getVercelAITools } from "@coinbase/agentkit-vercel-ai-sdk";
import { AgentKit } from "@coinbase/agentkit";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const agentKit = await AgentKit.from({
cdpApiKeyName: process.env.CDP_API_KEY_NAME,
cdpApiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY,
});
const tools = await getVercelAITools(agentKit);
const { text } = await generateText({
model: openai("gpt-4o-mini"),
system: "You are an onchain AI assistant with access to a wallet.",
prompt: "Print wallet details",
tools,
maxSteps: 10,
});
console.log(text);
For a full example, see the AgentKit AI SDK Chatbot Example.
Contributing
We welcome contributions of all kinds! Please see our Contributing Guide for detailed setup instructions and contribution guidelines.