New Tool Radar

Local AI

How to Run Khoj as a Local AI Assistant and Ask About Your Files

Self-host Khoj with Docker, point it at a local OpenAI-compatible model, sync your files, and ask questions about them.

Schematic diagram with three steps: start Khoj with Docker Compose on localhost 42110, point it at a local model API, then drag in files and ask questions about them.

Khoj is a personal AI app that answers questions from the web or your documents, and it is open source and self-hostable. Self-hosting keeps your data on your own machine: the docs say your data will never have to leave your private network, and you can even use Khoj without an internet connection if it is deployed on your personal computer.

Install Khoj with Docker

Install Docker Desktop and the Docker Compose tool first. Then download the Khoj compose file and start the server:

mkdir ~/.khoj && cd ~/.khoj
wget https://raw.githubusercontent.com/khoj-ai/khoj/master/docker-compose.yml
docker-compose up

Before starting, set KHOJ_ADMIN_PASSWORD and KHOJ_DJANGO_SECRET_KEY in the docker-compose.yml file to something secure, so you can customize Khoj later through the admin panel. Your setup is complete once you see Khoj is ready to engage in the server logs on your terminal. Then open the web app at http://localhost:42110. By default Khoj is only accessible on the machine it is running on.

Point it at a local model

Khoj supports local and online chat models. To use a local model, uncomment OPENAI_BASE_URL in the compose file and set it to the URL of your OpenAI-compatible API, such as vLLM or LM Studio. Then restart the server after the first run, so all settings are applied correctly.

For finer control, log in to the admin panel at http://localhost:42110/server/admin with the admin credentials you set during installation. Use localhost, not 127.0.0.1, to reach the admin panel and avoid the CSRF error. There, create a new AI Model API entry, give it a friendly name, and set the API base URL to your local model server; then create a new chat model, set its chat-model field to the model name and its model-type field to OpenAI.

Sync your files and ask questions

You can chat with your notes and documents using Khoj. Khoj can keep your files and folders synced using the Khoj Desktop, Obsidian, or Emacs clients, and your Notion workspace can be synced directly from the web app. You can also just drag and drop specific files you want to chat with onto the web app. Khoj reads PDFs, Markdown, Notion, Word documents, org-mode files, and more. Once a file is in, ask a question about it in the chat at http://localhost:42110 and check that the answer draws on your file rather than on general knowledge.

Try it: four checks from install to first answer

Check What you should see If you do not see it
Server ready Khoj is ready to engage in the terminal logs Check the docker-compose up output for an error, then restart the server
Web app opens The Khoj web app at http://localhost:42110 Check the server is still running and the port is 42110
Local model set OPENAI_BASE_URL points at your local OpenAI-compatible API Check the value in docker-compose.yml and restart the server
Answer from your file A reply that uses the file you dragged in, not general knowledge Check the file was dropped onto the web app and the chat model is set

Expected result. We checked the Khoj self-host guide, which gives the Docker install commands, the KHOJ_ADMIN_PASSWORD and KHOJ_DJANGO_SECRET_KEY settings, the OPENAI_BASE_URL setting for a local OpenAI-compatible API such as vLLM or LM Studio, the ready message, the http://localhost:42110 address, the admin panel at /server/admin with the localhost CSRF note, and the file sync options including drag and drop, and the Khoj README on GitHub, which describes Khoj as a self-hostable personal AI app that answers questions from your documents and lists the file types it reads. We did not install or run Khoj on this machine.

Limits

This guide covers the Docker install and one local chat model only. Khoj also has a pip install, a desktop app, and clients for Obsidian and Emacs, and it can create custom agents and schedule automations, but those are separate jobs. The admin panel login needs localhost, not 127.0.0.1, or you hit a CSRF error, and on a Mac the docs suggest Chrome or Firefox instead of Safari for the admin panel. Restart the server after the first run so all settings are applied. We did not test any of this ourselves.

Sources

See all