edit-prediction.md

  1---
  2title: AI Code Completion in Zed - Zeta, Copilot, Sweep, Mercury Coder
  3description: Set up AI code completions in Zed with Zeta (built-in), GitHub Copilot, Sweep, Codestral, or Mercury Coder. Multi-line predictions on every keystroke.
  4---
  5
  6# Edit Prediction
  7
  8Edit Prediction is how Zed's AI code completions work: an LLM predicts the code you want to write.
  9Each keystroke sends a new request to the edit prediction provider, which returns individual or multi-line suggestions that can be quickly accepted by pressing `tab`.
 10
 11The default provider is [Zeta, a proprietary open source and open dataset model](https://huggingface.co/zed-industries/zeta), but you can also use [other providers](#other-providers) like GitHub Copilot, Sweep, Mercury Coder, and Codestral.
 12
 13## Configuring Zeta
 14
 15To use Zeta, [sign in](../authentication.md#what-features-require-signing-in).
 16Once signed in, predictions appear as you type.
 17
 18You can confirm that Zeta is properly configured either by verifying whether you have the following code in your settings file:
 19
 20```json [settings]
 21{
 22  "edit_predictions": {
 23    "provider": "zed"
 24  }
 25}
 26```
 27
 28The Z icon in the status bar also indicates Zeta is active.
 29
 30### Pricing and Plans
 31
 32The free plan includes 2,000 Zeta predictions per month. The [Pro plan](../ai/plans-and-usage.md) removes this limit. See [Zed's pricing page](https://zed.dev/pricing) for details.
 33
 34### Switching Modes {#switching-modes}
 35
 36Zed's Edit Prediction comes with two different display modes:
 37
 381. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
 392. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
 40
 41Toggle between them via the `mode` key:
 42
 43```json [settings]
 44"edit_predictions": {
 45  "mode": "eager" // or "subtle"
 46},
 47```
 48
 49Or directly via the UI through the status bar menu:
 50
 51![Edit Prediction status bar menu, with the modes toggle.](https://zed.dev/img/edit-prediction/status-bar-menu.webp)
 52
 53> Note that edit prediction modes work with any prediction provider.
 54
 55### Conflict With Other `tab` Actions {#edit-predictions-conflict}
 56
 57By default, when `tab` would normally perform a different action, Zed requires a modifier key to accept predictions:
 58
 591. When the language server completions menu is visible.
 602. When your cursor isn't at the right indentation level.
 61
 62In these cases, `alt-tab` is used instead to accept the prediction. When the language server completions menu is open, holding `alt` first will cause it to temporarily disappear in order to preview the prediction within the buffer.
 63
 64On Linux, `alt-tab` is often used by the window manager for switching windows, so `alt-l` is provided as the default binding for accepting predictions. `tab` and `alt-tab` also work, but aren't displayed by default.
 65
 66{#action editor::AcceptNextWordEditPrediction} ({#kb editor::AcceptNextWordEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
 67{#action editor::AcceptNextLineEditPrediction} ({#kb editor::AcceptNextLineEditPrediction}) can be used to accept the current edit prediction up to the new line boundary.
 68
 69## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
 70
 71By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
 72
 73```json [keymap]
 74{
 75  "context": "Editor && edit_prediction",
 76  "bindings": {
 77    // Here we also allow `alt-enter` to accept the prediction
 78    "alt-enter": "editor::AcceptEditPrediction"
 79  }
 80}
 81```
 82
 83When there's a [conflict with the `tab` key](#edit-predictions-conflict), Zed uses a different key context to accept keybindings (`edit_prediction_conflict`).
 84If you want to use a different one, you can insert this in your keymap:
 85
 86```json [keymap]
 87{
 88  "context": "Editor && edit_prediction_conflict",
 89  "bindings": {
 90    "ctrl-enter": "editor::AcceptEditPrediction" // Example of a modified keybinding
 91  }
 92}
 93```
 94
 95If your keybinding contains a modifier (`ctrl` in the example above), it will also be used to preview the edit prediction and temporarily hide the language server completion menu.
 96
 97You can also bind this action to keybind without a modifier.
 98In that case, Zed will use the default modifier (`alt`) to preview the edit prediction.
 99
100```json [keymap]
101{
102  "context": "Editor && edit_prediction_conflict",
103  "bindings": {
104    // Here we bind tab to accept even when there's a language server completion
105    // or the cursor isn't at the correct indentation level
106    "tab": "editor::AcceptEditPrediction"
107  }
108}
109```
110
111To maintain the use of the modifier key for accepting predictions when there is a language server completions menu, but allow `tab` to accept predictions regardless of cursor position, you can specify the context further with `showing_completions`:
112
113```json [keymap]
114{
115  "context": "Editor && edit_prediction_conflict && !showing_completions",
116  "bindings": {
117    // Here we don't require a modifier unless there's a language server completion
118    "tab": "editor::AcceptEditPrediction"
119  }
120}
121```
122
123### Keybinding Example: Always Use Tab
124
125If you want to use `tab` to always accept edit predictions, you can use the following keybinding:
126
127```json [keymap]
128{
129  "context": "Editor && edit_prediction_conflict && showing_completions",
130  "bindings": {
131    "tab": "editor::AcceptEditPrediction"
132  }
133}
134```
135
136This will make `tab` work to accept edit predictions _even when_ you're also seeing language server completions.
137That means that you need to rely on `enter` for accepting the latter.
138
139### Keybinding Example: Always Use Alt-Tab
140
141The keybinding example below causes `alt-tab` to always be used instead of sometimes using `tab`.
142You might want this in order to have just one (alternative) keybinding to use for accepting edit predictions, since the behavior of `tab` varies based on context.
143
144```json [keymap]
145  {
146    "context": "Editor && edit_prediction",
147    "bindings": {
148      "alt-tab": "editor::AcceptEditPrediction"
149    }
150  },
151  // Bind `tab` back to its original behavior.
152  {
153    "context": "Editor",
154    "bindings": {
155      "tab": "editor::Tab"
156    }
157  },
158  {
159    "context": "Editor && showing_completions",
160    "bindings": {
161      "tab": "editor::ComposeCompletion"
162    }
163  },
164```
165
166If you are using [Vim mode](../vim.md), then additional bindings are needed after the above to return `tab` to its original behavior:
167
168```json [keymap]
169  {
170    "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
171    "bindings": {
172      "tab": "vim::Tab"
173    }
174  },
175  {
176    "context": "vim_mode == literal",
177    "bindings": {
178      "tab": ["vim::Literal", ["tab", "\u0009"]]
179    }
180  },
181```
182
183### Keybinding Example: Displaying Tab and Alt-Tab on Linux
184
185While `tab` and `alt-tab` are supported on Linux, `alt-l` is displayed instead.
186If your window manager does not reserve `alt-tab`, and you would prefer to use `tab` and `alt-tab`, include these bindings in `keymap.json`:
187
188```json [keymap]
189  {
190    "context": "Editor && edit_prediction",
191    "bindings": {
192      "tab": "editor::AcceptEditPrediction",
193      // Optional: This makes the default `alt-l` binding do nothing.
194      "alt-l": null
195    }
196  },
197  {
198    "context": "Editor && edit_prediction_conflict",
199    "bindings": {
200      "alt-tab": "editor::AcceptEditPrediction",
201      // Optional: This makes the default `alt-l` binding do nothing.
202      "alt-l": null
203    }
204  },
205```
206
207### Missing keybind {#edit-predictions-missing-keybinding}
208
209Zed requires at least one keybinding for the {#action editor::AcceptEditPrediction} action in both the `Editor && edit_prediction` and `Editor && edit_prediction_conflict` contexts ([learn more above](#edit-predictions-keybinding)).
210
211If you have previously bound the default keybindings to different actions in the global context, you will not be able to preview or accept edit predictions. For example:
212
213```json [keymap]
214[
215  // Your keymap
216  {
217    "bindings": {
218      // Binds `alt-tab` to a different action globally
219      "alt-tab": "menu::SelectNext"
220    }
221  }
222]
223```
224
225To fix this, you can specify your own keybinding for accepting edit predictions:
226
227```json [keymap]
228[
229  // ...
230  {
231    "context": "Editor && edit_prediction_conflict",
232    "bindings": {
233      "alt-l": "editor::AcceptEditPrediction"
234    }
235  }
236]
237```
238
239If you would like to use the default keybinding, you can free it up by either moving yours to a more specific context or changing it to something else.
240
241## Disabling Automatic Edit Prediction
242
243You can disable edit predictions at several levels, or turn them off entirely.
244
245Alternatively, if you have Zed set as your provider, consider [using Subtle Mode](#switching-modes).
246
247### On Buffers
248
249To not have predictions appear automatically as you type, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
250
251```json [settings]
252{
253  "show_edit_predictions": false
254}
255```
256
257This hides every indication that there is a prediction available, regardless of [the display mode](#switching-modes) you're in (valid only if you have Zed as your provider).
258Still, you can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} or hitting {#kb editor::ShowEditPrediction}.
259
260### For Specific Languages
261
262To not have predictions appear automatically as you type when working with a specific language, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
263
264```json [settings]
265{
266  "languages": {
267    "Python": {
268      "show_edit_predictions": false
269    }
270  }
271}
272```
273
274### In Specific Directories
275
276To disable edit predictions for specific directories or files, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
277
278```json [settings]
279{
280  "edit_predictions": {
281    "disabled_globs": ["~/.config/zed/settings.json"]
282  }
283}
284```
285
286### Turning Off Completely
287
288To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
289
290```json [settings]
291{
292  "edit_predictions": {
293    "provider": "none"
294  }
295}
296```
297
298## Configuring Other Providers {#other-providers}
299
300Edit Prediction also works with other providers.
301
302### GitHub Copilot {#github-copilot}
303
304To use GitHub Copilot as your provider, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
305
306```json [settings]
307{
308  "edit_predictions": {
309    "provider": "copilot"
310  }
311}
312```
313
314To sign in to GitHub Copilot, click on the Copilot icon in the status bar. A popup window appears displaying a device code. Click the copy button to copy the code, then click "Connect to GitHub" to open the GitHub verification page in your browser. Paste the code when prompted. The popup window closes automatically after successful authorization.
315
316#### Using GitHub Copilot Enterprise
317
318If your organization uses GitHub Copilot Enterprise, you can configure Zed to use your enterprise instance by specifying the enterprise URI in your settings file ([how to edit](../configuring-zed.md#settings-files)):
319
320```json [settings]
321{
322  "edit_predictions": {
323    "copilot": {
324      "enterprise_uri": "https://your.enterprise.domain"
325    }
326  }
327}
328```
329
330Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
331
332Once set, Zed will route Copilot requests through your enterprise endpoint.
333When you sign in by clicking the Copilot icon in the status bar, you will be redirected to your configured enterprise URL to complete authentication.
334All other Copilot features and usage remain the same.
335
336Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
337
338- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
339- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
340
341### Sweep {#sweep}
342
343To use [Sweep](https://sweep.dev/) as your provider:
344
3451. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3462. Search for "Edit Predictions" and click **Configure Providers**
3473. Find the Sweep section and enter your API key from the
348   [Sweep dashboard](https://app.sweep.dev/)
349
350Alternatively, click the edit prediction icon in the status bar and select
351**Configure Providers** from the menu.
352
353After adding your API key, Sweep will appear in the provider dropdown in the status bar menu, where you can select it. You can also set it directly in your settings file:
354
355```json [settings]
356{
357  "edit_predictions": {
358    "provider": "sweep"
359  }
360}
361```
362
363### Mercury Coder {#mercury-coder}
364
365To use [Mercury Coder](https://www.inceptionlabs.ai/) by Inception Labs as your provider:
366
3671. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3682. Search for "Edit Predictions" and click **Configure Providers**
3693. Find the Mercury section and enter your API key from the
370   [Inception Labs dashboard](https://platform.inceptionlabs.ai/dashboard/api-keys)
371
372Alternatively, click the edit prediction icon in the status bar and select
373**Configure Providers** from the menu.
374
375After adding your API key, Mercury Coder will appear in the provider dropdown in the status bar menu, where you can select it. You can also set it directly in your settings file:
376
377```json [settings]
378{
379  "edit_predictions": {
380    "provider": "mercury"
381  }
382}
383```
384
385### Codestral {#codestral}
386
387To use Mistral's Codestral as your provider:
388
3891. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3902. Search for "Edit Predictions" and click **Configure Providers**
3913. Find the Codestral section and enter your API key from the
392   [Codestral dashboard](https://console.mistral.ai/codestral)
393
394Alternatively, click the edit prediction icon in the status bar and select
395**Configure Providers** from the menu.
396
397After adding your API key, Codestral will appear in the provider dropdown in the status bar menu, where you can select it. You can also set it directly in your settings file:
398
399```json [settings]
400{
401  "edit_predictions": {
402    "provider": "codestral"
403  }
404}
405```
406
407### Self-Hosted OpenAI-compatible servers
408
409You can use any self-hosted server that implements the OpenAI completion API format. This works with vLLM, llama.cpp server, LocalAI, and other compatible servers.
410
411#### Configuration
412
413Set `open_ai_compatible_api` as your provider and configure the API endpoint:
414
415```json [settings]
416{
417  "edit_predictions": {
418    "provider": "open_ai_compatible_api",
419    "open_ai_compatible_api": {
420      "api_url": "http://localhost:8080/v1/completions",
421      "model": "deepseek-coder-6.7b-base",
422      "prompt_format": "deepseek_coder",
423      "max_output_tokens": 64
424    }
425  }
426}
427```
428
429The `prompt_format` setting controls how code context is formatted for the model. Use `"infer"` to detect the format from the model name, or specify one explicitly:
430
431- `code_llama` - CodeLlama format: `<PRE> prefix <SUF> suffix <MID>`
432- `star_coder` - StarCoder format: `<fim_prefix>prefix<fim_suffix>suffix<fim_middle>`
433- `deepseek_coder` - DeepSeek format with special unicode markers
434- `qwen` - Qwen/CodeGemma format: `<|fim_prefix|>prefix<|fim_suffix|>suffix<|fim_middle|>`
435- `codestral` - Codestral format: `[SUFFIX]suffix[PREFIX]prefix`
436- `glm` - GLM-4 format with code markers
437- `infer` - Auto-detect from model name (default)
438
439Your server must implement the OpenAI `/v1/completions` endpoint. Edit predictions will send POST requests with this format:
440
441```json
442{
443  "model": "your-model-name",
444  "prompt": "formatted-code-context",
445  "max_tokens": 256,
446  "temperature": 0.2,
447  "stop": ["<|endoftext|>", ...]
448}
449```
450
451## See also
452
453- [Agent Panel](./agent-panel.md): Agentic editing with file read/write and terminal access
454- [Inline Assistant](./inline-assistant.md): Prompt-driven transformations on selected code