New Tool Radar

Local AI

How to Connect LibreChat to Your Local Ollama Server

Point LibreChat at your Ollama server with one custom endpoint in librechat.yaml — a placeholder API key and the /v1 base URL — and your local models appear in LibreChat.

Schematic diagram with three steps: pull a model with Ollama, add a custom endpoint in librechat.yaml, and pick the model in LibreChat.

LibreChat is a chat interface you run yourself, and it does not come with models built in. Its Ollama docs explain the connection plainly: Ollama runs open models locally and exposes an OpenAI-compatible API, so you can point LibreChat at your own machine. The whole connection is one entry in LibreChat’s librechat.yaml configuration file — no plugin, no extra server, and no cloud account.

Add Ollama as a custom endpoint

First pull a model on the Ollama machine, for example ollama pull llama3. Then add the endpoint to the custom list under endpoints in librechat.yaml. If your file already has an endpoints.custom list, paste only the - name: entry into it, keeping the same indentation:

Setting Value in the example Why it is that value
name "Ollama" The endpoint name shown in LibreChat; it must start with “ollama” (any case) for LibreChat to fetch the model list through Ollama’s native /api/tags route
apiKey "ollama" Ollama ignores the API key but still expects the field to be present, so set it to any placeholder; an endpoint with no apiKey is dropped when the config loads
baseURL "http://localhost:11434/v1/" Ollama’s OpenAI-compatible API, on the port Ollama listens on
models.default A list such as ["llama3"] The models offered in the chat; with fetch: true, LibreChat pulls the full list from your server instead
titleModel "current_model" Title generation reuses the conversation’s model instead of loading a second one, keeping Ollama to a single loaded model per conversation

The one mistake almost everyone makes

If LibreChat runs in Docker, localhost is the LibreChat container itself, not your host machine — so http://localhost:11434/v1/ reaches nothing. LibreChat’s docs say to check that the endpoint is reachable from LibreChat, not from your shell: use http://host.docker.internal:11434/v1/ on Docker Desktop, or the host’s LAN address on Linux, where host.docker.internal may be unavailable. Running LibreChat outside Docker is the only case where http://localhost:11434/v1/ is correct.

There is a second half to the same problem. By default Ollama binds to 127.0.0.1, which a container cannot reach, so set OLLAMA_HOST=0.0.0.0 in Ollama’s own environment and restart it. LibreChat’s docs warn that this exposes Ollama on every interface, and Ollama’s API is unauthenticated — anyone who can reach port 11434 can use your models and pull or delete them — so prefer binding only the address the LibreChat container actually reaches and firewalling port 11434 so nothing else can reach it. If the connection still fails, docker compose logs api reports the connection error and the URL LibreChat actually tried.

Try it: check the model list appears

For a fictional example, with llama3 pulled and the endpoint above saved with fetch: true, restart LibreChat and open a new conversation on the Ollama endpoint. The model list shows the models from your server, because with fetch: true LibreChat pulls the full list from it. Pick llama3, ask “Why is the sky blue?”, and the reply comes from the model on your own machine, not from a cloud service. Expected result. We checked LibreChat’s Ollama docs and Ollama’s FAQ. We did not install LibreChat or connect it to a server.

Limits

This guide covers only the Ollama connection, not installing LibreChat itself, which runs as a Docker Compose application with its own database and secrets to set. If you rename the endpoint to something that does not start with “ollama”, model fetching falls back to the generic OpenAI-compatible /v1/models request instead of the native /api/tags route — usually still fine, since current Ollama versions answer that one too. A model that keeps generating without stopping may need stop sequences added, which LibreChat’s docs cover in the same page. We did not test any connection ourselves.

Sources

See all