Skip to Content
Installation

Install LobeChat

Your own chat interface for language models, set up against a free model on your own computer instead of against a key that costs per message.

Last reviewed:

What LobeChat is

A chat interface of your own for language models, which you run on your own computer. It looks roughly like the chat services you have already used, but you decide which model answers and where the conversations are saved.

Two things make it interesting for a company. You can build your own assistants with ready-made instructions, for example one that answers customer emails in your tone, and share them within the company. And you can run against a model that sits on your own computer, which means the text never leaves the machine.

The program was previously called LobeChat and is now also called LobeHub. It is the same thing.

This is a server program

LobeChat is not installed like a regular program. It is a web service that runs in a container and that you reach through the browser. The tool that runs the container is Docker, the same as in Install Docker. If you do not have Docker in place, start there and come back here.

On Windows, Docker Desktop means that you also get WSL2, which is Windows' built-in Linux. It is normally installed automatically by Docker Desktop, but if you are asked about it you should answer yes. Without WSL2, no container starts.

The free path first: LobeChat plus Ollama

Almost every guide online starts by telling you to paste in an API key from a paid service. Such a key costs money per message, and for a business that counts every krona, that is the wrong place to start.

There is a path without a key. Ollama is a free program that runs a language model directly on your computer, and LobeChat talks to it just as readily as to a paid service. Install Ollama from ollama.com, both Windows and Linux are available, and then fetch a model:

ollama pull llama3.2

Before you start the container, Ollama has to let it in. By default Ollama only listens on its own computer, and a container counts as something else. So set OLLAMA_HOST to 0.0.0.0 and restart Ollama. On Linux Mint:

sudo systemctl edit ollama

Add the line [Service] and below it Environment="OLLAMA_HOST=0.0.0.0", save, and then run sudo systemctl restart ollama. On Windows, quit Ollama in the taskbar, add OLLAMA_HOST with the value 0.0.0.0 under Environment Variables in the Windows settings, and start the program again. If you skip this, you will get empty answers in LobeChat later, without any error message explaining why.

Then start LobeChat. On Windows one line is enough, because Docker Desktop already knows the name host.docker.internal, that is, the host computer seen from inside the container:

docker run -d -p 3210:3210 --name lobe-chat -e OLLAMA_PROXY_URL=http://host.docker.internal:11434 -e OLLAMA_ORIGINS=* lobehub/lobe-chat

You should also set ACCESS_CODE to a password of your own, otherwise anyone who finds the address can use the service.

On Linux Mint that name does not exist, and then the container never finds Ollama. Add the flag that creates the name for you:

docker run -d -p 3210:3210 --name lobe-chat --add-host=host.docker.internal:host-gateway -e OLLAMA_PROXY_URL=http://host.docker.internal:11434 lobehub/lobe-chat

Surf to http://localhost:3210, choose Ollama as the provider in the settings and choose the model you fetched. Now everything works, and nothing costs anything.

If you later need a larger model than the computer can handle, you can add a paid key in the same settings. Then at least you know what you are paying for, and why.

Three things to do first

  1. Check that the connection to Ollama works before you do anything else. Ask a question in LobeChat and see that you get an answer. If the answer is empty, it is almost always OLLAMA_HOST that did not take effect, or the --add-host flag that is missing on Linux Mint.
  2. Build one assistant before you build ten. Give it a clear instruction, for example that it always answers in Swedish and stays under five sentences. The difference from an empty chat is bigger than you think.
  3. Choose a model based on your computer, not on what sounds best. A model with three billion parameters runs on an ordinary laptop. One with seventy does not, and you notice it because the answers take minutes instead of seconds.

The most common trap

Putting an API key in a file and then putting the file on GitHub. The key is a password that costs money when someone else uses it, and bots that scan new public repos for keys find them within minutes. There are plenty of stories about bills of tens of thousands of kronor that came about in exactly that way.

So keep the keys in LobeChat's own settings in the browser, or in a file called .env that is listed in .gitignore. And if you run it against Ollama, there is no key at all to leak, which is another reason to start there.

Cart

Loading