Quick start
Learn the basics of AgentKit in a few minutes.
In this tutorial you will create an Agent and run it within a Network with AgentKit.
Install AgentKit
Within an existing project, Install AgentKit from npm:
You can always find the latest release version on npm.
Create an agent
To start, we’ll create our first “Agent.” An “Agent” is an entity that has a specific role to answer questions or perform tasks (See “tools” further below).
To start, let’s create a new file, index.ts
. Using the createAgent
constructor, give your agent a name
, a description
and it’s initial system
prompt. The name
and description
properties are used to allow the LLM to determine which Agent to call.
You’ll also specify which model
you want the agent to use. Here we’ll use Anthropic’s Claude 3.5 Haiku model. (Model reference)
Your agent can be whatever you want, but in this quick start, we’ll create a Postgres database administrator agent:
We’ll also have to set any provider API keys as environment variables.
Test our agent
To test our agent, we’ll use the Inngest dev server to allow us to visually debug our agents. Using npx
, we’ll start the server and point it to our AgentKit server:
Now, open the dev server and select the function’s tab (http://localhost:8288/functions
) and click the “Invoke” button:
In the Invoke function modal, specify the input prompt for your agent and click the “Invoke function” button.
You’ll be redirected to watch the agent run and view the output:
Creating a Network
A key benefit of AgentKit is the ability to create a system of agents called a “Network.” “Networks” are used to create stateful workflows with one or more Agents that can call tools.
We’ll start by creating a second “Database Security” Agent:
We can now create a network combining our “Database Administrator” and “Database Security” Agents, which enables us to answer more complex questions.
Create a network using the createNetwork
constructor. Define a name
include our agent from the previous step in the agents
array. You must also configure the defaultModel
for which the “router” will use to determine which agent to call.
Test our network
We’ll use the same approach to test our network as we did above to test our network, with the Inngest dev server’s.
Networks are powerful as they include “routing agents” that can coordinate between a system of multiple agents, enabling networks to complete more complex tasks.
Our network enables us to answer more complex or multiple questions such as:
The network will now run through the Agents to answer the questions:
And provide the final answer in two parts:
Next steps
Congratulations! You’ve now created your first AgentKit Agents and Network.
In this guide you’ve learned that:
- Agents are the building blocks of AgentKit. They are used to call a single model to answer specific questions or perform tasks.
- Networks are a group of agents that can work together to achieve more complex goals.
The following guides will help you to build more advanced AI Agents: