configuration.md

  1# Configuration
  2
  3There are various aspects about the Agent Panel that you can customize.
  4All of them can be seen by either visiting [the Configuring Zed page](./configuring-zed.md#agent) or by running the `zed: open default settings` action and searching for `"agent"`.
  5Alternatively, you can also visit the panel's Settings view by running the `agent: open configuration` action or going to the top-right menu and hitting "Settings".
  6
  7## LLM Providers
  8
  9Zed supports multiple large language model providers.
 10Here's an overview of the supported providers and tool call support:
 11
 12| Provider                                        | Tool Use Supported                                                                                                                                                          |
 13| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
 14| [Anthropic](#anthropic)                         | βœ…                                                                                                                                                                          |
 15| [GitHub Copilot Chat](#github-copilot-chat)     | For Some Models ([link](https://github.com/zed-industries/zed/blob/9e0330ba7d848755c9734bf456c716bddf0973f3/crates/language_models/src/provider/copilot_chat.rs#L189-L198)) |
 16| [Google AI](#google-ai)                         | βœ…                                                                                                                                                                          |
 17| [Mistral](#mistral)                             | βœ…                                                                                                                                                                          |
 18| [Ollama](#ollama)                               | βœ…                                                                                                                                                                          |
 19| [OpenAI](#openai)                               | βœ…                                                                                                                                                                          |
 20| [DeepSeek](#deepseek)                           | 🚫                                                                                                                                                                          |
 21| [OpenAI API Compatible](#openai-api-compatible) | 🚫                                                                                                                                                                          |
 22| [LM Studio](#lmstudio)                          | 🚫                                                                                                                                                                          |
 23
 24## Use Your Own Keys {#use-your-own-keys}
 25
 26While Zed offers hosted versions of models through [our various plans](/ai/plans-and-usage), we're always happy to support users wanting to supply their own API keys.
 27Below, you can learn how to do that for each provider.
 28
 29> Using your own API keys is _free_β€”you do not need to subscribe to a Zed plan to use our AI features with your own keys.
 30
 31### Anthropic {#anthropic}
 32
 33> βœ… Supports tool use
 34
 35You can use Anthropic models by choosing it via the model dropdown in the Agent Panel.
 36
 371. Sign up for Anthropic and [create an API key](https://console.anthropic.com/settings/keys)
 382. Make sure that your Anthropic account has credits
 393. Open the settings view (`agent: open configuration`) and go to the Anthropic section
 404. Enter your Anthropic API key
 41
 42Even if you pay for Claude Pro, you will still have to [pay for additional credits](https://console.anthropic.com/settings/plans) to use it via the API.
 43
 44Zed will also use the `ANTHROPIC_API_KEY` environment variable if it's defined.
 45
 46#### Anthropic Custom Models {#anthropic-custom-models}
 47
 48You can add custom models to the Anthropic provider by adding the following to your Zed `settings.json`:
 49
 50```json
 51{
 52  "language_models": {
 53    "anthropic": {
 54      "available_models": [
 55        {
 56          "name": "claude-3-5-sonnet-20240620",
 57          "display_name": "Sonnet 2024-June",
 58          "max_tokens": 128000,
 59          "max_output_tokens": 2560,
 60          "cache_configuration": {
 61            "max_cache_anchors": 10,
 62            "min_total_token": 10000,
 63            "should_speculate": false
 64          },
 65          "tool_override": "some-model-that-supports-toolcalling"
 66        }
 67      ]
 68    }
 69  }
 70}
 71```
 72
 73Custom models will be listed in the model dropdown in the Agent Panel.
 74
 75You can configure a model to use [extended thinking](https://docs.anthropic.com/en/docs/about-claude/models/extended-thinking-models) (if it supports it),
 76by changing the mode in of your models configuration to `thinking`, for example:
 77
 78```json
 79{
 80  "name": "claude-3-7-sonnet-latest",
 81  "display_name": "claude-3-7-sonnet-thinking",
 82  "max_tokens": 200000,
 83  "mode": {
 84    "type": "thinking",
 85    "budget_tokens": 4_096
 86  }
 87}
 88```
 89
 90### GitHub Copilot Chat {#github-copilot-chat}
 91
 92> βœ… Supports tool use in some cases.
 93> Visit [the Copilot Chat code](https://github.com/zed-industries/zed/blob/9e0330ba7d848755c9734bf456c716bddf0973f3/crates/language_models/src/provider/copilot_chat.rs#L189-L198) for the supported subset.
 94
 95You can use GitHub Copilot chat with the Zed assistant by choosing it via the model dropdown in the Agent Panel.
 96
 97### Google AI {#google-ai}
 98
 99> βœ… Supports tool use
100
101You can use Gemini 1.5 Pro/Flash with the Zed assistant by choosing it via the model dropdown in the Agent Panel.
102
1031. Go the Google AI Studio site and [create an API key](https://aistudio.google.com/app/apikey).
1042. Open the settings view (`agent: open configuration`) and go to the Google AI section
1053. Enter your Google AI API key and press enter.
106
107The Google AI API key will be saved in your keychain.
108
109Zed will also use the `GOOGLE_AI_API_KEY` environment variable if it's defined.
110
111#### Google AI custom models {#google-ai-custom-models}
112
113By default Zed will use `stable` versions of models, but you can use specific versions of models, including [experimental models](https://ai.google.dev/gemini-api/docs/models/experimental-models) with the Google AI provider by adding the following to your Zed `settings.json`:
114
115```json
116{
117  "language_models": {
118    "google": {
119      "available_models": [
120        {
121          "name": "gemini-1.5-flash-latest",
122          "display_name": "Gemini 1.5 Flash (Latest)",
123          "max_tokens": 1000000
124        }
125      ]
126    }
127  }
128}
129```
130
131Custom models will be listed in the model dropdown in the Agent Panel.
132
133### Mistral {#mistral}
134
135> πŸ”¨Supports tool use
136
1371. Visit the Mistral platform and [create an API key](https://console.mistral.ai/api-keys/)
1382. Open the configuration view (`assistant: show configuration`) and navigate to the Mistral section
1393. Enter your Mistral API key
140
141The Mistral API key will be saved in your keychain.
142
143Zed will also use the `MISTRAL_API_KEY` environment variable if it's defined.
144
145#### Mistral Custom Models {#mistral-custom-models}
146
147The Zed Assistant comes pre-configured with several Mistral models (codestral-latest, mistral-large-latest, mistral-medium-latest, mistral-small-latest, open-mistral-nemo, and open-codestral-mamba). All the default models support tool use. If you wish to use alternate models or customize their parameters, you can do so by adding the following to your Zed `settings.json`:
148
149```json
150{
151  "language_models": {
152    "mistral": {
153      "api_url": "https://api.mistral.ai/v1",
154      "available_models": [
155        {
156          "name": "mistral-tiny-latest",
157          "display_name": "Mistral Tiny",
158          "max_tokens": 32000,
159          "max_output_tokens": 4096,
160          "max_completion_tokens": 1024,
161          "supports_tools": true
162        }
163      ]
164    }
165  }
166}
167```
168
169Custom models will be listed in the model dropdown in the assistant panel.
170
171### Ollama {#ollama}
172
173> βœ… Supports tool use
174
175Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
176
1771. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
178
179   ```sh
180   ollama pull mistral
181   ```
182
1832. Make sure that the Ollama server is running. You can start it either via running Ollama.app (macOS) or launching:
184
185   ```sh
186   ollama serve
187   ```
188
1893. In the Agent Panel, select one of the Ollama models using the model dropdown.
190
191#### Ollama Context Length {#ollama-context}
192
193Zed has pre-configured maximum context lengths (`max_tokens`) to match the capabilities of common models.
194Zed API requests to Ollama include this as `num_ctx` parameter, but the default values do not exceed `16384` so users with ~16GB of ram are able to use most models out of the box.
195See [get_max_tokens in ollama.rs](https://github.com/zed-industries/zed/blob/main/crates/ollama/src/ollama.rs) for a complete set of defaults.
196
197> **Note**: Tokens counts displayed in the Agent Panel are only estimates and will differ from the models native tokenizer.
198
199Depending on your hardware or use-case you may wish to limit or increase the context length for a specific model via settings.json:
200
201```json
202{
203  "language_models": {
204    "ollama": {
205      "api_url": "http://localhost:11434",
206      "available_models": [
207        {
208          "name": "qwen2.5-coder",
209          "display_name": "qwen 2.5 coder 32K",
210          "max_tokens": 32768,
211          "supports_tools": true
212        }
213      ]
214    }
215  }
216}
217```
218
219If you specify a context length that is too large for your hardware, Ollama will log an error. You can watch these logs by running: `tail -f ~/.ollama/logs/ollama.log` (MacOS) or `journalctl -u ollama -f` (Linux). Depending on the memory available on your machine, you may need to adjust the context length to a smaller value.
220
221You may also optionally specify a value for `keep_alive` for each available model. This can be an integer (seconds) or alternately a string duration like "5m", "10m", "1h", "1d", etc., For example `"keep_alive": "120s"` will allow the remote server to unload the model (freeing up GPU VRAM) after 120seconds.
222
223The `supports_tools` option controls whether or not the model will use additional tools.
224If the model is tagged with `tools` in the Ollama catalog this option should be supplied, and built in profiles `Ask` and `Write` can be used.
225If the model is not tagged with `tools` in the Ollama catalog, this
226option can still be supplied with value `true`; however be aware that only the
227`Minimal` built in profile will work.
228
229### OpenAI {#openai}
230
231> βœ… Supports tool use
232
2331. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
2342. Make sure that your OpenAI account has credits
2353. Open the settings view (`agent: open configuration`) and go to the OpenAI section
2364. Enter your OpenAI API key
237
238The OpenAI API key will be saved in your keychain.
239
240Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
241
242#### OpenAI Custom Models {#openai-custom-models}
243
244The Zed Assistant comes pre-configured to use the latest version for common models (GPT-3.5 Turbo, GPT-4, GPT-4 Turbo, GPT-4o, GPT-4o mini). If you wish to use alternate models, perhaps a preview release or a dated model release or you wish to control the request parameters you can do so by adding the following to your Zed `settings.json`:
245
246```json
247{
248  "language_models": {
249    "openai": {
250      "available_models": [
251        {
252          "name": "gpt-4o-2024-08-06",
253          "display_name": "GPT 4o Summer 2024",
254          "max_tokens": 128000
255        },
256        {
257          "name": "o1-mini",
258          "display_name": "o1-mini",
259          "max_tokens": 128000,
260          "max_completion_tokens": 20000
261        }
262      ],
263      "version": "1"
264    }
265  }
266}
267```
268
269You must provide the model's Context Window in the `max_tokens` parameter, this can be found [OpenAI Model Docs](https://platform.openai.com/docs/models). OpenAI `o1` models should set `max_completion_tokens` as well to avoid incurring high reasoning token costs. Custom models will be listed in the model dropdown in the Agent Panel.
270
271### DeepSeek {#deepseek}
272
273> 🚫 Does not support tool use
274
2751. Visit the DeepSeek platform and [create an API key](https://platform.deepseek.com/api_keys)
2762. Open the settings view (`agent: open configuration`) and go to the DeepSeek section
2773. Enter your DeepSeek API key
278
279The DeepSeek API key will be saved in your keychain.
280
281Zed will also use the `DEEPSEEK_API_KEY` environment variable if it's defined.
282
283#### DeepSeek Custom Models {#deepseek-custom-models}
284
285The Zed Assistant comes pre-configured to use the latest version for common models (DeepSeek Chat, DeepSeek Reasoner). If you wish to use alternate models or customize the API endpoint, you can do so by adding the following to your Zed `settings.json`:
286
287```json
288{
289  "language_models": {
290    "deepseek": {
291      "api_url": "https://api.deepseek.com",
292      "available_models": [
293        {
294          "name": "deepseek-chat",
295          "display_name": "DeepSeek Chat",
296          "max_tokens": 64000
297        },
298        {
299          "name": "deepseek-reasoner",
300          "display_name": "DeepSeek Reasoner",
301          "max_tokens": 64000,
302          "max_output_tokens": 4096
303        }
304      ]
305    }
306  }
307}
308```
309
310Custom models will be listed in the model dropdown in the Agent Panel. You can also modify the `api_url` to use a custom endpoint if needed.
311
312### OpenAI API Compatible{#openai-api-compatible}
313
314Zed supports using OpenAI compatible APIs by specifying a custom `endpoint` and `available_models` for the OpenAI provider.
315
316#### X.ai Grok
317
318Example configuration for using X.ai Grok with Zed:
319
320```json
321  "language_models": {
322    "openai": {
323      "api_url": "https://api.x.ai/v1",
324      "available_models": [
325        {
326          "name": "grok-beta",
327          "display_name": "X.ai Grok (Beta)",
328          "max_tokens": 131072
329        }
330      ],
331      "version": "1"
332    },
333  }
334```
335
336### LM Studio {#lmstudio}
337
338> 🚫 Does not support tool use
339
3401. Download and install the latest version of LM Studio from https://lmstudio.ai/download
3412. In the app press ⌘/Ctrl + Shift + M and download at least one model, e.g. qwen2.5-coder-7b
342
343   You can also get models via the LM Studio CLI:
344
345   ```sh
346   lms get qwen2.5-coder-7b
347   ```
348
3493. Make sure the LM Studio API server is running by executing:
350
351   ```sh
352   lms server start
353   ```
354
355Tip: Set [LM Studio as a login item](https://lmstudio.ai/docs/advanced/headless#run-the-llm-service-on-machine-login) to automate running the LM Studio server.
356
357## Advanced Configuration {#advanced-configuration}
358
359### Custom Provider Endpoints {#custom-provider-endpoint}
360
361You can use a custom API endpoint for different providers, as long as it's compatible with the providers API structure.
362To do so, add the following to your `settings.json`:
363
364```json
365{
366  "language_models": {
367    "some-provider": {
368      "api_url": "http://localhost:11434"
369    }
370  }
371}
372```
373
374Where `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
375
376### Default Model {#default-model}
377
378Zed's hosted LLM service sets `claude-3-7-sonnet-latest` as the default model.
379However, you can change it either via the model dropdown in the Agent Panel's bottom-right corner or by manually editing the `default_model` object in your settings:
380
381```json
382{
383  "assistant": {
384    "version": "2",
385    "default_model": {
386      "provider": "zed.dev",
387      "model": "gpt-4o"
388    }
389  }
390}
391```
392
393### Feature-specific Models {#feature-specific-models}
394
395If a feature-specific model is not set, it will fall back to using the default model, which is the one you set on the Agent Panel.
396
397You can configure the following feature-specific models:
398
399- Thread summary model: Used for generating thread summaries
400- Inline assistant model: Used for the inline assistant feature
401- Commit message model: Used for generating Git commit messages
402
403Example configuration:
404
405```json
406{
407  "assistant": {
408    "version": "2",
409    "default_model": {
410      "provider": "zed.dev",
411      "model": "claude-3-7-sonnet"
412    },
413    "inline_assistant_model": {
414      "provider": "anthropic",
415      "model": "claude-3-5-sonnet"
416    },
417    "commit_message_model": {
418      "provider": "openai",
419      "model": "gpt-4o-mini"
420    },
421    "thread_summary_model": {
422      "provider": "google",
423      "model": "gemini-2.0-flash"
424    }
425  }
426}
427```
428
429### Alternative Models for Inline Assists {#alternative-assists}
430
431You can configure additional models that will be used to perform inline assists in parallel.
432When you do this, the inline assist UI will surface controls to cycle between the alternatives generated by each model.
433
434The models you specify here are always used in _addition_ to your [default model](#default-model).
435For example, the following configuration will generate two outputs for every assist.
436One with Claude 3.7 Sonnet, and one with GPT-4o.
437
438```json
439{
440  "assistant": {
441    "default_model": {
442      "provider": "zed.dev",
443      "model": "claude-3-7-sonnet"
444    },
445    "inline_alternatives": [
446      {
447        "provider": "zed.dev",
448        "model": "gpt-4o"
449      }
450    ],
451    "version": "2"
452  }
453}
454```