ProjectsAI & Agents

Crawllama

CrawlLama ๐Ÿฆ™ is an local AI agent that answers questions via Ollama and integrates web- and RAG-based research.

110
Stars
4
Forks
Oct 2025
Created
15 days ago
Last push

Readme

This readme embeds 10 images from GitHub. They only load when you click below.

CrawlLama Logo CrawlLama

Python Version Platform Platform License Status Ask DeepWiki

Documentation | Quickstart | API Guide | Adaptive Hops | Security | Changelog

Project Website

AI Research Agent with OSINT and Multi-Hop Reasoning Current Version: 1.4.12 (Logic Fixes & Refactor) New in 1.4.8: Company Intelligence Developer Documentation

Table of Contents


Overview

A locally-capable AI research agent with advanced intelligence features (local processing requires a local LLM backend such as Ollama; cloud-based LLM APIs like Claude or OpenAI are not local):

  • OSINT module: email, phone, and IP intelligence; social media analysis; advanced search operators
  • Multi-hop reasoning using LangGraph for complex queries
  • Adaptive agent selection based on query complexity (low/mid/high)
  • REST API with FastAPI for integration
  • Plugin system for extensibility
  • Performance optimizations with large context support and asynchronous execution

Features

Core features

  • Adaptive agent hopping system โ€“ Automatic agent selection based on query complexity (low/mid/high), confidence-based escalation, and resource-aware adaptation (NEW v1.4.4)
  • UI settings for adaptive report โ€“ Toggle the Adaptive Intelligence Report directly from the interactive settings menu (NEW v1.4.4)
  • Multi-hop reasoning โ€“ LangGraph-based agent with a multi-step workflow (Router โ†’ Search โ†’ Analyze โ†’ Follow-Up โ†’ Synthesize โ†’ Critique)
  • Restart command โ€“ Restart the agent without exiting the program
  • Parallelization โ€“ Multi-aspect searches using thread pools for improved performance
  • Performance optimizations โ€“ 16k context support for RTX 3080; async and parallel processing
  • Multi-source web search โ€“ DuckDuckGo, Brave Search, Serper API with fallback
  • Wikipedia integration โ€“ Dedicated Wikipedia search (German/English)
  • Advanced RAG system โ€“ Batch processing, multi-query and hybrid search (RAG Analysis)
  • Intelligent caching โ€“ TTL-based with hash keys, LRU eviction, and a configurable max size (500MB)
  • Tool orchestration โ€“ Automatic tool selection via LLM
  • Interactive settings menu โ€“ Live configuration of LLM, search, RAG and OSINT
  • Context usage tracker โ€“ Real-time token usage monitoring using tiktoken
  • Health monitoring dashboard โ€“ Interactive system monitoring with a rich UI
  • Lazy-loading โ€“ On-demand loading for tools and plugins
  • Async operations โ€“ Parallel HTTP requests with aiohttp
  • Resource monitoring โ€“ RAM usage, performance tracking, and automated garbage collection
  • FastAPI REST API โ€“ 40+ endpoints with auto-documentation (/query, /plugins, /stats, /health) (see app.py)
  • Plugin system โ€“ Dynamic loading and unloading of plugins
  • Enhanced CLI โ€“ Rich formatting and Markdown output
  • Setup scripts โ€“ setup.bat, setup.sh with auto-configuration
  • Optional cloud LLM support (note: using cloud APIs such as Claude or OpenAI means data is sent to external servers and is not processed locally)

OSINT features

  • Advanced search operators โ€“ site:, inurl:, intext:, filetype:, email:, phone:, ip:
  • Email intelligence โ€“ Validation, MX records, disposable detection, and variations
  • Phone intelligence โ€“ Validation, carrier lookup, country detection, and formatting
  • Persistent memory store โ€“ Survives /clear; stores emails, phones, IPs, usernames, domains and notes
  • Memory store CRUD โ€“ Full CRUD functionality with forget command
  • Batch processing โ€“ Analyze multiple emails or phones simultaneously with summary statistics
  • IP intelligence โ€“ IPv4/IPv6 analysis, geolocation, ISP info, security reputation and VPN detection
  • Social intelligence โ€“ Supports 12 platforms (GitHub, LinkedIn, Twitter, Instagram, Facebook, YouTube, Reddit, Pinterest, TikTok, Twitch, Telegram, Discord)
  • AI query enhancement โ€“ Query variations, operator suggestions, entity detection and auto-type detection
  • Compliance module โ€“ Rate limiting, terms of use, audit logging and robots.txt compliance
  • Privacy protection โ€“ Ethical scraping, usage tracking; no API keys required
  • Safesearch quality filter โ€“ Configurable result quality (off/moderate/strict)

Security & performance

  • Code quality โ€“ Refactored, focused methods for better maintainability
  • Accurate token counting โ€“ tiktoken integration for precise token counts
  • Intelligent retry logic โ€“ Tenacity-based retries with exponential backoff
  • Rate limiting โ€“ 1 request/second and robots.txt checks
  • Fallback system โ€“ Automatic fallbacks for API failures
  • Secure config โ€“ Encrypted API key storage
  • Output validation โ€“ Sanitization of LLM outputs
  • Domain blacklist โ€“ Protection against unwanted domains
  • RTX 3080 optimization โ€“ 16k context support (qwen3:8b), increased cache sizes
  • Windows console compatibility โ€“ ASCII output and UTF-8 encoding for robust CLI experience (NEW v1.4.4)
  • Clear-all command โ€“ Instantly reset session, cache, and memory from the CLI (NEW v1.4.4)
  • Tor mode โ€“ Optionally route all outbound web traffic (crawling, search, OSINT, cloud LLM calls) through a Tor SOCKS5 proxy with a fail-fast startup check and DNS-leak prevention (see Tor Mode)
  • Local operation โ€“ LLM processing happens locally only when using a local backend such as Ollama. When using cloud-based APIs (e.g., Claude, OpenAI), queries are sent to external servers and are not processed locally. Web searches and data fetching always require internet access regardless of the LLM backend. For enhanced privacy, we recommend using a VPN or proxy.

Images

Health Dashboard - Live System Monitor

Real-time monitoring with rich terminal UI displaying system metrics, component health, and performance tracking.

Health Dashboard

Interactive CLI Interface

CrawlLama's adaptive intelligence system with automatic agent selection and interactive commands.

CLI Interface

Test Dashboard GUI

Tkinter-based test management interface with automatic test detection and real-time progress tracking.

Test Dashboard

Quickstart

Installation

Important โ€” Keep dependencies up to date: Dependencies are managed with uv via pyproject.toml and uv.lock. If you are using a pre-built / downloaded package release (zip/tar), always install dependencies from the latest pyproject.toml/uv.lock in this repository rather than any bundled copy. Package versions are updated regularly to address security vulnerabilities and compatibility issues.

uv sync

Always fetch the current files from the repository before installing to ensure you have the latest, secure package versions.

Windows:

  1. Download Crawllama
  2. Extract to any folder (e.g., C:\Crawllama)
  3. Install Ollama from ollama.ai/download
  4. Start Ollama and load model:
ollama serve
ollama pull qwen3:8b
  1. In the Crawllama folder:
setup.bat
run.bat

Linux/macOS:

  1. Download and extract:
wget https://github.com/arn-c0de/Crawllama/archive/refs/heads/main.zip
unzip main.zip
cd Crawllama-main
  1. Install Ollama:
curl -fsSL https://ollama.ai/install.sh | sh
ollama serve &
ollama pull qwen3:8b
  1. Setup and start:
chmod +x setup.sh run.sh
./setup.sh
./run.sh

Option 1: Setup Scripts (Recommended for Git Installation)

Windows:

setup.bat

Linux/macOS:

chmod +x setup.sh
./setup.sh

Note: After the initial setup, you must select at least one LLM model during setup. If a model is already installed, you can skip this stepโ€”otherwise, selection is required to avoid errors in the test program.

The setup script:

  • Checks Python version (3.11+)
  • Creates virtual environment
  • Lets you select features and LLM models to install (core is always installed)
  • Installs all selected dependencies
  • Creates necessary directories
  • Copies .env.example to .env
  • Checks Ollama status

Note for initial installation:

When running uv sync for the first time, installing all dependenciesโ€”especially packages like chromadb and its ONNX runtime and scientific librariesโ€”may take 5โ€“10 minutes (or longer, depending on connection and hardware). Please wait until the process completes; afterward, the virtual environment is ready for use.

Note on disk space: After installation (including venv), the project typically requires about 1.2โ€“1.5 GB of free disk space (v1.4: ~1.23 GB). This value may vary significantly depending on the operating system, Python packages (e.g., larger PyTorch/CUDA wheels), and additional models. Plan for ample additional space if storage is limited.

Model download sizes (approximate):

  • qwen3:4b โ€” ~2โ€“4 GB (depending on format/quantization)
  • qwen3:8b โ€” ~8โ€“12 GB
  • deepseek-r1:8b โ€” ~6โ€“10 GB
  • llama3:7b โ€” ~6โ€“9 GB
  • mistral:7b โ€” ~4โ€“8 GB
  • phi3:14b โ€” ~12โ€“20+ GB

Note: Model sizes vary significantly depending on the provider, format (FP16, INT8 quantization, etc.), and additional assets. Quantized models (e.g., INT8) can significantly reduce size, while FP32/FP16 or models with additional tokenizer/vocab files require more space. Plan for sufficient additional storage if using larger models or multiple models simultaneously.

Option 2: Manual Installation

Prerequisites:

Windows - Step by Step:

# 1. Clone repository
git clone https://github.com/arn-c0de/Crawllama.git
cd Crawllama

# 2. Install dependencies with uv (creates the virtual environment, takes 5-10 min)
uv sync

# 3. Create directories
mkdir data\cache data\embeddings data\history logs plugins

# 4. Configuration
copy .env.example .env
notepad .env # Optional: Add API keys

# 5. Start Ollama (separate terminal)
ollama serve

# 6. Load model (separate terminal)
ollama pull qwen3:8b

# 7. Start Crawllama (interactive mode starts when no question is given)
uv run python main.py

Linux/macOS - Step by Step:

# 1. Clone repository
git clone https://github.com/arn-c0de/Crawllama.git
cd Crawllama

# 2. Install dependencies with uv (creates the virtual environment, takes 5-10 min)
uv sync

# 3. Create directories
mkdir -p data/cache data/embeddings data/history logs plugins

# 4. Configuration
cp .env.example .env
nano .env # Optional: Add API keys

# 5. Install and start Ollama
curl -fsSL https://ollama.ai/install.sh | sh
ollama serve &

# 6. Load model
ollama pull qwen3:8b

# 7. Start Crawllama (interactive mode starts when no question is given)
uv run python main.py

Troubleshooting Installation:

Problem Solution
python not found Install Python 3.11+: python.org
pip install fails Run python -m pip install --upgrade pip
ollama: command not found Install Ollama: ollama.ai/download
Connection refused (Ollama) Start Ollama: ollama serve
ModuleNotFoundError Activate virtual environment: venv\Scripts\activate (Win) or source venv/bin/activate (Linux)
Disk space full Ensure at least 5 GB free for venv + model

Option 3: Git Clone (Quick Installation)

# 1. Clone
git clone https://github.com/arn-c0de/Crawllama.git
cd Crawllama

# 2. Dependencies (uv creates the virtual environment)
uv sync

# 3. Directories
mkdir -p data/cache data/embeddings data/history logs plugins

# 4. Config
cp .env.example .env

Ollama Setup

# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh # Linux/macOS
# or from https://ollama.ai/download # Windows

# Start Ollama
ollama serve

# Load model
ollama pull qwen3:8b
# Alternative: qwen3:4b, deepseek-r1:8b, llama3:7b, mistral

Usage

Note: The first start may take significantly longer than subsequent starts! Initialization, dependency installation, and model downloads may take several minutes, depending on hardware and internet connection. After the first successful start, all subsequent starts are significantly faster.

1. CLI - Interactive Mode

# Interactive mode starts automatically when no question is given
python main.py

# Or with setup script
run.bat # Windows
./run.sh # Linux/macOS
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ CrawlLama - Local Search and Response Agent โ”‚
โ”‚ Commands (slash-prefixed): โ”‚
โ”‚ /clear - Reset session (history + cache) โ”‚
โ”‚ /clear-cache - Clear cache only โ”‚
โ”‚ /save - Manually save session โ”‚
โ”‚ /load - Reload session โ”‚
โ”‚ /stats - Display statistics โ”‚
โ”‚ /status - Show context usage โ”‚
โ”‚ /settings - Show/edit settings โ”‚
โ”‚ /restart - Restart agent (reload config) โ”‚
โ”‚ /exit, /quit - Exit โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

 What is Machine Learning?

New Commands:

  • /status - Shows token usage and available context capacity
/status

Context Usage Tracker
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Source โ”ƒ Tokens โ”ƒ Share โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Conversation โ”‚ 850 โ”‚ 8.5% โ”‚
โ”‚ Search Results โ”‚ 320 โ”‚ 3.2% โ”‚
โ”‚ Total Used โ”‚ 1,170 โ”‚ 11.7% โ”‚
โ”‚ Available โ”‚ 8,830 โ”‚ 88.3% โ”‚
โ”‚ Maximum โ”‚ 10,000 โ”‚ 100% โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  • /settings - Interactive configuration editor
/settings

Displays all settings and allows:
โ€ข Category selection (llm, search, rag, cache, osint, all)
โ€ข Change LLM model (qwen3:8b, deepseek-r1:8b, etc.)
โ€ข Adjust temperature (0.0-1.0)
โ€ข Configure max tokens (now 16,000 for RTX 3080+)
โ€ข Change search region (de-de, us-en, wt-wt)
โ€ข Configure OSINT max results & rate limits
โ€ข Enable/disable RAG
โ€ข Enable/disable cache
โ€ข Save changes directly to config.json
โ€ข Auto-restart after saving (optional)
  • /restart - Restart agent
/restart

โ€ข Reloads config.json
โ€ข Fully reinitializes agent
โ€ข Optional session preservation
โ€ข No session interruption

2. Health Monitoring Dashboard

# Windows
health-dashboard.bat

# Linux/macOS
python health-dashboard.py

The dashboard displays:

  • System health (CPU, RAM, disk, network)
  • Component status (LLM, cache, RAG, tools)
  • Performance metrics (response times)
  • Alerts (top 5 active alerts)
  • Auto-refresh (every 2 seconds)

Interactive commands:

  • r - Refresh (manual)
  • c - Clear error log
  • t - Run component tests
  • q - Quit

3. How does intelligent search work?

The agent automatically decides when and how to search:

Automatic decision

 Who is the current German Chancellor?

1. LLM analyzes: "Requires current info" 
2. Agent performs web search
3. LLM processes search results
4. Agent delivers up-to-date response

Search operators for targeted searches

OSINT Search Operators:

# Domain-specific search
 site:github.com machine learning

# Email Intelligence
 email:john.doe@company.com

# Phone Intelligence
 phone:"+49 151 12345678"

# IP Intelligence (NEW!)
 ip:8.8.8.8
 192.168.1.1 # Auto-detects as IP

# Social Media Intelligence (12 Platforms)
 username:elonmusk
 @microsoft
 github # Auto-detects as username

# File format search
 site:example.com filetype:pdf

# URL filter
 inurl:documentation python

# Text in content
 intext:"contact email" site:example.com

Combined Searches:

# Multiple operators
 site:linkedin.com inurl:profile "software engineer"

# Exclusion with minus
 python programming -java

# OR conjunction
 site:github.com OR site:gitlab.com "machine learning"

See OSINT Usage Guide for all features.

4. CLI - Direct Queries

# Standard query (agent decides automatically if web search is needed)
python main.py "What is Python?"

# Multi-Hop Reasoning (auto-selected by the adaptive system for complex queries)
python main.py "Compare Python and JavaScript for web development"

# Offline mode (no web search, only LLM knowledge)
python main.py --no-web "Explain photosynthesis"

# OSINT search with search operators
python main.py "site:github.com python projects"
python main.py "email:contact@example.com"

# With specific model
python main.py --model llama3:7b "Who discovered Einstein?"

5. FastAPI Server

# Start server
python app.py

# Or with starter scripts
run_api.bat # Windows
./run_api.sh # Linux/macOS

# Or manually
uvicorn app:app --host 0.0.0.0 --port 8000

API Documentation: http://localhost:8000/docs

Available Endpoints:

Query & Reasoning:

  • POST /query - Execute standard or multi-hop queries
  • POST /query-adaptive - Adaptive query (automatic agent/complexity selection)
  • POST /osint/query - OSINT queries with operators (email:, phone:, ip:, etc.)
  • POST /osint/company - Company-focused OSINT query (name, country, region, language)

Memory Store (CRUD):

  • GET /memory - Retrieve all stored entries
  • POST /memory/remember - Store value (email, phone, ip, username, domain; notes are CLI-only)
  • GET /memory/recall/{category} - Retrieve category (emails, phones, ips, etc.)
  • DELETE /memory/forget - Delete individual values, categories, or everything
  • GET /memory/stats - Memory store statistics

Session Management:

  • POST /session/clear - Reset session
  • POST /session/save - Save session
  • POST /session/load - Load session

Cache:

  • POST /cache/clear - Clear cache
  • GET /cache/stats - Cache statistics

Configuration:

  • GET /config - Retrieve current configuration
  • PATCH /config - Modify configuration (llm, search, rag, cache, osint)
  • GET /context/status - Token usage & context status

Plugins & Tools:

  • GET /plugins - List available plugins
  • POST /plugins/{name}/load - Load plugin
  • POST /plugins/{name}/unload - Unload plugin
  • GET /tools - List available tools

System:

  • GET /api - API information (name, version, links)
  • GET /health - Health check (agent, monitoring, components)
  • GET /stats - System statistics (agent stats, resources, performance)
  • GET /security-info - Security configuration (rate limits, features)

Security & Administration:

  • POST /csrf-token - Fetch a CSRF token (required for state-changing requests outside DEV_MODE)
  • POST /admin/roles/assign, GET /admin/roles/list, DELETE /admin/roles/revoke, GET /admin/roles/stats - RBAC role management (admin only)
  • GET /admin/roles/me - Show your own role and permissions
  • GET /admin/audit/logs, GET /admin/audit/stats - Query audit logs and statistics (admin only)
  • POST /admin/api-keys/generate - Generate a new API key (admin only)
  • POST /admin/api-keys/rotate, GET /admin/api-keys/list, DELETE /admin/api-keys/revoke/{key_id} - Manage your own API keys
  • GET /dev/api-key - Retrieve the auto-generated key (DEV_MODE + loopback only)

API Security (v1.4.2+):

The API is protected by default with multiple security features:

  • API Key Authentication - X-API-Key header required
  • Rate Limiting - Per-endpoint limits (e.g. /query 10/min, /search 20/min, default 60/min) plus a global per-key limit of 60 requests/minute (configurable via RATE_LIMIT)
  • Input Validation - Pydantic-based validation
  • Query Sanitization - Protection against injection attacks
  • Request Logging - All requests are logged
  • CORS Protection - Configurable origins
  • Trusted Host Middleware - Host header validation
  • CSRF Protection - X-CSRF-Token header required for state-changing requests (obtain via POST /csrf-token) (v1.4.10+)
  • Role-Based Access Control (RBAC) - Admin role required for /admin/* endpoints and plugin load/unload (v1.4.10+)
  • Audit Logging - Security events recorded and queryable via /admin/audit/logs and /admin/audit/stats (v1.4.10+)
  • API Key Management - Generate, rotate, list, and revoke keys via /admin/api-keys/* (v1.4.10+)

Setup:

# 1. Set API key in .env
CRAWLLAMA_API_KEY=your_secure_api_key_min_32_chars

# 2. For local development (without API key)
CRAWLLAMA_DEV_MODE=true

# 3. Adjust rate limit (optional)
RATE_LIMIT=100

# 4. Configure CORS origins (optional)
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8080

Usage with API Key:

# With API key header
curl -X POST http://localhost:8000/query \
 -H "Content-Type: application/json" \
 -H "X-API-Key: your_api_key_here" \
 -d '{"query": "test"}'

# Or in dev mode (without API key)
export CRAWLLAMA_DEV_MODE=true
python app.py

Example Requests:

# Standard query (agent uses web search automatically if needed)
curl -X POST http://localhost:8000/query \
 -H "Content-Type: application/json" \
 -d '{
 "query": "What is Machine Learning?",
 "use_multihop": false
 }'

# Multi-hop query (for complex analyses)
curl -X POST http://localhost:8000/query \
 -H "Content-Type: application/json" \
 -d '{
 "query": "Compare Python and JavaScript",
 "use_multihop": true,
 "max_hops": 3
 }'

# OSINT search with search operators
curl -X POST http://localhost:8000/query \
 -H "Content-Type: application/json" \
 -d '{
 "query": "site:github.com python machine-learning",
 "use_multihop": false
 }'

# Retrieve statistics
curl http://localhost:8000/stats

# List plugins
curl http://localhost:8000/plugins

# Load plugin
curl -X POST http://localhost:8000/plugins/example_plugin/load

CLI Commands and Options

Basic Options

Option Description
--no-web Offline mode (no web search)
--debug Enable debug mode
--model MODEL Override LLM model (e.g. qwen2.5:3b, gpt-4o-mini)
--config PATH Path to configuration file (default: config.json)
--stats Show agent statistics and exit
--clear-cache Clear cache and exit
--setup-keys Interactive setup for API keys

Note: Running python main.py with no question starts interactive mode automatically; pass a question as a positional argument for a direct query.

Interactive Commands

Built-in commands are slash-prefixed โ€” type them with a leading / (e.g. /settings). Bare keywords without a slash are treated as normal queries.

Command Description
/exit, /quit Exit program
/clear Reset session (history + cache)
/clear-cache Clear cache only
/clear-memory, /memory-clear Clear memory store only
/clear-all Clear session, cache and memory
/save Manually save session
/load Reload session
/export, /export-memory Export memory store to file (JSON + TXT)
/export-report [md|txt] Export last report as Markdown or plain text
/stats Display statistics
/status Show context usage
/settings Show/edit settings
/restart Restart agent (reload config)
/help, /hilfe, /? Show help

Tip: Memory operators (remember email:..., recall emails, forget email:...), OSINT operators (email:, ip:, username:, site:, ...) and the context-only prefix (< question answers from conversation history without a web search) are entered as regular queries (no slash) โ€” see the in-app /help for the full list.

REST API

CrawlLama provides a complete REST API for integration into custom applications.

Start API Server

Windows:

run_api.bat

Linux/macOS:

./run_api.sh

Or manually:

uvicorn app:app --host 0.0.0.0 --port 8000

Quickstart

1. Start API Server

run_api.bat

2. Open API Documentation

3. Send Query

curl -X POST http://localhost:8000/query \
 -H "X-API-Key: your-key" \
 -H "Content-Type: application/json" \
 -d '{"query": "What is Python?", "use_tools": false}'

Key Endpoints

  • POST /query - Execute queries (with/without web search, multi-hop)
  • GET /health - Health check
  • GET /stats - System statistics
  • POST /memory/remember - Store data (OSINT)
  • GET /memory/recall/{category} - Retrieve data
  • GET /plugins - Manage plugins
  • POST /cache/clear - Clear cache

Authentication

Set API key in .env:

CRAWLLAMA_API_KEY=your-secret-key-here

Or for testing:

CRAWLLAMA_DEV_MODE=true

Full Documentation

API Usage Guide - Complete API documentation with examples

Project Structure

The complete and up-to-date project structure can be found here: docs/development/PROJECT_STRUCTURE.md

Configuration

config.json

{
 "llm": {
 "base_url": "http://127.0.0.1:11434",
 "model": "qwen3:8b",
 "temperature": 0.7,
 "max_tokens": 2048,
 "stream": true
 },
 "search": {
 "provider": "duckduckgo",
 "max_results": 25,
 "timeout": 10
 },
 "rag": {
 "enabled": true,
 "embedding_model": "nomic-embed-text",
 "chunk_size": 500,
 "chunk_overlap": 50,
 "top_k": 10
 },
 "cache": {
 "enabled": true,
 "ttl_hours": 24,
 "max_size_mb": 500,
 "clear_on_startup": false
 },
 "osint": {
 "max_results": 25,
 "email_search_limit": 50,
 "phone_search_limit": 50,
 "general_osint_limit": 100
 },
 "plugins": {
 "example_plugin": {
 "enabled": false,
 "sha256": "<plugin-file-sha256>"
 }
 },
 "security": {
 "warn_external_requests": true,
 "allowed_domains": [],
 "max_context_length": 6000
 },
 "tor": {
 "enabled": false,
 "socks_host": "127.0.0.1",
 "socks_port": 9050
 }
}

Recommended max_tokens Settings:

GPU/Hardware Recommended max_tokens Model
RTX 3080+ (10GB+) 10,000 - 16,000 qwen3:8b, deepseek-r1:8b
RTX 3060/3070 (8GB) 6,000 - 8,000 qwen3:4b, llama3:7b
CPU Only 2,000 - 4,000 qwen3:4b

Tip: Use the /status command to monitor your token usage in real-time!

.env (Optional)

# API Keys (optional)
BRAVE_API_KEY=your_brave_api_key
SERPER_API_KEY=your_serper_api_key

# Proxy (optional)
HTTP_PROXY=http://proxy:port
HTTPS_PROXY=https://proxy:port

# Tor mode (optional) โ€” overrides the "tor" section in config.json
TOR_MODE=1
TOR_SOCKS_HOST=127.0.0.1
TOR_SOCKS_PORT=9050

Tor Mode (Anonymous Fetching)

With Tor mode enabled, every outbound web request โ€” crawler page fetches, web/news search, OSINT lookups, robots.txt checks and cloud LLM calls โ€” is routed through a Tor SOCKS5 proxy. Enable it via TOR_MODE=1 (env) or "tor": {"enabled": true} in config.json.

# 1. Install and start Tor (provides a SOCKS5 proxy on 127.0.0.1:9050)
sudo apt install tor && sudo systemctl start tor   # Linux
brew install tor && brew services start tor        # macOS

# 2. Run CrawlLama with Tor mode
TOR_MODE=1 python main.py "your query"

Behavior and guarantees:

  • Fail fast: on startup the Tor circuit is verified via check.torproject.org. If Tor is unreachable or traffic does not exit through Tor, the application refuses to start โ€” it never falls back to a direct connection.
  • No DNS leaks: hostnames are resolved at the Tor exit (socks5h / remote DNS); local DNS lookups (SSRF pre-resolution, reverse DNS) are skipped while Tor mode is active.
  • Local services stay reachable: loopback and private-network targets (e.g. a local Ollama server) bypass Tor โ€” that traffic never leaves your machine or LAN, and Tor cannot route to it anyway.
  • With Tor mode off, behavior is completely unchanged.

Note: Tor adds noticeable latency and some sites block Tor exit nodes โ€” expect slower fetches and occasional refusals.

Testing

Full screening (tests + arena in one gate)

full-screening.sh merges the two testing layers: it runs the pytest suite first (unit correctness of every tool), and only if that is green does the arena begin (validate โ†’ capability-coverage gate โ†’ smoke โ†’ capabilities suites) for a complete behavioural screening. See the Model Arena guide.

./full-screening.sh                 # pytest + deterministic arena screening
./full-screening.sh --live          # also run the live tool suite (web/page/wiki/RAG)
./full-screening.sh --profile arena/scenarios/profiles/ollama-llama31-8b.json

pytest only

# All tests
pytest tests/ -v

# With coverage
pytest --cov=core --cov=tools --cov=utils tests/

# Specific tests
pytest tests/multihop/test_multihop_reasoning.py -v
pytest tests/robustness/test_fallback_manager.py -v

# With debug output
pytest tests/ -v --log-cli-level=INFO

Plugin Development

Creating a Simple Plugin

# plugins/my_plugin.py

from core.plugin_manager import Plugin, PluginMetadata

class MyPlugin(Plugin):
 def get_metadata(self) -> PluginMetadata:
 return PluginMetadata(
 name="MyPlugin",
 version="1.0.0",
 description="My custom plugin",
 author="Your Name",
 dependencies=[]
 )

 def get_tools(self):
 return [self.my_tool]

 def my_tool(self, input: str) -> str:
 return f"Processed: {input}"

See: Plugin Tutorial for details

Technology Stack

Core

  • LLM: Ollama (qwen3:4b, deepseek-r1:8b, llama3, mistral)
  • Orchestration: LangGraph (Multi-Hop Reasoning)
  • Web Search: duckduckgo-search, Brave API, Serper API
  • RAG: ChromaDB + Sentence Transformers

Backend

  • API: FastAPI + Uvicorn
  • Database: SQLite (Sessions)
  • Async: aiohttp, asyncio
  • Monitoring: psutil

Utils

  • HTML Parsing: BeautifulSoup4
  • CLI: Rich (Formatting)
  • Retry: Tenacity
  • Security: cryptography

Development

  • Tests: pytest, pytest-mock, pytest-cov
  • CI/CD: GitHub Actions (planned)

Documentation

User Guides

Developer Docs

  • Project Structure - Project overview
  • docs/development/RELEASE_PROCESS.md - Release workflow (planned/maintainer note)
  • Tests - See tests/ for examples

API Documentation

Roadmap

Phase 1: Core (Completed)

  • Ollama integration
  • Web search (DuckDuckGo)
  • Tool orchestration
  • Basic RAG & caching
  • CLI with Rich

Phase 2: Robustness (Completed)

  • Fallback system
  • Retry logic with tenacity
  • Rate limiting & robots.txt
  • Domain blacklist
  • Safe fetch with proxy support
  • Multi-source web search
  • Comprehensive tests (80%+ coverage)

Phase 3: Intelligence (Completed - v1.1)

  • Multi-Hop Reasoning with LangGraph
  • RAG optimizations (batch, multi-query, hybrid)
  • Parallelization (ThreadPoolExecutor)
  • Lazy-loading for tools/plugins
  • Async HTTP operations
  • RAM & performance monitoring

Phase 4: Production (Completed - v1.1)

  • FastAPI REST API
  • Multi-user support (SQLite)
  • Plugin system
  • Enhanced CLI
  • Setup scripts (Windows/Linux)
  • Systemd service
  • Comprehensive documentation

Phase 5: Future (Planned)

  • GUI (Streamlit/Gradio)
  • GraphQL API
  • Redis cache for production
  • Kubernetes deployment
  • Monitoring dashboard
  • Multi-language support
  • Voice interface

Contributing

Contributions are welcome!

Development Workflow:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a pull request

Coding Standards:

  • PEP8 compliant
  • Use type hints
  • Docstrings for all functions
  • Tests for new features

Performance

Benchmarks (on i7-8700K, 32GB RAM)

Operation Average Notes
Standard Query 2-5s Without web search
Query with Web Search 5-10s 3-5 results
Multi-Hop (3 Hops) 15-30s Complex
RAG Search <1s 5 results
API Request <100ms Without tools

Resources

  • RAM: 200-500 MB (standard), 500-800 MB (with RAG)
  • CPU: 10-30% (idle), 50-80% (active)
  • Disk: ~100 MB (code), variable (cache/embeddings)

Legal Notices

Web Scraping

  • Respects robots.txt
  • Rate limiting (1 req/s default)
  • Identifiable user agent
  • Users are responsible for compliance with local laws

Data Privacy

  • Data is processed locally only when using a local LLM backend (e.g., Ollama)
  • When using cloud-based LLM APIs (e.g., Claude, OpenAI, Gemini), your queries are sent to external servers โ€” local processing is not guaranteed in this case
  • No cloud services used by default
  • Full control over logs/cache
  • Session data stored locally in SQLite (data/history/); API keys stored encrypted

API Keys

Troubleshooting

Ollama not reachable

# Check status
curl http://127.0.0.1:11434/api/tags

# Start Ollama
ollama serve

Import errors

# Reinstall dependencies
uv sync

# Or re-run setup
./setup.sh # or setup.bat

ChromaDB errors

# Delete embeddings
rm -rf data/embeddings/

# Restart
python main.py

API rate limits

The REST API enforces per-endpoint rate limits (e.g. /query: 10 req/min, /search: 20 req/min, /osint/query: 5 req/min). Set RATE_LIMIT_SECRET in .env for consistent rate limiting across restarts (and REDIS_URL to share limits across processes):

# .env
RATE_LIMIT_SECRET=your-long-random-secret
REDIS_URL=redis://localhost:6379/0

Support and Community

License

Crawllama License (Non-Commercial) - Free for use and development, but no commercial sale allowed.

Allowed:

  • Personal use
  • Education & research
  • Modification & sharing (non-commercial)
  • Contributions to the project

Not Allowed:

  • Sale of the software
  • Commercial use
  • Integration into paid products

See LICENSE for full details.

Credits

Built with:

Further Documentation


Last Updated: 2026-03-18

Changelog

CHANGELOG.md

Navigation: README | Contributing | Security | Docs


All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Added

  • Tor mode (#42): optional global toggle (TOR_MODE=1 or "tor" section in config.json) that routes all outbound web fetching โ€” crawler, web/news search, OSINT lookups, robots.txt checks and cloud LLM calls โ€” through a Tor SOCKS5 proxy (default socks5h://127.0.0.1:9050, host/port configurable). The Tor circuit is verified on startup via check.torproject.org and the application fails fast when Tor is unreachable. Hostnames resolve at the Tor exit (remote DNS) and local DNS lookups are skipped while active, preventing DNS leaks; loopback/LAN targets (e.g. local Ollama) stay direct. With Tor mode off, behavior is unchanged.

Planned

  • GUI with Streamlit/Gradio
  • GraphQL API
  • Redis cache for production
  • Voice interface

[1.4.12] โ€” 2026-10-26

Logic-fix & refactor release. A codebase-wide review for logic errors, followed by fixes, deduplication into shared helpers and API modernization.

Fixed

  • Managed API keys now act for the principal they were issued to. Roles, key listing and revocation follow the owner, so a managed key can list and revoke its owner's keys.
  • Middleware order: 429 and CSRF 403 responses are now audited and carry the security and CORS headers.
  • Redis rate limiter: the token-bucket update is atomic (WATCH/MULTI), so concurrent requests can no longer overspend.
  • OSINT batches: the first e-mail address or phone number is no longer analyzed twice, and both batch types share one batch loop.
  • API sessions per user: every API principal now has its own conversation session (history, search results, loaded pages). Clients can no longer see or continue each other's results, and follow-up answers are no longer shared through the response cache.
  • Third review round:
    • OSINT:
      • username: queries are routed to social intelligence again.
      • A single plain word no longer starts a scan across 12 platforms.
      • The compliance blacklist matches whole words, so "Spyder" and "hackathon" are no longer blocked.
      • Company intent is no longer triggered by words like "ab", "se" or "spa".
      • File names are no longer taken as domains, and short subdomains no longer count as company matches.
    • Utilities:
      • Cache writes are atomic in the async path too.
      • Tor mode can be activated twice and still restores the original environment.
      • API keys saved through SecureConfig take effect immediately.
      • Wikipedia summaries come from the page that was actually found.
    • Deduplication: one shared query validator, shared CLI routing, an alert-rule base class, one OSINT compliance helper and one Tor-guarded reverse-DNS helper.
  • Second review round:
    • Agent and routing: "ergebnis 2" is recognized as a result reference again, a normal question such as "connection between Einstein and Bohr" no longer triggers a connection analysis, an adaptive escalation really uses tools now (separate caches), the hop limits are applied, and the complexity heuristics match whole words only.
    • LLM client: one retry layer instead of up to 27 connection attempts, a cheap health ping, rate limiting for streaming, and context windows chosen by the longest model prefix.
    • API:
      • GET /config no longer leaks secrets from lists or credentials in URLs, and max_tokens is no longer hidden.
      • PATCH /config refuses to overwrite a config.json that failed to load and checks value types.
      • One shared memory store for the whole process.
      • Access to the shared agent session is serialized.
    • Crawler: a missing robots.txt (404) no longer blocks the whole site, and rate limiting per domain no longer stalls other domains.
    • OSINT sources:
      • Failed sources are reported instead of counting as "not pwned".
      • DeHashed no longer reports a breach when there are 0 hits.
      • Local breach files match the email exactly.
      • HIBP encodes the email correctly in the URL path.
      • Audit hashes are keyed with a secret (HMAC).
    • Plugins: the code that runs is exactly the file whose SHA-256 was checked. A plugin is only cached after its initialization succeeded.
    • Other:
      • The cache commands clear the configured cache.
      • Prompt-injection detection catches common filler-word variants.
      • Proxy and NO_PROXY checks are fixed.
      • RAG no longer switches itself off permanently.
      • forget domain: and forget note: work.
      • Arena run deletion and dataset redaction are hardened.
      • The /settings restart uses the same config path as startup.
      • The health dashboard counts errors and timeouts as failures.
  • Security / API: write endpoints for memory, session and cache now require the user role and GET /config requires admin, matching ENDPOINT_PERMISSIONS. The performance tracker and adaptive processor are now stored on the runtime, so /query-adaptive stops returning 503. forget with a value but no category returns 400 instead of 500. Notes can be stored through /memory/remember. A non-ASCII API-key header no longer causes a 500.
  • safe_fetch: the original error is re-raised after retries, so the typed handlers and the circuit breaker run again. 4xx responses are not retried and no longer block the whole domain. Redirect targets are checked against the blacklist and robots.txt. Credential headers are dropped when a redirect goes to a different host. Fixed the redirect off-by-one and the consecutive-failure counting.
  • Domain blacklist: patterns loaded from a file are compiled. Matching uses the hostname, so a port or a trailing dot no longer bypasses it.
  • Memory store: a corrupt memory.json is moved to *.corrupt instead of being overwritten with empty data. Entry counts no longer include timestamp strings. Notes render correctly. A merge import deduplicates entries within the imported file. The page cache keeps its integer keys after a session reload.
  • OSINT:
    • Query parser: phone numbers no longer swallow the operators after them, notes keep their full text, recall only works at the start of a query, and operators no longer match inside other words.
    • Social profiles are no longer all marked "verified".
    • IP intel: an existing session is reused instead of leaked, cloud ranges are matched by prefix, the fake "0/100" reputation is gone, and the VPN hint works.
    • Phone and email intel: the 00 dialing prefix is handled, malformed local parts are handled, the LeakCheck query is URL-encoded, and in Tor mode a domain no longer counts as existing when the DNS check was skipped.
  • Agent:
    • Harmless questions are no longer refused as prompt injections ("coffee filter", "security news").
    • Tool use is decided from the first word of the model's answer.
    • The LangGraph confidence and quality scores are parsed correctly (85, 85/100, 8.5/10).
  • Hallucination detector: removed contradiction patterns that matched almost every answer. Fixed patterns that could never match. Proper names are matched case-sensitively. The Wikipedia timeout now takes effect. Each config gets its own detector with deep-copied defaults.
  • Utilities: run_async passes coroutine errors through unchanged and works inside a running event loop. The audit-log search returns the newest events first. clean_html no longer repeats nested text. ANSI sequences are fully stripped from logs. The prompt-injection filter keeps "+" in normal text such as "C++". Multi-label domains such as www.example.com are recognized as search candidates.

Changed

  • New shared helpers replace duplicated code:
    • core.prompt_budget replaces four copies of the pre-flight LLM truncation. It now counts the system prompt and keeps the trailing question.
    • utils.redis_utils.connect_redis replaces three copies of the Redis setup and redacts credentials in logs.
    • api.security_config.client_ip replaces five inline client-IP lookups.
    • utils.secure_hash.pii_log_id, the breach name/date helpers, the token-bucket refill, ResultFlow._get_result and the memory API's method resolution each replace copied code.
  • Modernized APIs: explicit X | None parameters, no asyncio.get_event_loop() pattern, asyncio.to_thread, and dict.get idioms.
  • Added regression tests for the fixes above.

[1.4.11] โ€” 2026-06-12

Refactor & code-quality release. Large functions across the CLI, agent, FastAPI server, OSINT, RAG, memory, rate limiter and health dashboard are split into smaller focused helpers. No behaviour changes โ€” the runtime trees are identical to 1.4.10.

Shortened here. Full file on GitHub