LOCAL INFERENCE × CODING AGENTS

From a GGUF
to a coding agent.

Pick one engine to load the model, then connect one harness to give it files, tools, and an agent loop. The model stays on your Mac; the two apps talk over a local HTTP endpoint.

STEP 1 / SERVE THE MODEL

Choose an inference engine.

All three can expose a local API. Ollama minimizes setup, llama.cpp exposes the most knobs, and LM Studio adds a visual model manager.

01

LEAST SETUP

Ollama

Import a downloaded GGUF with a Modelfile, or pull an existing Ollama model. Its launch command can configure supported coding harnesses for you.

Modelfile
FROM ./models/your-model.gguf
PARAMETER num_ctx 65536
Terminal
brew install ollama
ollama create local-model -f ./Modelfile
ollama run local-model
LOCAL APIlocalhost:11434
Ollama GGUF import docs ↗
02

MOST CONTROL

llama.cpp

Point the server directly at a GGUF. Give it a stable alias for harness configuration and enable Jinja templates for tool calls.

Terminal
brew install llama.cpp

llama-server \
  -m ./models/your-model.gguf \
  --alias local-model \
  -c 65536 \
  --jinja
LOCAL APIlocalhost:8080
llama.cpp server docs ↗
03

VISUAL WORKFLOW

LM Studio

Install and open LM Studio once to enable its CLI. Then find and load a model, set a memorable identifier, and start the local server.

Terminal
lms get
lms load <model-key> \
  --identifier=local-model \
  --gpu=max \
  --context-length=65536
lms server start --port 1234
LOCAL APIlocalhost:1234
LM Studio server docs ↗

STEP 2 / PICK A HARNESS

Every useful pairing, at a glance.

Quick or direct Small config file Experimental
Inference enginePiClaude CodeOpenCode
OllamaConfigOne commandOne command
llama.cppConfigExperimentalConfig
LM StudioConfigDirectConfig

Claude Code can target llama.cpp's Anthropic-compatible endpoint, but that path is less complete and less documented than Ollama or LM Studio. Use it as an experiment, not the default.

THE AGENT LAYER

Connect your coding harness.

Start the engine first. Then give the harness the matching base URL and the exact model identifier exposed by that engine.

MINIMAL, EXTENSIBLE

Pi

Add any OpenAI-compatible local server in ~/.pi/agent/models.json, start Pi, then choose the model with /model.

Install
curl -fsSL https://pi.dev/install.sh | sh
~/.pi/agent/models.json
{
  "providers": {
    "local": {
      "baseUrl": "http://localhost:8080/v1",
      "api": "openai-completions",
      "apiKey": "local",
      "compat": {
        "supportsDeveloperRole": false,
        "supportsReasoningEffort": false
      },
      "models": [{
        "id": "local-model",
        "name": "My local model",
        "reasoning": true,
        "contextWindow": 65536,
        "maxTokens": 8192
      }]
    }
  }
}
Pi custom model docs ↗

POLISHED AGENT UX

Claude Code

Ollama has the shortest setup. LM Studio exposes the Anthropic endpoint Claude Code expects. Use a large context window for tool definitions and project files.

Ollama · recommended
curl -fsSL https://claude.ai/install.sh | bash
ollama launch claude --model local-model
LM Studio · direct
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=lmstudio
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model local-model
llama.cpp · experimental
export ANTHROPIC_BASE_URL=http://localhost:8080
export ANTHROPIC_AUTH_TOKEN=llama.cpp
export ANTHROPIC_API_KEY=""
claude --model local-model

OPEN SOURCE HARNESS

OpenCode

Ollama can launch it directly. For llama.cpp or LM Studio, add a custom OpenAI-compatible provider and change only the base URL.

Ollama · fastest path
curl -fsSL https://opencode.ai/install | bash
ollama launch opencode
opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Local model",
      "options": {
        "baseURL": "http://localhost:8080/v1"
      },
      "models": {
        "local-model": {
          "name": "My local model"
        }
      }
    }
  }
}

KEEP THIS HANDY

Endpoint cheat sheet.

Pi and OpenCode use the OpenAI-compatible URL. Claude Code uses the Anthropic base URL where the engine supports it.

EnginePortOpenAI-compatibleAnthropic base
Ollama11434http://localhost:11434/v1http://localhost:11434
llama.cpp8080http://localhost:8080/v1http://localhost:8080
LM Studio1234http://localhost:1234/v1http://localhost:1234

THE CONTEXT TAX

Leave room for the agent to think.

The GGUF file is only the starting point. Context, the KV cache, tool definitions, and the harness itself all need memory. A model that barely fits may slow down or fail once an agent scans a repo.

  • Start at 32K context; move to 64K when the working set remains comfortable.
  • Prefer a smaller, higher-quality quant over a model that leaves no headroom.
  • Coding needs a compatible chat template and reliable tool calling—not just a high benchmark score.
Find a GGUF that fits your Mac →