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)     | In Some Cases      |
 16| [Google AI](#google-ai)                         | ✅                 |
 17| [Ollama](#ollama)                               | ✅                 |
 18| [OpenAI](#openai)                               | ✅                 |
 19| [DeepSeek](#deepseek)                           | 🚫                 |
 20| [OpenAI API Compatible](#openai-api-compatible) | 🚫                 |
 21| [LM Studio](#lmstudio)                          | 🚫                 |
 22
 23## Use Your Own Keys {#use-your-own-keys}
 24
 25While 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 for LLM providers. Below, you can learn how to do that for each provider.
 26
 27> 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.
 28
 29### Anthropic {#anthropic}
 30
 31> ✅ Supports tool use
 32
 33You can use Anthropic models by choosing it via the model dropdown in the Agent Panel.
 34
 351. Sign up for Anthropic and [create an API key](https://console.anthropic.com/settings/keys)
 362. Make sure that your Anthropic account has credits
 373. Open the settings view (`agent: open configuration`) and go to the Anthropic section
 384. Enter your Anthropic API key
 39
 40Even 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.
 41
 42Zed will also use the `ANTHROPIC_API_KEY` environment variable if it's defined.
 43
 44#### Anthropic Custom Models {#anthropic-custom-models}
 45
 46You can add custom models to the Anthropic provider by adding the following to your Zed `settings.json`:
 47
 48```json
 49{
 50  "language_models": {
 51    "anthropic": {
 52      "available_models": [
 53        {
 54          "name": "claude-3-5-sonnet-20240620",
 55          "display_name": "Sonnet 2024-June",
 56          "max_tokens": 128000,
 57          "max_output_tokens": 2560,
 58          "cache_configuration": {
 59            "max_cache_anchors": 10,
 60            "min_total_token": 10000,
 61            "should_speculate": false
 62          },
 63          "tool_override": "some-model-that-supports-toolcalling"
 64        }
 65      ]
 66    }
 67  }
 68}
 69```
 70
 71Custom models will be listed in the model dropdown in the Agent Panel.
 72
 73You can configure a model to use [extended thinking](https://docs.anthropic.com/en/docs/about-claude/models/extended-thinking-models) (if it supports it),
 74by changing the mode in of your models configuration to `thinking`, for example:
 75
 76```json
 77{
 78  "name": "claude-3-7-sonnet-latest",
 79  "display_name": "claude-3-7-sonnet-thinking",
 80  "max_tokens": 200000,
 81  "mode": {
 82    "type": "thinking",
 83    "budget_tokens": 4_096
 84  }
 85}
 86```
 87
 88### GitHub Copilot Chat {#github-copilot-chat}
 89
 90> ✅ Supports tool use in some cases.
 91> 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.
 92
 93You can use GitHub Copilot chat with the Zed assistant by choosing it via the model dropdown in the Agent Panel.
 94
 95### Google AI {#google-ai}
 96
 97> ✅ Supports tool use
 98
 99You can use Gemini 1.5 Pro/Flash with the Zed assistant by choosing it via the model dropdown in the Agent Panel.
100
1011. Go the Google AI Studio site and [create an API key](https://aistudio.google.com/app/apikey).
1022. Open the settings view (`agent: open configuration`) and go to the Google AI section
1033. Enter your Google AI API key and press enter.
104
105The Google AI API key will be saved in your keychain.
106
107Zed will also use the `GOOGLE_AI_API_KEY` environment variable if it's defined.
108
109#### Google AI custom models {#google-ai-custom-models}
110
111By 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`:
112
113```json
114{
115  "language_models": {
116    "google": {
117      "available_models": [
118        {
119          "name": "gemini-1.5-flash-latest",
120          "display_name": "Gemini 1.5 Flash (Latest)",
121          "max_tokens": 1000000
122        }
123      ]
124    }
125  }
126}
127```
128
129Custom models will be listed in the model dropdown in the Agent Panel.
130
131### Ollama {#ollama}
132
133> ✅ Supports tool use
134
135Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
136
1371. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
138
139   ```sh
140   ollama pull mistral
141   ```
142
1432. Make sure that the Ollama server is running. You can start it either via running Ollama.app (macOS) or launching:
144
145   ```sh
146   ollama serve
147   ```
148
1493. In the Agent Panel, select one of the Ollama models using the model dropdown.
150
151#### Ollama Context Length {#ollama-context}
152
153Zed has pre-configured maximum context lengths (`max_tokens`) to match the capabilities of common models.
154Zed 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.
155See [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.
156
157> **Note**: Tokens counts displayed in the Agent Panel are only estimates and will differ from the models native tokenizer.
158
159Depending on your hardware or use-case you may wish to limit or increase the context length for a specific model via settings.json:
160
161```json
162{
163  "language_models": {
164    "ollama": {
165      "api_url": "http://localhost:11434",
166      "available_models": [
167        {
168          "name": "qwen2.5-coder",
169          "display_name": "qwen 2.5 coder 32K",
170          "max_tokens": 32768,
171          "supports_tools": true
172        }
173      ]
174    }
175  }
176}
177```
178
179If 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.
180
181You 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.
182
183The `supports_tools` option controls whether or not the model will use additional tools.
184If 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.
185If the model is not tagged with `tools` in the Ollama catalog, this
186option can still be supplied with value `true`; however be aware that only the
187`Minimal` built in profile will work.
188
189### OpenAI {#openai}
190
191> ✅ Supports tool use
192
1931. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
1942. Make sure that your OpenAI account has credits
1953. Open the settings view (`agent: open configuration`) and go to the OpenAI section
1964. Enter your OpenAI API key
197
198The OpenAI API key will be saved in your keychain.
199
200Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
201
202#### OpenAI Custom Models {#openai-custom-models}
203
204The 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`:
205
206```json
207{
208  "language_models": {
209    "openai": {
210      "available_models": [
211        {
212          "name": "gpt-4o-2024-08-06",
213          "display_name": "GPT 4o Summer 2024",
214          "max_tokens": 128000
215        },
216        {
217          "name": "o1-mini",
218          "display_name": "o1-mini",
219          "max_tokens": 128000,
220          "max_completion_tokens": 20000
221        }
222      ],
223      "version": "1"
224    }
225  }
226}
227```
228
229You 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.
230
231### DeepSeek {#deepseek}
232
233> 🚫 Does not support tool use
234
2351. Visit the DeepSeek platform and [create an API key](https://platform.deepseek.com/api_keys)
2362. Open the settings view (`agent: open configuration`) and go to the DeepSeek section
2373. Enter your DeepSeek API key
238
239The DeepSeek API key will be saved in your keychain.
240
241Zed will also use the `DEEPSEEK_API_KEY` environment variable if it's defined.
242
243#### DeepSeek Custom Models {#deepseek-custom-models}
244
245The 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`:
246
247```json
248{
249  "language_models": {
250    "deepseek": {
251      "api_url": "https://api.deepseek.com",
252      "available_models": [
253        {
254          "name": "deepseek-chat",
255          "display_name": "DeepSeek Chat",
256          "max_tokens": 64000
257        },
258        {
259          "name": "deepseek-reasoner",
260          "display_name": "DeepSeek Reasoner",
261          "max_tokens": 64000,
262          "max_output_tokens": 4096
263        }
264      ]
265    }
266  }
267}
268```
269
270Custom 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.
271
272### OpenAI API Compatible{#openai-api-compatible}
273
274Zed supports using OpenAI compatible APIs by specifying a custom `endpoint` and `available_models` for the OpenAI provider.
275
276#### X.ai Grok
277
278Example configuration for using X.ai Grok with Zed:
279
280```json
281  "language_models": {
282    "openai": {
283      "api_url": "https://api.x.ai/v1",
284      "available_models": [
285        {
286          "name": "grok-beta",
287          "display_name": "X.ai Grok (Beta)",
288          "max_tokens": 131072
289        }
290      ],
291      "version": "1"
292    },
293  }
294```
295
296### LM Studio {#lmstudio}
297
298> 🚫 Does not support tool use
299
3001. Download and install the latest version of LM Studio from https://lmstudio.ai/download
3012. In the app press ⌘/Ctrl + Shift + M and download at least one model, e.g. qwen2.5-coder-7b
302
303   You can also get models via the LM Studio CLI:
304
305   ```sh
306   lms get qwen2.5-coder-7b
307   ```
308
3093. Make sure the LM Studio API server by running:
310
311   ```sh
312   lms server start
313   ```
314
315Tip: 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.
316
317## Advanced Configuration {#advanced-configuration}
318
319### Custom Provider Endpoints {#custom-provider-endpoint}
320
321You can use a custom API endpoint for different providers, as long as it's compatible with the providers API structure.
322To do so, add the following to your `settings.json`:
323
324```json
325{
326  "language_models": {
327    "some-provider": {
328      "api_url": "http://localhost:11434"
329    }
330  }
331}
332```
333
334Where `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
335
336### Default Model {#default-model}
337
338Zed's hosted LLM service sets `claude-3-7-sonnet-latest` as the default model.
339However, 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:
340
341```json
342{
343  "assistant": {
344    "version": "2",
345    "default_model": {
346      "provider": "zed.dev",
347      "model": "gpt-4o"
348    }
349  }
350}
351```
352
353### Feature-specific Models {#feature-specific-models}
354
355If 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.
356
357You can configure the following feature-specific models:
358
359- Thread summary model: Used for generating thread summaries
360- Inline assistant model: Used for the inline assistant feature
361- Commit message model: Used for generating Git commit messages
362
363Example configuration:
364
365```json
366{
367  "assistant": {
368    "version": "2",
369    "default_model": {
370      "provider": "zed.dev",
371      "model": "claude-3-7-sonnet"
372    },
373    "inline_assistant_model": {
374      "provider": "anthropic",
375      "model": "claude-3-5-sonnet"
376    },
377    "commit_message_model": {
378      "provider": "openai",
379      "model": "gpt-4o-mini"
380    },
381    "thread_summary_model": {
382      "provider": "google",
383      "model": "gemini-2.0-flash"
384    }
385  }
386}
387```
388
389### Alternative Models for Inline Assists {#alternative-assists}
390
391You can configure additional models that will be used to perform inline assists in parallel.
392When you do this, the inline assist UI will surface controls to cycle between the alternatives generated by each model.
393
394The models you specify here are always used in _addition_ to your [default model](#default-model).
395For example, the following configuration will generate two outputs for every assist.
396One with Claude 3.7 Sonnet, and one with GPT-4o.
397
398```json
399{
400  "assistant": {
401    "default_model": {
402      "provider": "zed.dev",
403      "model": "claude-3-7-sonnet"
404    },
405    "inline_alternatives": [
406      {
407        "provider": "zed.dev",
408        "model": "gpt-4o"
409      }
410    ],
411    "version": "2"
412  }
413}
414```