Khoj
Open-source AI second brain, personal search assistant, and ChatGPT for your local documents.
Why consider Khoj?
An open-source, self-hostable personal AI assistant that uses RAG to index and chat with your own documents and data.
Learn Khoj by building
Practical setup notes, real use cases, and copy-ready examples in one focused guide.
In this guide3 sections
Khoj: Your Personal AI Second Brain
Khoj is a self-hostable, open-source AI application built to serve as a personal research copilot. Unlike general-purpose AI chat interfaces, Khoj is designed to connect directly with your own knowledge base. By using Retrieval-Augmented Generation (RAG), it allows you to index and search through your personal data—including Markdown notes, PDFs, Word documents, Notion workspaces, and GitHub repositories.
The primary goal of Khoj is to provide a unified, privacy-first interface where you can leverage large language models (LLMs) to reason about your own files. You have the flexibility to run the application locally on your own hardware to ensure maximum data privacy, or use cloud-hosted options if convenience is the priority. Khoj supports a wide variety of AI models, enabling you to integrate local models via Ollama or connect to external providers like OpenAI, Anthropic, and Google Gemini.
For users who want to retain ownership of their personal data while benefiting from modern AI capabilities, Khoj fills a critical gap. It is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) and offers multiple access methods, including a web interface, a desktop application, and direct integrations with popular editors like Obsidian and Emacs. Official documentation and source code are available at https://github.com/khoj-ai/khoj.
Orchestrating Khoj with Docker Compose
Running Khoj locally requires several integrated services to function correctly. Beyond the main application server, Khoj depends on a PostgreSQL database with the pgvector extension for storing and querying vector embeddings, as well as a search engine component (like SearXNG) for web queries.
Because of these interconnected dependencies, the official and most reliable method to deploy Khoj is using Docker Compose. This approach orchestrates the networking and persistent volumes required by the database and application containers automatically.
To get started on a local machine, you need to download the official Docker Compose configuration provided by the Khoj repository. This configuration defines the multi-container environment needed to run the application seamlessly. Official source: https://github.com/khoj-ai/khoj.
Downloading and Starting the Services
The official installation process involves creating a dedicated directory for your Khoj deployment and fetching the docker-compose.yml file from the main branch of the repository. Once the file is downloaded, you can use Docker Compose to pull the necessary images and start the services in detached mode.
Here is the officially documented sequence to download the configuration and start the environment:
mkdir ~/.khoj && cd ~/.khojwget https://raw.githubusercontent.com/khoj-ai/khoj/master/docker-compose.ymlAfter the configuration file is saved to your machine, you can start the Khoj environment using the standard Docker Compose command:
docker-compose up -dThese commands ensure that the necessary volumes are created and the containers are brought up in the correct order. You can optionally open the docker-compose.yml file before running the up command to configure environment variables, such as API keys for external models or an admin password for the Khoj instance.
Connecting Your Data and Clients
Once the Docker Compose stack is running, Khoj exposes a web interface where you can begin indexing your personal files. The initial setup usually involves pointing the application to your local directories or authenticating it with external services like Notion or GitHub.
Khoj processes these inputs by generating vector embeddings, which are stored in the local pgvector database. When you ask a question through one of the supported interfaces, Khoj performs a semantic search against these embeddings, retrieves the most relevant context, and passes it to the selected language model to generate a grounded, accurate response based purely on your personal data.
Whether you prefer interacting with your AI assistant through a dedicated desktop app, directly within your Obsidian vault, or via the web browser, Khoj provides a flexible and privacy-focused solution for managing and querying your digital life.
Related tools
More options with a similar category or technology profile.
marimo
A reactive Python notebook that is reproducible, git-friendly, and executable as a script.
JupyterLab
The next-generation web-based user interface for Project Jupyter computational notebooks.
Trafilatura
Python package and command-line tool designed to gather text and metadata on the Web.
ScrapeGraphAI
Python scraper library that uses LLMs and direct graph logic to extract website data.