Tidqom — Source-linked AI and developer tools
AITid
AI Tools

Zed Editor Ollama Setup: Fast Local AI Coding Guide

Connect Zed Editor to local Ollama models in under 10 minutes. Fix silent dropouts, tune context windows, and optimize JSON for zero latency.

T
Tidqom Editorial
August 23, 2026 · 5 min read
Zed Editor Ollama Setup: Fast Local AI Coding Guide

Why Zed and Ollama Belong Together

Related: Run LM Studio Headless on Linux: Full CLI Setup Guide →

Zed is currently the fastest code editor on the market. Written in Rust with direct GPU hardware acceleration, it renders UI frames in under 4 milliseconds and opens multi-gigabyte repositories instantly. However, pairing a hyper-efficient editor with cloud-based AI completion services like OpenAI or Anthropic introduces network round-trip overhead. A 300-millisecond API lag breaks the flow state that Zed worked so hard to create.

Running local LLMs through Ollama solves the latency problem. When your code context does not leave your local network, auto-completions stream back at 60 to 110 tokens per second on consumer hardware. You get total privacy, zero monthly API costs, and full offline functionality on airplanes or unstable connections.

Getting Zed to communicate seamlessly with Ollama used to be frustrating. Older versions required third-party plugins, and silent connection drops were common due to base URL mismatches and context window truncations.

Zed now provides native support for local provider endpoints. Setting up a reliable local pipeline requires a few specific edits to your settings.json file, precise context tuning, and an understanding of how Ollama exposes its REST API.


Prerequisites and Local Infrastructure Setup

Related: Connect Cursor IDE to Local Ollama: 2026 Setup →

Before editing your editor configuration, you must verify that Ollama is compiled, running, and accessible across your system's network interfaces.

1. Model Selection for Code Generation

Not all local models handle inline code completion and multi-file reasoning effectively. For modern software development in Zed, stick to models explicitly fine-tuned on instruction and fill-in-the-middle (FIM) programming tasks:

  • Qwen 2.5 Coder (14B or 7B): The current benchmark leader for local development. The 14B variant fits comfortably inside 12GB of VRAM when quantized to Q4_K_M.
  • DeepSeek R1 Distill Qwen (14B): Excellent for complex architectural planning inside Zed's Assistant Panel, though slower for instantaneous inline completion.
  • CodeLlama (13B or 7B): A stable fallback option with native fill-in-the-middle primitives.

Pull your target model from your terminal:

bash
ollama pull qwen2.5-coder:14b

2. Resolving Cross-Origin and Port Access Issues

By default, Ollama binds strictly to 127.0.0.1:11434. If you run Zed inside a Linux container, a remote SSH workspace, or a macOS virtualized environment, Zed will fail to connect with an unhelpful timeout error.

To avoid connection drops, explicitly set the host and allowed origins variables in your shell environment.

On Linux systemd services (/etc/systemd/system/ollama.service.d/override.conf):

ini
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_ORIGINS=*"
Advertisement — In Article

On macOS, launch Ollama with environment variables passed directly if serving outside default localhost bounds:

bash
OLLAMA_ORIGINS="*" OLLAMA_HOST="0.0.0.0:11434" ollama serve

Verify the service is active by querying the base endpoint directly:

bash
curl http://localhost:11434/api/tags

If you receive a JSON array listing qwen2.5-coder:14b, your backend is ready for Zed.


Configuring settings.json for Native Integration

Related: Run OpenHands Locally with Ollama: Step-by-Step Guide →

Zed manages its global and project-level configurations through a central JSON file. You can open this file inside Zed using Cmd+, on macOS or Ctrl+, on Linux, or by triggering the command palette (Cmd+Shift+P / Ctrl+Shift+P) and selecting Zed: Open Settings.

The configuration file resides at:

  • macOS: ~/.config/zed/settings.json or ~/Library/Application Support/Zed/settings.json
  • Linux: ~/.config/zed/settings.json

The Complete 2026 Configuration Block

Insert the following structure into your settings.json. This block defines Ollama as an explicit provider under language_models, configures model limits, and sets up the inline assistant to stream directly from your local hardware.

json
{
  "assistant": {
    "version": "2",
    "default_model": {
      "provider": "ollama",
      "model": "qwen2.5-coder:14b"
    },
    "enabled": true
  },
  "language_models": {
    "ollama": {
      "api_url": "http://localhost:11434",
      "available_models": [
        {
          "name": "qwen2.5-coder:14b",
          "display_name": "Qwen 2.5 Coder 14B (Local)",
          "max_tokens": 16384
        },
        {
          "name": "deepseek-r1:14b",
          "display_name": "DeepSeek R1 14B",
          "max_tokens": 8192
        }
      ]
    }
  }
}

Key Configuration Directives Explained

  1. api_url: Ensure there is no trailing slash (/) at the end of the URL string. Adding http://localhost:11434/ will cause Zed to generate invalid double-slash paths like http://localhost:11434//api/chat, resulting in silent HTTP 404 responses.
  2. version: "2": Instructs Zed to use the modernized Assistant panel schema. Legacy schemas treat provider definitions differently and may silently fall back to default cloud providers.
  3. max_tokens: Matches the token context ceiling configured inside Ollama. Setting this higher than your GPU memory allocation causes background swapping and drops output speeds down to 2 tokens per second.

Context Window Tuning and Hardware Allocation

Related: Enable Ollama Parallel Requests Without OOM Crashes →

Advertisement — In Article

Running local LLMs inside an editor requires balancing memory context against latency. If you assign an 8,000-token context to a 14B model on an 8GB GPU, offloading execution layers to system RAM severely degrades performance.

Ollama defaults to a context window of 2,048 tokens unless explicitly overriden. For real-world coding—where Zed sends current file context, cursor position, and project imports—2,048 tokens is often insufficient.

How to Expand Context in Modelfiles

To grant your Zed setup a larger context window without breaking stability, build a custom Modelfile inside Ollama.

Create a plain text file named Modelfile-zed:

dockerfile
FROM qwen2.5-coder:14b
PARAMETER num_ctx 16384
PARAMETER repeat_penalty 1.1
PARAMETER temperature 0.2

Build this custom image:

bash
ollama create qwen2.5-coder-16k -f ./Modelfile-zed

Then reference qwen2.5-coder-16k directly inside your Zed settings.json.

Hardware Performance Matrix

Use this breakdown to select the right model weight and context ceiling for your specific local hardware setup:

GPU / Hardware SetupModel SelectionQuantizationContext Window (num_ctx)Tokens/SecPeak VRAM Usage
Apple M1/M2/M3 (16GB)Qwen 2.5 Coder 7BQ4_K_M8,192 tokens~55 tok/s~6.2 GB
RTX 3080 / 4070 (12GB)Qwen 2.5 Coder 14BQ4_K_M12,288 tokens~42 tok/s~10.1 GB
RTX 4090 / 3090 (24GB)Qwen 2.5 Coder 14BQ8_032,768 tokens~85 tok/s~18.5 GB
Apple M3/M4 Max (64GB+)DeepSeek R1 32BQ4_K_M16,384 tokens~28 tok/s~24.0 GB

Debugging Silent Connection Failures and Edge Cases

Related: Connect Claude Code CLI to Local Ollama Models →

If the assistant panel shows an endless loading indicator or fails to respond, Zed rarely throws a disruptive pop-up error. Instead, failures are logged internally. Here is how to diagnose and resolve the three most common setup issues.

1. Auditing Internal Zed Diagnostics

When local completions stop responding, open Zed's internal log viewer.

Press Cmd+Shift+P (or Ctrl+Shift+P) and execute:

text
Zed: Open Log
Advertisement — In Article

Filter or scroll to the bottom of the log stream. Look for HTTP transport errors:

text
[ERROR] assistant::provider::ollama: standard error: request to http://localhost:11434/api/chat failed: connect ECONNREFUSED

If you observe ECONNREFUSED, check if:

  • The Ollama background process crashed due to Out-Of-Memory (OOM) constraints.
  • Your host firewall or Docker network interface is blocking local sockets.

2. Fixing Protocol and CORS Mismatches

If you see HTTP 403 Forbidden entries inside the log file, Ollama rejected Zed's request payload because origins were not configured for local API traffic.

Fix this issue by exporting the CORS variable before launching the service:

bash
export OLLAMA_ORIGINS="app://zed,vscode://*,http://localhost:*"
ollama serve

On Windows/WSL2 environments, ensure that WSL can resolve the Windows host's hardware IP. Change your api_url in settings.json from localhost to the host's LAN address or 172.x.x.x gateway mapping.

3. Recovering from High Latency and Context Saturation

If an inline completion takes longer than two seconds to start streaming, your system is likely swapping memory between VRAM and system DRAM.

You can instantly confirm this by monitoring active GPU utilization during a completion request:

bash
# For NVIDIA GPUs
nvidia-smi -l 1

For Apple Silicon Macs

sudo powermetrics --samplers gpu_power -i 1000

terminal

If GPU memory utilization reaches 100% and offloads to system memory, lower the max_tokens field inside your settings.json file down to 4096 or switch from a 14B model weight down to a 7B variant.


FAQ

How do I switch between different local models inside Zed?

Open the Assistant Panel (Cmd+R / Ctrl+R). Click the model selector dropdown located in the lower-right corner of the pane. All models registered under the language_models.ollama.available_models array in your settings.json will appear in this list.

Can I run inline completions and Assistant panel on different Ollama models?

Yes. You can configure a lightweight, ultra-low-latency model (like qwen2.5-coder:7b) for general task execution and assign a larger reasoning model (like deepseek-r1:14b) as your default Assistant model for panel queries. Simply update the model assignments in your settings.json configuration accordingly.

Why is Ollama consuming high GPU memory even when Zed is idle?

Ollama keeps models loaded in GPU memory after the initial inference request to avoid reload delays on subsequent completions. By default, models remain loaded in VRAM for 5 minutes before unloading. You can alter this duration by launching Ollama with a custom keep-alive setting, such as OLLAMA_KEEP_ALIVE=2m.

Does Zed support custom local endpoints like vLLM or LM Studio?

Yes. Any server exposing an OpenAI-compatible REST API or standard Ollama protocol endpoints can be connected. For LM Studio, set the api_url inside your settings.json to http://localhost:1234/v1 and set the provider type to openai while configuring your local model names.

Advertisement

مواضيع مقترحة · Suggested Topics

استكشف مواضيع ومحاور ذات صلة بهذا المقال — روابط داخلية لتعميق قراءتك.

The Daily Pulse

Newsletter delivery is not connected yet. This form only saves your address in this browser; no email is sent.

Get concise, source-linked technology notes without the hype.

Advertisement