Build AI workflows by orchestrating multiple LLM agents that work together to solve complex problems.
- Multi-LLM Support: OpenAI GPT and Anthropic Claude models with seamless switching
- Three Agent Types: ReAct, Planner-Executor, and Reflexion agents
- Pipeline Architecture: Modular, configurable pipeline with pluggable steps
- Intent Detection: Intelligent analysis of user prompts to determine optimal agent configuration
- Parallel Execution: Concurrent agent execution with proper resource management
- Tool Registry: Extensible tool system with built-in implementations
- REST API: Complete API with validation, error handling, and rate limiting
- Developer Ready: Docker support, health checks, metrics, and graceful shutdown
- Node.js 18+
- OpenAI API key OR Anthropic API key (or both)
- Docker (optional)
git clone <repository-url>
cd nexus-ai
pnpm install
cp .env.example .envEdit .env with your API keys:
# Choose your preferred LLM provider
LLM_PROVIDER=openai # or "anthropic"
# OpenAI Configuration (if using OpenAI)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4
# Anthropic Configuration (if using Claude)
ANTHROPIC_API_KEY=your_anthropic_api_key_here
ANTHROPIC_MODEL=claude-3-sonnet-20240229pnpm run devpnpm run build
pnpm startdocker-compose up -dπ Complete API Documentation: See API.md for comprehensive endpoint documentation with examples.
Base URL: http://localhost:3000/api/v1
POST /orchestrate- Execute multi-agent orchestrationGET /sessions- List orchestration sessionsGET /sessions/{id}- Get session detailsDELETE /sessions/{id}- Cancel running sessionGET /agents/types- List available agent typesGET /tools- List registered toolsPOST /tools/register- Register new toolPOST /tools/{toolName}/execute- Execute toolGET /health- Health checkGET /metrics- System metricsGET /version- Version info
- ReAct Agent: Reasoning and Acting in iterative loops. Think β Act β Observe cycles for complex problem-solving.
- Planner Agent: Creates detailed plans before systematic execution. Best for structured tasks.
- Reflexion Agent: Self-evaluation and iteration to improve response quality through reflection.
The system supports both OpenAI and Anthropic Claude models with seamless switching:
OpenAI:
gpt-4(default)gpt-4-turbogpt-3.5-turbo
Anthropic:
claude-3-sonnet-20240229(default)claude-3-opus-20240229claude-3-haiku-20240307
- Server Default: Set
LLM_PROVIDERenvironment variable - Per-Request: Include
llmProviderin API requests to override default
{
"prompt": "Your request here",
"agentType": "react",
"llmProvider": "anthropic"
}- Auto-Discovery: The system will use available API keys if no provider is specified
Key environment variables:
# Provider Selection
LLM_PROVIDER=openai # or "anthropic"
# API Keys (configure based on provider)
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
# Server Settings
PORT=3000
MAX_PARALLEL_AGENTS=5
MAX_TOKENS=4096
TEMPERATURE=0.7See .env.example for complete configuration options.
The pipeline consists of modular steps that can be configured:
{
"enabledSteps": [
"intent_detection",
"agent_selection",
"tool_assignment",
"parallel_execution",
"result_aggregation",
"quality_check"
],
"parallelExec": true,
"stepConfig": {
"maxAgents": 3,
"qualityThreshold": 0.8
}
}- intent_detection: Analyzes prompt to determine required tools and complexity
- agent_selection: Chooses optimal agents based on detected intent
- tool_assignment: Assigns relevant tools to each agent
- parallel_execution: Runs agents concurrently
- result_aggregation: Combines outputs from multiple agents
- quality_check: Validates and scores results
- reflection: Self-evaluation and potential re-execution
- web_search: Search the internet for information
- calculator: Perform mathematical calculations
- code_executor: Execute code in various languages
- file_reader: Read and analyze files
- data_analyzer: Analyze structured data (CSV, JSON, XML)
pnpm run dev- Start development server with hot reloadpnpm run build- Build TypeScript to JavaScriptpnpm run start- Start production serverpnpm run test- Run test suitepnpm run lint- Lint code with Biomepnpm run format- Format code with Biomepnpm run typecheck- Run TypeScript type checking
src/
βββ agents/ # Agent implementations and orchestrator
βββ api/ # HTTP API routes and handlers
β βββ handlers/ # Request handlers
β βββ middleware/ # Koa middleware
βββ config/ # Configuration management
βββ llm/ # LLM clients (OpenAI, Anthropic) and prompts
β βββ client.ts # Factory and OpenAI client
β βββ anthropicClient.ts # Anthropic Claude client
β βββ prompts.ts # System prompts
βββ pipeline/ # Pipeline framework
βββ tools/ # Tool registry and implementations
βββ types/ # TypeScript types and schemas
βββ server.ts # Main application entry point
- Define the tool schema:
const myTool: Tool = {
name: "my_custom_tool",
description: "Does something useful",
parameters: [
{
name: "input",
type: "string",
description: "Input parameter",
required: true,
},
],
enabled: true,
};- Implement the tool function:
const myToolFunction: ToolFunction = async (params) => {
const { input } = params;
try {
const result = await performOperation(input);
return { success: true, result };
} catch (error) {
return { success: false, result: null, error: error.message };
}
};- Register the tool:
toolRegistry.register(myTool, myToolFunction);GET /api/v1/health- Application health statusGET /api/v1/metrics- Performance metricsGET /api/v1/status- System resource usage
- Total/active/completed/failed sessions
- Average execution time
- Total tokens consumed
- Memory and CPU usage
The API provides structured error responses:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"field": "prompt",
"message": "Prompt is required"
}
],
"timestamp": "2024-01-01T00:00:00Z"
}
}Default rate limiting: 100 requests per minute per IP.
- Helmet.js for security headers
- CORS configuration
- Request validation with Zod schemas
- Rate limiting
- Timeout protection
MIT
# Start server
pnpm start
# Health check
curl http://localhost:3000/api/v1/health
# Test orchestration (requires API keys)
curl -X POST http://localhost:3000/api/v1/orchestrate \
-H "Content-Type: application/json" \
-d '{
"prompt": "What is 2+2?",
"agentType": "react"
}'pnpm test
pnpm run test:coverageπ Complete Testing Guide: See the Testing section in API.md for comprehensive testing examples, scripts, and load testing instructions.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run linting and type checking
- Submit a pull request