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.
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.
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 Manager agentconst manager = crew.agents.get("Manager");// Use the agentconst { reply } = await manager.forward({ task: "Create a plan for building a website" });console.log(reply);
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 fileconst configFilePath = './agentConfig.json';const crew = new AxCrew(configFilePath);// Initialize all agentsawait crew.addAllAgents();