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:

  1. @ulifeai/agentb: The core framework for building and running your agents.

  2. @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-ui

If 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/agentb

Environment 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.

  1. Install dotenv: This helper loads environment variables from a .env file.

  2. Create a .env file: In the root directory of your project, create a file named .env and add your OpenAI API key:

    Replace sk-your_openai_api_key_here with your actual key.

  3. Load dotenv in your app: At the very beginning of your main application file (e.g., index.ts or server.ts), add:

This ensures your OPENAI_API_KEY is available to AgentB when it initializes the LLM client.

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