selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

Khoj logo

Self-host Khoj

2.0.0-beta.28

AI second brain to chat with your docs, agents, automations

BetaOpen SourceAGPL-3.0
Docker ComposeCompose file & guide
docker-compose up
Updated7 months ago
LanguagePython
Setup difficultyModerate
MobilePWA
Stars
38 080
RAM
Minimum 8 GB RAM (16 GB VRAM recommended)
Storage
Minimum 5 GB of disk available
Port
42110 (Khoj web app and API server (started with --host="0.0.0.0" --port=42110))
Docker
ghcr.io/khoj-ai/khoj
Khoj web app home screen with chat and searchChat on the web, using an image as contextServer admin panel form for configuring an AI model API

What is Khoj?

Khoj is a personal AI assistant that indexes your notes and files so you can talk to them, using whichever large language model you point it at, local or hosted. Retrieval-augmented chat sits on top of a fast semantic search engine, and you can define custom agents with their own knowledge, persona, model and tools, or schedule recurring research that arrives in your inbox as email. It also generates images from prompts, takes and plays voice input, and writes and runs small Python programs for analysis and plots. Access is not limited to the browser: there are desktop, Obsidian, Emacs and WhatsApp clients, plus a PWA install for phones. Self-hosting means running the project's docker-compose stack (PostgreSQL with pgvector plus bundled SearxNG and Terrarium containers) or installing the server with pip and launching khoj --anonymous-mode; multi-user setups turn on magic-link or Google sign-in and are administered through a Django admin panel at /server/admin. The software is AGPL-3.0 licensed, current releases are in the 2.0 beta series, telemetry is on by default but can be switched off, and the vendor also offers a hosted cloud instance and an on-premises/hybrid enterprise variant.

Should you self-host Khoj?

Khoj scores 79/100 on selfhost.directory (how scoring works) and ranks #5 of 120 in AI Assistant. It has 38 080 GitHub stars, +516 in the last 30 days.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is moderate: expect some configuration beyond a single command. An official Docker image is available. It is AGPL-3.0-licensed and written mostly in Python.

Its closest alternative on selfhost.directory is hermes-agent (89/100, 261 891 stars). It scores higher overall, so compare the two before you pick. See Khoj vs hermes-agent side by side.

Features

  • Admin Panel
  • Chat with local or online LLMs
  • Chat with your documents
  • Desktop file sync
  • Image Generation
  • Multi-user AuthenticationGoogle OAuth needs the prod image ghcr.io/khoj-ai/khoj-cloud or pip install khoj[prod].
  • Online search with references
  • Python code execution
  • Scheduled Automations
  • Semantic Search
  • Shareable conversations
  • Voice chat

Khoj README

How to install Khoj

Install Khoj with Docker Compose

Environment variables
KHOJ_DJANGO_SECRET_KEY,KHOJ_ADMIN_EMAIL,KHOJ_ADMIN_PASSWORD,POSTGRES_DB,POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_HOST,POSTGRES_PORT,KHOJ_SEARXNG_URL,KHOJ_TERRARIUM_URL,OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY,OPENAI_BASE_URL
mkdir ~/.khoj && cd ~/.khoj
wget https://raw.githubusercontent.com/khoj-ai/khoj/master/docker-compose.yml
  • Configure the environment variables in the docker-compose.yml
cd ~/.khoj
docker-compose up

Compose file brings up the Khoj server plus pgvector PostgreSQL, SearxNG and Terrarium sandbox containers.

How to configure Khoj

  • KHOJ_ADMIN_PASSWORDPassword for the admin account; set to something secure.
  • KHOJ_DJANGO_SECRET_KEYSecret key for the Django backend; set to something secure so the admin panel can be used.
  • KHOJ_ADMIN_EMAILEmail of the admin account created on first run.
  • OPENAI_API_KEYAPI key for OpenAI chat models.
  • ANTHROPIC_API_KEYAPI key for Anthropic chat models.

FAQ

How can I make my own agent?

Follow the project's step-by-step blog guide on creating custom agents in Khoj.

Can I use Khoj without self-hosting?

Yes, Khoj can be used straight away on the hosted app at app.khoj.dev with no setup.

More in AI Assistant

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…