BeeAI Framework

0.1.28 · active · verified Sun Apr 19

The BeeAI Framework is a TypeScript-first library (also available in Python) designed for building production-ready multi-agent systems leveraging large language models (LLMs). It provides a modular architecture encompassing core components like agents, backend functionalities for interacting with various AI models (chat, embedding, tool calling), a flexible prompt templating system, diverse memory types, and a robust tool ecosystem. The current stable TypeScript version is `0.1.28`. The project maintains a rapid release cadence, with frequent minor version updates across both TypeScript and Python branches, often incorporating security fixes and dependency updates to keep pace with the fast-evolving AI landscape. Key differentiators include its explicit focus on production readiness, extensive modularity for customizable agent workflows, and broad support for numerous third-party AI SDKs (such as OpenAI, Anthropic, Google Vertex via `@ai-sdk/*`), vector databases (like Qdrant, Milvus), and other LLM-related tools, as evidenced by its comprehensive list of peer dependencies. The project is currently in 'Beta' status, indicating active development and potential for API evolution, but also a commitment to ongoing feature enhancement and stability improvements.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing an agent with a chat model and a custom tool, then running a simple query for calculation.

import "dotenv/config";
import { Agent, ChatModel, Tool, Message } from 'beeai-framework';

// Define a simple tool that the agent can use
class MyCalculatorTool extends Tool {
  constructor() {
    super({
      name: "calculator",
      description: "A simple calculator tool that can add two numbers.",
      parameters: {
        type: "object",
        properties: {
          a: { type: "number", description: "The first number" },
          b: { type: "number", description: "The second number" }
        },
        required: ["a", "b"]
      }
    });
  }

  async execute(params: { a: number; b: number }): Promise<any> {
    return { result: params.a + params.b };
  }
}

async function runAgent() {
  // Initialize a chat model (e.g., using OpenAI via @ai-sdk/openai peer dep)
  // Ensure OPENAI_API_KEY is set in your .env file
  const chatModel = new ChatModel({
    model: process.env.OPENAI_MODEL ?? 'gpt-4o',
    provider: 'openai' // This would depend on specific @ai-sdk integration
  });

  // Instantiate the agent with the chat model and available tools
  const agent = new Agent({
    model: chatModel,
    tools: [new MyCalculatorTool()] // Add our custom tool
    // Other agent configurations like memory, system prompts etc.
  });

  console.log("Agent initialized. Asking it to perform a calculation...");

  // Interact with the agent
  const response = await agent.run([
    { role: "user", content: "What is 5 plus 3?" }
  ]);

  console.log("Agent's response:", response.messages[response.messages.length - 1].content);
}

runAgent().catch(console.error);

view raw JSON →