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
304> **Changed in Preview (v0.225).** See [release notes](/releases#0.225).
305
306To use GitHub Copilot as your provider, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
307
308```json [settings]
309{
310  "edit_predictions": {
311    "provider": "copilot"
312  }
313}
314```
315
316To 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.
317
318#### Using GitHub Copilot Enterprise
319
320If 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)):
321
322```json [settings]
323{
324  "edit_predictions": {
325    "copilot": {
326      "enterprise_uri": "https://your.enterprise.domain"
327    }
328  }
329}
330```
331
332Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
333
334Once set, Zed will route Copilot requests through your enterprise endpoint.
335When you sign in by clicking the Copilot icon in the status bar, you will be redirected to your configured enterprise URL to complete authentication.
336All other Copilot features and usage remain the same.
337
338Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
339
340- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
341- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
342
343### Sweep {#sweep}
344
345To use [Sweep](https://sweep.dev/) as your provider:
346
3471. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3482. Search for "Edit Predictions" and click **Configure Providers**
3493. Find the Sweep section and enter your API key from the
350   [Sweep dashboard](https://app.sweep.dev/)
351
352Alternatively, click the edit prediction icon in the status bar and select
353**Configure Providers** from the menu.
354
355After 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:
356
357```json [settings]
358{
359  "edit_predictions": {
360    "provider": "sweep"
361  }
362}
363```
364
365### Mercury Coder {#mercury-coder}
366
367To use [Mercury Coder](https://www.inceptionlabs.ai/) by Inception Labs as your provider:
368
3691. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3702. Search for "Edit Predictions" and click **Configure Providers**
3713. Find the Mercury section and enter your API key from the
372   [Inception Labs dashboard](https://platform.inceptionlabs.ai/dashboard/api-keys)
373
374Alternatively, click the edit prediction icon in the status bar and select
375**Configure Providers** from the menu.
376
377After 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:
378
379```json [settings]
380{
381  "edit_predictions": {
382    "provider": "mercury"
383  }
384}
385```
386
387### Codestral {#codestral}
388
389To use Mistral's Codestral as your provider:
390
3911. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3922. Search for "Edit Predictions" and click **Configure Providers**
3933. Find the Codestral section and enter your API key from the
394   [Codestral dashboard](https://console.mistral.ai/codestral)
395
396Alternatively, click the edit prediction icon in the status bar and select
397**Configure Providers** from the menu.
398
399After 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:
400
401```json [settings]
402{
403  "edit_predictions": {
404    "provider": "codestral"
405  }
406}
407```
408
409### Self-Hosted OpenAI-compatible servers
410
411To configure Zed to use an arbitrary server for edit predictions:
412
4131. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
4142. Search for "Edit Predictions" and click **Configure Providers**
4153. Find the "OpenAI-compatible API" section and enter the URL and model name. You can also select a prompt format that Zed should use. Zed currently supports several FIM prompt formats, as well as Zed's own Zeta prompt format. If you do not select a prompt format, Zed will attempt to infer it from the model name.
416
417The URL must accept requests according to OpenAI's [Completions API](https://developers.openai.com/api/reference/resources/completions/methods/create)
418
419## See also
420
421- [Agent Panel](./agent-panel.md): Agentic editing with file read/write and terminal access
422- [Inline Assistant](./inline-assistant.md): Prompt-driven transformations on selected code