Installation
Welcome to AgentB! Setting up is quick and easy.
Prerequisites
Node.js: Version 18.x or later is recommended.
Package Manager: npm (usually comes with Node.js) or yarn.
Install AgentB Packages
You'll typically need two packages:
@ulifeai/agentb: The core framework for building and running your agents.@ulifeai/agentb-ui: (Optional) Pre-built React components for a chat interface.
Open your project terminal and run:
# Using npm
npm install @ulifeai/agentb @ulifeai/agentb-ui
# Using yarn
yarn add @ulifeai/agentb @ulifeai/agentb-uiIf you don't need the UI components immediately, you can just install the core package:
# Using npm
npm install @ulifeai/agentb
# Using yarn
yarn add @ulifeai/agentbEnvironment Variables (Especially for OpenAI)
Most AI agents connect to a Large Language Model (LLM) provider, like OpenAI. AgentB makes this easy but requires your API key.
Install
dotenv: This helper loads environment variables from a.envfile.Create a
.envfile: In the root directory of your project, create a file named.envand add your OpenAI API key:Replace
sk-your_openai_api_key_herewith your actual key.Load
dotenvin your app: At the very beginning of your main application file (e.g.,index.tsorserver.ts), add:
This ensures your OPENAI_API_KEY is available to AgentB when it initializes the LLM client.
TypeScript Setup (Recommended)
AgentB is written in TypeScript and works best in a TypeScript project. If you're starting a new project or adding AgentB to an existing one, here's a typical tsconfig.json:
Adjust target, module, rootDir, and outDir to fit your project structure.
You're all set! Now you're ready to build your first agent in the next tutorial.
Last updated