Insights

How to Host Your Own LLM on a Private AI Server

How to Host Your Own LLM on a Private AI Server

Hosted AI is convenient until it isn't. Your documents leave your network, your costs grow with every request, and the model you rely on can change under you.

A private AI server is the alternative: an open-weight language model running on a machine you own, answering only the people you choose. Setting one up is now an afternoon's work.

This guide shows how to host your own LLM with Ollama, add a chat interface, and reach the server from anywhere without opening it to the internet. It also covers what hardware you need and where self-hosting falls short.

Can you run AI locally?

Yes. Open-weight models such as Llama, Qwen, Gemma, and Mistral are published for anyone to download and run. Tools like Ollama package the runtime, so running a model is a single command.

What you trade for privacy is capability. A model that fits on one machine is smaller than the largest hosted models. For many everyday tasks, such as summarizing, drafting, extracting data, and answering questions about your own documents, a well-chosen local model is enough.

Why host your own LLM

  • Privacy. Prompts and documents stay on your hardware. That matters for client data, health records, source code, and anything under an NDA.
  • Predictable cost. You pay for the hardware and electricity once, not per token.
  • Control. You choose the model and the version, and it does not change until you change it.
  • Availability. No rate limits from a provider, and it keeps working when an outside service is down.

What hardware you need

The main constraint is memory: the model's weights have to fit in GPU memory (VRAM), or in unified memory on Apple Silicon. Quantized models, which store weights at lower precision, make this much easier. These are rough figures for 4-bit quantized models:

Model sizeMemory neededTypical hardwareGood for
Small (1B to 4B parameters)About 2 to 4 GBMost recent laptops, a Raspberry Pi 5 for the smallest modelsQuick drafts, classification, simple chat
Medium (7B to 9B)About 5 to 8 GBA GPU with 8 GB or more, or an Apple Silicon Mac with 16 GBGeneral chat, summaries, coding help
Large (12B to 32B)About 8 to 24 GBA 16 to 24 GB GPU, or a Mac with 32 GB or moreStronger reasoning and longer documents
Very large (70B and up)40 GB and moreSeveral GPUs, or a high-memory workstationClosest to hosted frontier models

Longer conversations and documents need extra memory on top of the weights. A model can also run on the CPU alone, but expect replies to arrive far more slowly.

If you already have a gaming PC or a recent Mac, start there. Buy hardware once you know which model size you actually use.

Step 1: Install Ollama and run a model

On Linux:

curl -fsSL https://ollama.com/install.sh | sh

On macOS and Windows, download the installer from ollama.com.

Then download and chat with a model:

ollama run llama3.2

The first run downloads the model. After that it starts in seconds. ollama list shows the models you have, and ollama pull fetches others from the Ollama model library.

Step 2: Use the API

Ollama runs a local API on port 11434. Any program on the machine can call it:

curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2",
  "prompt": "Summarize the benefits of self-hosted AI in two sentences.",
  "stream": false
}'

Ollama also offers an OpenAI-compatible endpoint at /v1/chat/completions, so many existing tools and SDKs can point at your server by changing the base URL.

Step 3: Add a chat interface

For a ChatGPT-style interface, Open WebUI is a popular choice. On a Linux server with Docker installed, run it on the host network so it can reach Ollama on 127.0.0.1:

docker run -d --network=host \
  -e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
  -v open-webui:/app/backend/data \
  --name open-webui --restart always \
  ghcr.io/open-webui/open-webui:main

Open http://localhost:8080. The first account you create becomes the administrator, and your Ollama models appear in the model list. On a Mac or Windows machine running Docker Desktop, follow the Open WebUI quick start instead, which maps the interface to port 3000.

Step 4: Reach your private AI server from anywhere

So far, the server only works for someone sitting at it. To use it from your laptop, phone, or office, you need a way in, and this is where many self-hosted setups go wrong.

Do not expose Ollama directly to the internet. Ollama's API has no login of its own. Anyone who can reach port 11434 can use your hardware, download your models, and pull new ones. Changing OLLAMA_HOST to 0.0.0.0 and forwarding the port on your router does exactly that.

A safer pattern keeps the server private and controls who can reach it:

Share the chat interface, with sign-in. Install the noBGP agent on the AI server:

curl -fsSL https://downloads.nobgp.com/agent/install.sh | sh

Then publish Open WebUI's port as a noBGP service. You can ask your AI assistant to do it ("publish port 8080 on my ai-server with sign-in required"), or use the noBGP dashboard. The service gets an HTTPS address on nobgp.link, sign-in is required by default, and you grant access to specific people by email. Nothing is opened on your router. Read the publishing services guide.

Reach the API privately from your own machines. Put your laptop and other machines in the same noBGP network as the server. They can then call the API by the server's node name:

curl http://ai-server:11434/api/tags

Ollama can stay bound to 127.0.0.1. A connection from another node arrives at the server as a local connection, so you do not need to change OLLAMA_HOST. Because Ollama has no login, only put the server in a network whose members you trust with it. A node owner can also turn off peer access to loopback-only ports with the peer-loopback setting. Read the core concepts.

Step 5: Let your AI assistant run the server

Once the server is a noBGP node, you can manage it from a conversation with Claude or ChatGPT:

  • "Which models are installed on ai-server, and how much disk do they use?"
  • "Is the GPU on ai-server busy right now? Show me nvidia-smi."
  • "Pull qwen2.5:7b on ai-server and tell me when it's ready."
  • "Is Open WebUI still running? Restart the container if it isn't."

Your assistant runs the commands on the server and reports back, and noBGP's roles and per-machine settings decide what it is allowed to run. See how to run commands on your machines from Claude.

Where self-hosting falls short

Be honest with yourself about the trade-offs:

  • Quality. The largest hosted models are still ahead on hard reasoning and long, complex tasks.
  • Upkeep. Drivers, updates, model versions, and backups are now yours.
  • Speed under load. One GPU serves a handful of people well. A whole company needs more planning.

A common middle path is to keep sensitive work on the private server and send everything else to a hosted model.

Frequently asked questions

What is the best self-hosted AI model?

It depends on your memory and your task. Start with a 7B to 9B model from a current family such as Llama, Qwen, or Gemma, test it on your own work, and move up a size only if the answers are not good enough.

Is a self-hosted LLM really private?

The model runs on your hardware, so prompts are not sent to a model provider. Privacy then depends on who can reach the server, which is why it should not be exposed to the internet without authentication.

Can I run a local AI on Linux without a GPU?

Yes, on the CPU. Small models are usable. Larger ones are slow.

Can I host an LLM on a Raspberry Pi?

The smallest models run on a Raspberry Pi 5 with 8 GB of memory, slowly. A Pi is better used as the always-on gateway in front of a bigger machine.

Build your private AI server

Install Ollama on the most capable machine you already own, try a model, and connect the server to noBGP so you can reach it from anywhere. Start with the agent installation guide.

Put your first device within AI reach.

Choose your path.