Getting Started with AxCrew
What is AxCrew?
Section titled “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
Section titled “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
Environment Setup
Section titled “Environment Setup”Create a .env
file in your project root with the API keys for the AI providers you intend to use:
# OpenAIOPENAI_API_KEY=your_openai_key
# AnthropicANTHROPIC_API_KEY=your_anthropic_key
# Google GeminiGEMINI_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
Section titled “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 objectconst 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 AxCrewconst crew = new AxCrew(config);
// Initialize all agentsawait crew.addAllAgents();
// Get the Planner agentconst manager = crew.agents.get("Manager");
// Use the agentconst { reply } = await manager.forward({ task: "Create a plan for building a website" });console.log(reply);
Using a Configuration File
Section titled “Using a Configuration File”For larger projects, you might prefer to keep your configuration in a separate JSON file:
{ "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 fileconst configFilePath = './agentConfig.json';const crew = new AxCrew(configFilePath);
// Initialize all agentsawait crew.addAllAgents();
Next Steps
Section titled “Next Steps”- Learn how to configure agents in detail
- Learn more about Crew Configuration
- Integrate MCP Servers
- Explore creating custom functions to enhance your agents
- See how to manage state across agents in a crew
- Check out the examples for more use cases