Skip to content

Quickstart

Prerequisites

  • Python 3.11+
  • Redis 7.0+ (for state management and message passing)
  • OpenAI API key or Anthropic API key (for LLM-powered agents)

Installation

Option 1: Docker (Recommended)

# Clone the repository
git clone https://github.com/nasirquant/fractal-neural-engine
cd fractal-neural-engine

# Start all services
docker-compose up -d

# Verify the API is running
curl http://localhost:8000/health

Option 2: Local Development

# Clone the repository
git clone https://github.com/nasirquant/fractal-neural-engine
cd fractal-neural-engine

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Copy and configure environment
cp .env.example .env
# Edit .env with your API keys

# Start Redis
docker run -d -p 6379:6379 redis:7-alpine

# Run the API server
python main.py

Your First Epoch

An epoch is a complete simulation run with a defined objective, agent count, and tick limit.

curl -X POST http://localhost:8000/epochs \
  -H "Content-Type: application/json" \
  -d '{
    "num_agents": 10,
    "max_ticks": 100,
    "global_objective": "minimize_loss",
    "convergence_threshold": 0.01
  }'

Response:

{
  "epoch_id": "ep_abc123",
  "status": "running",
  "num_agents": 10,
  "max_ticks": 100,
  "global_objective": "minimize_loss",
  "created_at": "2024-01-15T10:30:00Z"
}

Monitor Progress

WebSocket Streaming (Real-time)

# Install websocat for testing
# Then connect to the epoch stream
websocat ws://localhost:8000/epochs/ep_abc123/stream

REST Polling

# Check epoch status
curl http://localhost:8000/epochs/ep_abc123

# Get agent states
curl http://localhost:8000/epochs/ep_abc123/agents

# Get loss history
curl http://localhost:8000/epochs/ep_abc123/loss-history

Environment Variables

VariableRequiredDefaultDescription
OPENAI_API_KEYYes*-OpenAI API key for GPT models
ANTHROPIC_API_KEYYes*-Anthropic API key for Claude models
REDIS_URLNoredis://localhost:6379Redis connection string
FNSE_LOG_LEVELNoINFOLogging level (DEBUG, INFO, WARNING, ERROR)
FNSE_MAX_CONCURRENT_EPOCHSNo5Maximum parallel epochs
FNSE_DEFAULT_MODELNogpt-4-turboDefault LLM model for agents

*At least one LLM API key is required.

Next Steps