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"edit_predictions": {
22 "provider": "zed"
23},
24```
25
26The Z icon in the status bar also indicates Zeta is active.
27
28### Pricing and Plans
29
30The 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.
31
32### Switching Modes {#switching-modes}
33
34Zed's Edit Prediction comes with two different display modes:
35
361. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
372. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
38
39Toggle between them via the `mode` key:
40
41```json [settings]
42"edit_predictions": {
43 "mode": "eager" // or "subtle"
44},
45```
46
47Or directly via the UI through the status bar menu:
48
49
50
51> Note that edit prediction modes work with any prediction provider.
52
53### Conflict With Other `tab` Actions {#edit-predictions-conflict}
54
55By default, when `tab` would normally perform a different action, Zed requires a modifier key to accept predictions:
56
571. When the language server completions menu is visible.
582. When your cursor isn't at the right indentation level.
59
60In 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.
61
62On 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.
63
64{#action editor::AcceptNextWordEditPrediction} ({#kb editor::AcceptNextWordEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
65{#action editor::AcceptNextLineEditPrediction} ({#kb editor::AcceptNextLineEditPrediction}) can be used to accept the current edit prediction up to the new line boundary.
66
67## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
68
69By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
70
71```json [settings]
72{
73 "context": "Editor && edit_prediction",
74 "bindings": {
75 // Here we also allow `alt-enter` to accept the prediction
76 "alt-enter": "editor::AcceptEditPrediction"
77 }
78}
79```
80
81When there's a [conflict with the `tab` key](#edit-predictions-conflict), Zed uses a different key context to accept keybindings (`edit_prediction_conflict`).
82If you want to use a different one, you can insert this in your keymap:
83
84```json [settings]
85{
86 "context": "Editor && edit_prediction_conflict",
87 "bindings": {
88 "ctrl-enter": "editor::AcceptEditPrediction" // Example of a modified keybinding
89 }
90}
91```
92
93If 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.
94
95You can also bind this action to keybind without a modifier.
96In that case, Zed will use the default modifier (`alt`) to preview the edit prediction.
97
98```json [settings]
99{
100 "context": "Editor && edit_prediction_conflict",
101 "bindings": {
102 // Here we bind tab to accept even when there's a language server completion
103 // or the cursor isn't at the correct indentation level
104 "tab": "editor::AcceptEditPrediction"
105 }
106}
107```
108
109To 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`:
110
111```json [settings]
112{
113 "context": "Editor && edit_prediction_conflict && !showing_completions",
114 "bindings": {
115 // Here we don't require a modifier unless there's a language server completion
116 "tab": "editor::AcceptEditPrediction"
117 }
118}
119```
120
121### Keybinding Example: Always Use Tab
122
123If you want to use `tab` to always accept edit predictions, you can use the following keybinding:
124
125```json [keymap]
126{
127 "context": "Editor && edit_prediction_conflict && showing_completions",
128 "bindings": {
129 "tab": "editor::AcceptEditPrediction"
130 }
131}
132```
133
134This will make `tab` work to accept edit predictions _even when_ you're also seeing language server completions.
135That means that you need to rely on `enter` for accepting the latter.
136
137### Keybinding Example: Always Use Alt-Tab
138
139The keybinding example below causes `alt-tab` to always be used instead of sometimes using `tab`.
140You 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.
141
142```json [keymap]
143 {
144 "context": "Editor && edit_prediction",
145 "bindings": {
146 "alt-tab": "editor::AcceptEditPrediction"
147 }
148 },
149 // Bind `tab` back to its original behavior.
150 {
151 "context": "Editor",
152 "bindings": {
153 "tab": "editor::Tab"
154 }
155 },
156 {
157 "context": "Editor && showing_completions",
158 "bindings": {
159 "tab": "editor::ComposeCompletion"
160 }
161 },
162```
163
164If you are using [Vim mode](../vim.md), then additional bindings are needed after the above to return `tab` to its original behavior:
165
166```json [keymap]
167 {
168 "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
169 "bindings": {
170 "tab": "vim::Tab"
171 }
172 },
173 {
174 "context": "vim_mode == literal",
175 "bindings": {
176 "tab": ["vim::Literal", ["tab", "\u0009"]]
177 }
178 },
179```
180
181### Keybinding Example: Displaying Tab and Alt-Tab on Linux
182
183While `tab` and `alt-tab` are supported on Linux, `alt-l` is displayed instead.
184If your window manager does not reserve `alt-tab`, and you would prefer to use `tab` and `alt-tab`, include these bindings in `keymap.json`:
185
186```json [keymap]
187 {
188 "context": "Editor && edit_prediction",
189 "bindings": {
190 "tab": "editor::AcceptEditPrediction",
191 // Optional: This makes the default `alt-l` binding do nothing.
192 "alt-l": null
193 }
194 },
195 {
196 "context": "Editor && edit_prediction_conflict",
197 "bindings": {
198 "alt-tab": "editor::AcceptEditPrediction",
199 // Optional: This makes the default `alt-l` binding do nothing.
200 "alt-l": null
201 }
202 },
203```
204
205### Missing keybind {#edit-predictions-missing-keybinding}
206
207Zed 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)).
208
209If 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:
210
211```json [keymap]
212[
213 // Your keymap
214 {
215 "bindings": {
216 // Binds `alt-tab` to a different action globally
217 "alt-tab": "menu::SelectNext"
218 }
219 }
220]
221```
222
223To fix this, you can specify your own keybinding for accepting edit predictions:
224
225```json [keymap]
226[
227 // ...
228 {
229 "context": "Editor && edit_prediction_conflict",
230 "bindings": {
231 "alt-l": "editor::AcceptEditPrediction"
232 }
233 }
234]
235```
236
237If 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.
238
239## Disabling Automatic Edit Prediction
240
241You can disable edit predictions at several levels, or turn them off entirely.
242
243Alternatively, if you have Zed set as your provider, consider [using Subtle Mode](#switching-modes).
244
245### On Buffers
246
247To not have predictions appear automatically as you type, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
248
249```json [settings]
250{
251 "show_edit_predictions": false
252}
253```
254
255This 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).
256Still, you can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} or hitting {#kb editor::ShowEditPrediction}.
257
258### For Specific Languages
259
260To 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)):
261
262```json [settings]
263{
264 "language": {
265 "python": {
266 "show_edit_predictions": false
267 }
268 }
269}
270```
271
272### In Specific Directories
273
274To disable edit predictions for specific directories or files, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
275
276```json [settings]
277{
278 "edit_predictions": {
279 "disabled_globs": ["~/.config/zed/settings.json"]
280 }
281}
282```
283
284### Turning Off Completely
285
286To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
287
288```json [settings]
289"features": {
290 "edit_prediction_provider": "none"
291},
292```
293
294## Configuring Other Providers {#other-providers}
295
296Edit Prediction also works with other providers.
297
298### GitHub Copilot {#github-copilot}
299
300To use GitHub Copilot as your provider, set this in your settings file ([how to edit](../configuring-zed.md#settings-files)):
301
302```json [settings]
303{
304 "features": {
305 "edit_prediction_provider": "copilot"
306 }
307}
308```
309
310To 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.
311
312#### Using GitHub Copilot Enterprise
313
314If 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)):
315
316```json [settings]
317{
318 "edit_predictions": {
319 "copilot": {
320 "enterprise_uri": "https://your.enterprise.domain"
321 }
322 }
323}
324```
325
326Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
327
328Once set, Zed will route Copilot requests through your enterprise endpoint.
329When you sign in by clicking the Copilot icon in the status bar, you will be redirected to your configured enterprise URL to complete authentication.
330All other Copilot features and usage remain the same.
331
332Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
333
334- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
335- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
336
337### Sweep {#sweep}
338
339To use [Sweep](https://sweep.dev/) as your provider:
340
3411. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3422. Search for "Edit Predictions" and click **Configure Providers**
3433. Find the Sweep section and enter your API key from the
344 [Sweep dashboard](https://app.sweep.dev/)
345
346Alternatively, click the edit prediction icon in the status bar and select
347**Configure Providers** from the menu.
348
349After 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:
350
351```json [settings]
352{
353 "edit_predictions": {
354 "provider": "sweep"
355 }
356}
357```
358
359### Mercury Coder {#mercury-coder}
360
361To use [Mercury Coder](https://www.inceptionlabs.ai/) by Inception Labs as your provider:
362
3631. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3642. Search for "Edit Predictions" and click **Configure Providers**
3653. Find the Mercury section and enter your API key from the
366 [Inception Labs dashboard](https://platform.inceptionlabs.ai/dashboard/api-keys)
367
368Alternatively, click the edit prediction icon in the status bar and select
369**Configure Providers** from the menu.
370
371After 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:
372
373```json [settings]
374{
375 "features": {
376 "edit_prediction_provider": "mercury"
377 }
378}
379```
380
381### Codestral {#codestral}
382
383To use Mistral's Codestral as your provider:
384
3851. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3862. Search for "Edit Predictions" and click **Configure Providers**
3873. Find the Codestral section and enter your API key from the
388 [Codestral dashboard](https://console.mistral.ai/codestral)
389
390Alternatively, click the edit prediction icon in the status bar and select
391**Configure Providers** from the menu.
392
393After 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:
394
395```json [settings]
396{
397 "features": {
398 "edit_prediction_provider": "codestral"
399 }
400}
401```
402
403### Self-Hosted OpenAI-compatible servers
404
405To configure Zed to use an arbitrary server for edit predictions:
406
4071. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
4082. Search for "Edit Predictions" and click **Configure Providers**
4093. 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.
410
411The URL must accept requests according to OpenAI's [Completions API](https://developers.openai.com/api/reference/resources/completions/methods/create)
412
413## See also
414
415- [Agent Panel](./agent-panel.md): Agentic editing with file read/write and terminal access
416- [Inline Assistant](./inline-assistant.md): Prompt-driven transformations on selected code