AxCrew

Getting Started

Learn how to install and set up AxCrew in your project

What is AxCrew?

AxCrew is a framework for building and managing crews of AI agents. It is built on top of AxLLM, a powerful TypeScript framework for building and managing LLM agents.

Installation

Install the AxCrew package using npm:

npm install @amitdeshmukh/ax-crew

Since AxLLM is a peer dependency, you'll need to install it separately:

npm install @ax-llm/ax

Requirements: Node.js >= 21

Environment Setup

Create a .env file in your project root with the API keys for the AI providers you intend to use:

# OpenAI
OPENAI_API_KEY=your_openai_key
 
# Anthropic
ANTHROPIC_API_KEY=your_anthropic_key
 
# Google Gemini
GEMINI_API_KEY=your_gemini_key
 
# Add other provider keys as needed

For a complete list of supported environment variables, check the .env.example file in the repository.

Basic Setup

Here's a minimal example of how to set up an AxCrew instance with a single agent:

import { AxCrew } from '@amitdeshmukh/ax-crew';
 
// Create the configuration object
const config = {
  crew: [
    {
      name: "Manager",
      description: "Completes a task or responds to a question",
      signature: "task:string \"task or question from the user\" -> reply:string \"detailed response addressing the user's task\"",
      provider: "openai",
      providerKeyName: "OPENAI_API_KEY", 
      ai: {
        model: "gpt-4o-mini",
        temperature: 0.7
      }
    }
  ]
};
 
// Create a new instance of AxCrew
const crew = new AxCrew(config);
 
// Initialize all agents
await crew.addAllAgents();
 
// Get the Manager agent
const manager = crew.agents.get("Manager");
 
// Use the agent
const { reply } = await manager.forward({ task: "Create a plan for building a website" });
console.log(reply);

Using a Configuration File

For larger projects, you might prefer to keep your configuration in a separate JSON file:

agentConfig.json
{
  "crew": [
    {
      "name": "Manager",
      "description": "Completes a task or responds to a question",
      "signature": "task:string \"task or question from the user\" -> reply:string \"detailed response addressing the user's task\"",
      "provider": "openai",
      "providerKeyName": "OPENAI_API_KEY",
      "ai": {
        "model": "gpt-4o-mini",
        "temperature": 0.7
      }
    }
  ]
}

You can then load the configuration from the file:

import { AxCrew } from '@amitdeshmukh/ax-crew';
 
// Create a new instance of AxCrew using a config file
const configFilePath = './agentConfig.json';
const crew = new AxCrew(configFilePath);
 
// Initialize all agents
await crew.addAllAgents();

Next Steps

On this page