edit-prediction.md

  1---
  2title: AI Code Completion in Zed - Zeta, Copilot, Codestral, Mercury Coder
  3description: Set up AI code completions in Zed with Zeta (built-in), GitHub Copilot, 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 you accept 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, 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 by opening the [Settings Editor](zed://settings/edit_predictions.providers) (`Cmd+,` on macOS or `Ctrl+,` on Linux/Windows) and searching for `edit_predictions`. The `provider` field should be set to `Zed AI`.
 19
 20Or verify this in your settings.json:
 21
 22```json [settings]
 23{
 24  "edit_predictions": {
 25    "provider": "zed"
 26  }
 27}
 28```
 29
 30The Z icon in the status bar also indicates Zeta is active.
 31
 32### Pricing and Plans
 33
 34The 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.
 35
 36### Switching Modes {#switching-modes}
 37
 38Edit Prediction has two display modes:
 39
 401. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
 412. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
 42
 43Toggle between them via the `mode` key:
 44
 45```json [settings]
 46"edit_predictions": {
 47  "mode": "eager" // or "subtle"
 48},
 49```
 50
 51Or directly via the UI through the status bar menu:
 52
 53![Edit Prediction status bar menu, with the modes toggle.](https://zed.dev/img/edit-prediction/status-bar-menu.webp)
 54
 55> Note that edit prediction modes work with any prediction provider.
 56
 57## Default Key Bindings
 58
 59On macOS and Windows, you can accept edit predictions with `alt-tab`. On Linux, `alt-tab` is often used by the window manager for switching windows, so `alt-l` is the default key binding for edit predictions.
 60
 61In `eager` mode, you can also use the `tab` key to accept edit predictions, unless the completion menu is open, in which case `tab` accepts LSP completions. To use `tab` to insert whitespace, you need to dismiss the prediction with {#kb editor::Cancel} before hitting `tab`.
 62
 63{#action editor::AcceptNextWordEditPrediction} ({#kb editor::AcceptNextWordEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
 64{#action editor::AcceptNextLineEditPrediction} ({#kb editor::AcceptNextLineEditPrediction}) can be used to accept the current edit prediction up to the new line boundary.
 65
 66## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
 67
 68### Keybinding Example: Always Use Tab
 69
 70To always use `tab` for accepting edit predictions, regardless of whether the LSP completions menu is open, you can add the following to your keymap:
 71
 72Open the keymap editor with {#action zed::OpenKeymap} ({#kb zed::OpenKeymap}), search for `AcceptEditPrediction`, right click on the binding for `tab` and hit `edit`. Then change the context the binding is active in to just `Editor && edit_prediction` and save it.
 73
 74Alternatively, you can put the following in your `keymap.json`:
 75
 76```json [keymap]
 77[
 78  {
 79    "context": "Editor && edit_prediction",
 80    "bindings": {
 81      "tab": "editor::AcceptEditPrediction"
 82    }
 83  }
 84]
 85```
 86
 87After that, {#kb editor::ComposeCompletion} remains available for accepting LSP completions.
 88
 89### Keybinding Example: Always Use Alt-Tab
 90
 91To stop using `tab` for accepting edit predictions and always use `alt-tab` instead, unbind the default `tab` binding in the eager edit prediction context:
 92
 93Open the keymap editor with {#action zed::OpenKeymap} ({#kb zed::OpenKeymap}), search for `AcceptEditPrediction`, right click on the binding for `tab` and delete it.
 94
 95Alternatively, you can put the following in your `keymap.json`:
 96
 97```json [keymap]
 98[
 99  {
100    "context": "Editor && edit_prediction",
101    "unbind": {
102      "tab": "editor::AcceptEditPrediction"
103    }
104  }
105]
106```
107
108After that, `alt-tab` remains available for accepting edit predictions, and on Linux `alt-l` does too unless you unbind it.
109
110### Keybinding Example: Rebind Both Tab and Alt-Tab
111
112To move both default accept bindings to something else, unbind them and add your replacement:
113
114Open the keymap editor with {#action zed::OpenKeymap} ({#kb zed::OpenKeymap}), search for `AcceptEditPrediction`, right click on the binding for `tab` and delete it. Then right click on the binding for `alt-tab`, select "Edit", and record your desired keystrokes before hitting saving.
115
116Alternatively, you can put the following in your `keymap.json`:
117
118```json [keymap]
119[
120  {
121    "context": "Editor && edit_prediction",
122    "unbind": {
123      "alt-tab": "editor::AcceptEditPrediction",
124      // Add this as well on Windows/Linux
125      // "alt-l": "editor::AcceptEditPrediction",
126      "tab": "editor::AcceptEditPrediction"
127    },
128    "bindings": {
129      "ctrl-enter": "editor::AcceptEditPrediction"
130    }
131  }
132]
133```
134
135In this case, because the binding contains the modifier `ctrl`, it will be used to preview the prediction in subtle mode, or when the completions menu is open.
136
137### Cleaning Up Older Keymap Entries
138
139If you configured edit prediction keybindings before Zed `v0.229.0`, your `keymap.json` may have entries that are now redundant.
140
141**Old tab workaround**: Before `unbind` existed, the only way to prevent `tab` from accepting edit predictions was to copy all the default non-edit-prediction `tab` bindings into your keymap alongside a custom `AcceptEditPrediction` binding. If your keymap still contains those copy-pasted entries, delete them and use a single `"unbind"` entry as shown in the examples above.
142
143**Renamed context**: The `edit_prediction_conflict` context has been replaced by `edit_prediction && (showing_completions || in_leading_whitespace)`. Zed automatically migrates any bindings that used `edit_prediction_conflict`, so no changes are required on your end.
144
145## Disabling Automatic Edit Prediction
146
147You can disable edit predictions at several levels, or turn them off entirely.
148
149Alternatively, if you have Zed set as your provider, consider [using Subtle Mode](#switching-modes).
150
151### On Buffers
152
153To not have predictions appear automatically as you type, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
154
155```json [settings]
156{
157  "show_edit_predictions": false
158}
159```
160
161This 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).
162Still, you can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} or hitting {#kb editor::ShowEditPrediction}.
163
164### For Specific Languages
165
166To 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)):
167
168```json [settings]
169{
170  "languages": {
171    "Python": {
172      "show_edit_predictions": false
173    }
174  }
175}
176```
177
178### In Specific Directories
179
180To disable edit predictions for specific directories or files, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
181
182```json [settings]
183{
184  "edit_predictions": {
185    "disabled_globs": ["~/.config/zed/settings.json"]
186  }
187}
188```
189
190### Turning Off Completely
191
192To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
193
194```json [settings]
195{
196  "edit_predictions": {
197    "provider": "none"
198  }
199}
200```
201
202## Configuring Other Providers {#other-providers}
203
204Edit Prediction also works with other providers.
205
206### GitHub Copilot {#github-copilot}
207
208To use GitHub Copilot as your provider, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
209
210```json [settings]
211{
212  "edit_predictions": {
213    "provider": "copilot"
214  }
215}
216```
217
218To 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.
219
220#### Using GitHub Copilot Enterprise
221
222If 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)):
223
224```json [settings]
225{
226  "edit_predictions": {
227    "copilot": {
228      "enterprise_uri": "https://your.enterprise.domain"
229    }
230  }
231}
232```
233
234Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
235
236Once set, Zed routes Copilot requests through your enterprise endpoint.
237When you sign in by clicking the Copilot icon in the status bar, you are redirected to your configured enterprise URL to complete authentication.
238All other Copilot features and usage remain the same.
239
240Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
241
242- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
243- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
244
245### Mercury Coder {#mercury-coder}
246
247To use [Mercury Coder](https://www.inceptionlabs.ai/) by Inception Labs as your provider:
248
2491. Open the Settings Editor ({#kb zed::OpenSettings})
2502. Search for "Edit Predictions" and click **Configure Providers**
2513. Find the Mercury section and enter your API key from the
252   [Inception Labs dashboard](https://platform.inceptionlabs.ai/dashboard/api-keys)
253
254Alternatively, click the edit prediction icon in the status bar and select
255**Configure Providers** from the menu.
256
257After 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:
258
259```json [settings]
260{
261  "edit_predictions": {
262    "provider": "mercury"
263  }
264}
265```
266
267### Codestral {#codestral}
268
269To use Mistral's Codestral as your provider:
270
2711. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
2722. Search for "Edit Predictions" and click **Configure Providers**
2733. Find the Codestral section and enter your API key from the
274   [Codestral dashboard](https://console.mistral.ai/codestral)
275
276Alternatively, click the edit prediction icon in the status bar and select
277**Configure Providers** from the menu.
278
279After 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:
280
281```json [settings]
282{
283  "edit_predictions": {
284    "provider": "codestral"
285  }
286}
287```
288
289### Self-Hosted OpenAI-compatible servers
290
291You 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.
292
293#### Configuration
294
295Set `open_ai_compatible_api` as your provider and configure the API endpoint:
296
297```json [settings]
298{
299  "edit_predictions": {
300    "provider": "open_ai_compatible_api",
301    "open_ai_compatible_api": {
302      "api_url": "http://localhost:8080/v1/completions",
303      "model": "deepseek-coder-6.7b-base",
304      "prompt_format": "deepseek_coder",
305      "max_output_tokens": 64
306    }
307  }
308}
309```
310
311The `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:
312
313- `code_llama` - CodeLlama format: `<PRE> prefix <SUF> suffix <MID>`
314- `star_coder` - StarCoder format: `<fim_prefix>prefix<fim_suffix>suffix<fim_middle>`
315- `deepseek_coder` - DeepSeek format with special unicode markers
316- `qwen` - Qwen/CodeGemma format: `<|fim_prefix|>prefix<|fim_suffix|>suffix<|fim_middle|>`
317- `codestral` - Codestral format: `[SUFFIX]suffix[PREFIX]prefix`
318- `glm` - GLM-4 format with code markers
319- `infer` - Auto-detect from model name (default)
320
321Your server must implement the OpenAI `/v1/completions` endpoint. Edit predictions will send POST requests with this format:
322
323```json
324{
325  "model": "your-model-name",
326  "prompt": "formatted-code-context",
327  "max_tokens": 256,
328  "temperature": 0.2,
329  "stop": ["<|endoftext|>", ...]
330}
331```
332
333## See also
334
335- [Agent Panel](./agent-panel.md): Agentic editing with file read/write and terminal access
336- [Inline Assistant](./inline-assistant.md): Prompt-driven transformations on selected code