← All posts

Your GPU, Your Coding Agent: Run borg on a Local LLM and Keep Your Code Private

August 31, 2026 · 5 min read · The xShellz Team

TL;DR

  • borg works with any local LLM provider: set BORG_PROVIDER=ollama and your already-pulled model powers the agent with zero API fees.
  • A local setup keeps all your source code offline: nothing leaves your machine, and the borg binary itself is a single static Go file with no external phoning home.
  • You can switch providers without reinstalling: use Ollama on a desktop, LM Studio for a quick alternative, or a hosted Chuppa model from xShellz when you need more capacity.

Point borg at your local Ollama instance with an environment variable: `export BORG_PROVIDER=ollama` and `borg` will use whatever model you have pulled. No API key, no per-token billing, no internet required. We run this exact setup on our own fleet of Agent Shell boxes (xshellz.box) where developers keep a local model for latency and privacy.

how do i use borg with my local ollama model instead of paying for openai?

Set the `BORG_PROVIDER` environment variable to `ollama`. Then run `borg` as you normally would. That is the only config change. borg detects the Ollama server running on localhost port 11434 by default and queries it for whatever model you have pulled. The agent REPL, one-shot tasks, and `borg learn` all work the same, except every token is processed by your GPU instead of by a cloud API that bills you per thousand tokens. If you later want to go back to a hosted model, change the variable back to `xshellz` and log in with `borg auth login` (on a headless box add `--device`).

how do i connect borg to ollama locally?

First, confirm Ollama is running and you have pulled at least one model. Then point borg at it with a single environment variable. The following three commands get you from nothing to an agent session:

# Ensure Ollama is running with a model pulled
ollama pull llama3.2:latest

# Tell borg to use Ollama
export BORG_PROVIDER=ollama

# Start the agent REPL
borg

You can also set `BORG_OLLAMA_HOST` if your Ollama is not on localhost:11434, but for a local development machine the defaults just work. borg is a single static Go binary (install it with `curl -fsSL https://turborg.com/install.sh | sh`), so there is no Python environment or Docker container to wire up. When you run `borg`, it reads the provider env var, finds your Ollama instance, and uses the default model: Ollama's own concept of the currently loaded model, or whichever you specify in borg's config file at `~/.config/borg/`.

can i run an ai coding agent without an internet connection?

Yes. borg itself is one static Go binary with no runtime dependencies, so it never phones home during a session. Ollama loads models from your local disk and runs them entirely on your own hardware. Put the two together on a laptop with no network cable, and you can still ask borg to "fix the failing test" or write a Pull Request description. The one exception is the first time you pull a model with Ollama, which requires a download. After that, the model stays on disk and every subsequent coding session is fully offline.

what is the fastest way to use borg with lm studio?

LM Studio serves its local models through an OpenAI-compatible API on port 1234 by default. Treat it exactly like an OpenAI endpoint, but point it at localhost. Set two environment variables:

export BORG_PROVIDER=openai
export BORG_API_BASE=http://localhost:1234/v1
borg

No API key is needed because the traffic stays on your machine. borg talks to LM Studio's endpoint without any custom shim; it is the same binary, the same REPL, and the same `borg learn` workflow. Toggle back to a hosted provider by changing those two variables. This pattern works with any OpenAI-compatible local server, including text-generation-webui and llama.cpp server. When a new LM Studio release changes the port, adjust `BORG_API_BASE` and restart borg.

how much does it cost to run borg with local models vs hosted models?

A local model costs only the electricity your GPU draws. borg itself is free and open source. Hosted models such as Chuppa Flash, Chuppa Pro, Floko, and Axiom have per-token pricing; you can check the exact rates on the pricing page. The meaningful difference is control. Local models do not generate a surprise bill, and you can iterate all day on a tricky refactor without a meter running. Hosted models remove the hardware requirement and give you access to larger context windows, but the cost is tied to usage. Many developers run a local model for most tasks and switch to a hosted model only when they need more capacity, toggling `BORG_PROVIDER` back and forth.

Frequently asked questions

can i run borg with a remote ollama server instead of localhost?

Yes. Set `BORG_OLLAMA_HOST` to the server's IP address and port (for example, `http://192.168.1.50:11434\`). Make sure the port is reachable and that Ollama's bind setting allows remote connections. borg treats it exactly like a local instance; the model still runs on remote hardware while borg runs on your terminal.

does `borg learn` work with local models the same as with hosted ones?

`borg learn` scans your repository and writes a `BORG.md` context file. The model does not participate in that scan, so the local versus hosted distinction does not matter for this command. When you later use borg for coding tasks, the local model reads the generated `BORG.md` just like any other file, same as a hosted model would.

what if ollama does not have the model i want?

Pull the model first with `ollama pull `. borg will query whatever model Ollama currently serves. If you need a model not available in Ollama's library, use LM Studio as the local provider instead, because LM Studio supports GGUF model files you download and load directly. borg requires no code changes to switch between these backends.