← All posts

Stop Wasting API Tokens: Point borg at Your Local Ollama Instance

August 3, 2026 · 4 min read · The xShellz Team

TL;DR

  • borg supports Ollama as a bring-your-own-model backend, so you can point it at any model you run locally.
  • Set two environment variables, BORG_API_BASE and BORG_MODEL, to connect borg to your Ollama instance.
  • No code leaves your machine: all prompts and completions stay on your own hardware.

Install borg with curl -fsSL https://turborg.com/install.sh | sh, pull your Ollama model, then export two environment variables: BORG_API_BASE=http://localhost:11434/v1 and BORG_MODEL=your-model. After that, borg will talk to your local LLM for every session. We run borg this way on our own fleet, pointing it at Ollama instances daily.

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

borg is a single static Go binary from xShellz that runs on any machine without a runtime. To replace OpenAI with Ollama, you need an Ollama server running, a model pulled, and two environment variables that tell borg where to find it. Set BORG_API_BASE to http://localhost:11434/v1 (Ollama's OpenAI-compatible endpoint) and BORG_MODEL to the model name you pulled, for example codellama. Start borg with borg in a terminal; it picks up those variables immediately. You never hit an external API again.

how to connect borg to ollama

The connection uses Ollama's local API, which borg treats like any OpenAI-compatible backend. Here are the exact three steps.

# 1. Install borg (static binary, no runtime)
curl -fsSL https://turborg.com/install.sh | sh

# 2. Start Ollama and pull a coding model
ollama pull codellama

# 3. Export the endpoint and model name
export BORG_API_BASE=http://localhost:11434/v1
export BORG_MODEL=codellama

# 4. Launch borg
borg

The configuration lives in ~/.config/borg/ and respects the BORG_* environment variable prefix, so you can also persist these settings in your shell profile or in a .env file sourced before running borg.

can i run borg ai agent locally with no api costs

Yes, zero API costs. borg is a bring-your-own-model agent. When you point it at Ollama, every prompt and completion stays on your own hardware: no token meters, no monthly bills. The binary itself is free and runs on CPU-only boxes, though an NVIDIA GPU or Apple Silicon will give you faster inference. Our team has been running borg on local Ollama instances for production codebases for months, and the only recurring cost is electricity.

how to configure borg to use a local llm

Configuration is split between environment variables prefixed with BORG_ and files under ~/.config/borg/. For any OpenAI-compatible local LLM (not just Ollama), set BORG_API_BASE to the server's address and BORG_MODEL to the model ID. If you prefer a config file, create ~/.config/borg/config.json with a JSON object containing api_base and model keys, or use a .env file with BORG_API_BASE and BORG_MODEL. Every time borg starts, it reads these settings. No restart is needed; just open a new terminal session or source the env file.

is borg ai agent private if i use my own model

Absolutely. When you run Ollama locally and point borg at it, none of your code, prompts, or completions ever leave your machine. There is no phoning home, no telemetry, and no intermediate proxy (unless you configure one). The only traffic is between the borg binary and Ollama on localhost. This is the same setup we use internally for sensitive codebases. For an added layer of isolation, you can even run borg inside an Agent Shell sandbox that never touches a public network.

Frequently asked questions

Does borg work with any Ollama model?

Yes. Any model you pull with ollama pull can be used as long as it exposes the OpenAI-compatible endpoint. borg sends standard chat-completion requests, so coding-focused models like Code Llama, DeepSeek Coder, or Mixtral work out of the box.

Do I need to run borg auth login for local models?

No. The borg auth login command is only for hosted xShellz models. When you bring your own Ollama instance, authentication is skipped entirely. Just set the environment variables and start borg.

What happens if I switch back to OpenAI later?

Overwrite the environment variables or config to point at https://api.openai.com/v1 and set BORG_MODEL to a GPT model. borg picks up the change instantly. No reinstallation, no separate binary.