configuration.md

  1# Configuring the Assistant
  2
  3## Providers {#providers}
  4
  5The following providers are supported:
  6
  7- [Zed AI (Configured by default when signed in)](#zed-ai)
  8- [Anthropic](#anthropic)
  9- [GitHub Copilot Chat](#github-copilot-chat)
 10- [Google AI](#google-ai)
 11- [Ollama](#ollama)
 12- [OpenAI](#openai)
 13- [LM Studio](#lmstudio)
 14
 15To configure different providers, run `assistant: show configuration` in the command palette, or click on the hamburger menu at the top-right of the assistant panel and select "Configure".
 16
 17To further customize providers, you can use `settings.json` to do that as follows:
 18
 19- [Configuring endpoints](#custom-endpoint)
 20- [Configuring timeouts](#provider-timeout)
 21- [Configuring default model](#default-model)
 22- [Configuring alternative models for inline assists](#alternative-assists)
 23
 24### Zed AI {#zed-ai}
 25
 26A hosted service providing convenient and performant support for AI-enabled coding in Zed, powered by Anthropic's Claude 3.5 Sonnet and accessible just by signing in.
 27
 28### Anthropic {#anthropic}
 29
 30You can use Claude 3.5 Sonnet via [Zed AI](#zed-ai) for free. To use other Anthropic models you will need to configure it by providing your own API key.
 31
 321. Sign up for Anthropic and [create an API key](https://console.anthropic.com/settings/keys)
 332. Make sure that your Anthropic account has credits
 343. Open the configuration view (`assistant: show configuration`) and navigate to the Anthropic section
 354. Enter your Anthropic API key
 36
 37Even 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.
 38
 39Zed will also use the `ANTHROPIC_API_KEY` environment variable if it's defined.
 40
 41#### Anthropic Custom Models {#anthropic-custom-models}
 42
 43You can add custom models to the Anthropic provider by adding the following to your Zed `settings.json`:
 44
 45```json
 46{
 47  "language_models": {
 48    "anthropic": {
 49      "available_models": [
 50        {
 51          "name": "claude-3-5-sonnet-20240620",
 52          "display_name": "Sonnet 2024-June",
 53          "max_tokens": 128000,
 54          "max_output_tokens": 2560,
 55          "cache_configuration": {
 56            "max_cache_anchors": 10,
 57            "min_total_token": 10000,
 58            "should_speculate": false
 59          },
 60          "tool_override": "some-model-that-supports-toolcalling"
 61        }
 62      ]
 63    }
 64  }
 65}
 66```
 67
 68Custom models will be listed in the model dropdown in the assistant panel.
 69
 70### GitHub Copilot Chat {#github-copilot-chat}
 71
 72You can use GitHub Copilot chat with the Zed assistant by choosing it via the model dropdown in the assistant panel.
 73
 74### Google AI {#google-ai}
 75
 76You can use Gemini 1.5 Pro/Flash with the Zed assistant by choosing it via the model dropdown in the assistant panel.
 77
 781. Go the Google AI Studio site and [create an API key](https://aistudio.google.com/app/apikey).
 792. Open the configuration view (`assistant: show configuration`) and navigate to the Google AI section
 803. Enter your Google AI API key and press enter.
 81
 82The Google AI API key will be saved in your keychain.
 83
 84Zed will also use the `GOOGLE_AI_API_KEY` environment variable if it's defined.
 85
 86#### Google AI custom models {#google-ai-custom-models}
 87
 88By 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`:
 89
 90```json
 91{
 92  "language_models": {
 93    "google": {
 94      "available_models": [
 95        {
 96          "name": "gemini-1.5-flash-latest",
 97          "display_name": "Gemini 1.5 Flash (Latest)",
 98          "max_tokens": 1000000
 99        }
100      ]
101    }
102  }
103}
104```
105
106Custom models will be listed in the model dropdown in the assistant panel.
107
108### Ollama {#ollama}
109
110Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
111
1121. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
113
114   ```sh
115   ollama pull mistral
116   ```
117
1182. Make sure that the Ollama server is running. You can start it either via running Ollama.app (MacOS) or launching:
119
120   ```sh
121   ollama serve
122   ```
123
1243. In the assistant panel, select one of the Ollama models using the model dropdown.
125
126#### Ollama Context Length {#ollama-context}
127
128Zed has pre-configured maximum context lengths (`max_tokens`) to match the capabilities of common models. Zed 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. See [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.
129
130**Note**: Tokens counts displayed in the assistant panel are only estimates and will differ from the models native tokenizer.
131
132Depending on your hardware or use-case you may wish to limit or increase the context length for a specific model via settings.json:
133
134```json
135{
136  "language_models": {
137    "ollama": {
138      "api_url": "http://localhost:11434",
139      "available_models": [
140        {
141          "name": "qwen2.5-coder",
142          "display_name": "qwen 2.5 coder 32K",
143          "max_tokens": 32768
144        }
145      ]
146    }
147  }
148}
149```
150
151If 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.
152
153You 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.
154
155### OpenAI {#openai}
156
1571. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
1582. Make sure that your OpenAI account has credits
1593. Open the configuration view (`assistant: show configuration`) and navigate to the OpenAI section
1604. Enter your OpenAI API key
161
162The OpenAI API key will be saved in your keychain.
163
164Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
165
166#### OpenAI Custom Models {#openai-custom-models}
167
168The 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`:
169
170```json
171{
172  "language_models": {
173    "openai": {
174      "available_models": [
175        {
176          "name": "gpt-4o-2024-08-06",
177          "display_name": "GPT 4o Summer 2024",
178          "max_tokens": 128000
179        },
180        {
181          "name": "o1-mini",
182          "display_name": "o1-mini",
183          "max_tokens": 128000,
184          "max_completion_tokens": 20000
185        }
186      ]
187      "version": "1"
188    },
189  }
190}
191```
192
193You 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 assistant panel.
194
195### DeepSeek {#deepseek}
196
1971. Visit the DeepSeek platform and [create an API key](https://platform.deepseek.com/api_keys)
1982. Open the configuration view (`assistant: show configuration`) and navigate to the DeepSeek section
1993. Enter your DeepSeek API key
200
201The DeepSeek API key will be saved in your keychain.
202
203Zed will also use the `DEEPSEEK_API_KEY` environment variable if it's defined.
204
205#### DeepSeek Custom Models {#deepseek-custom-models}
206
207The 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`:
208
209```json
210{
211  "language_models": {
212    "deepseek": {
213      "api_url": "https://api.deepseek.com",
214      "available_models": [
215        {
216          "name": "deepseek-chat",
217          "display_name": "DeepSeek Chat",
218          "max_tokens": 64000
219        },
220        {
221          "name": "deepseek-reasoner",
222          "display_name": "DeepSeek Reasoner",
223          "max_tokens": 64000,
224          "max_output_tokens": 4096
225        }
226      ]
227    }
228  }
229}
230```
231
232Custom models will be listed in the model dropdown in the assistant panel. You can also modify the `api_url` to use a custom endpoint if needed.
233
234### OpenAI API Compatible
235
236Zed supports using OpenAI compatible APIs by specifying a custom `endpoint` and `available_models` for the OpenAI provider.
237
238#### X.ai Grok
239
240Example configuration for using X.ai Grok with Zed:
241
242```json
243  "language_models": {
244    "openai": {
245      "api_url": "https://api.x.ai/v1",
246      "available_models": [
247        {
248          "name": "grok-beta",
249          "display_name": "X.ai Grok (Beta)",
250          "max_tokens": 131072
251        }
252      ],
253      "version": "1"
254    },
255  }
256```
257
258### Advanced configuration {#advanced-configuration}
259
260#### Example Configuration
261
262```json
263{
264  "assistant": {
265    "enabled": true,
266    "default_model": {
267      "provider": "zed.dev",
268      "model": "claude-3-5-sonnet"
269    },
270    "version": "2",
271    "button": true,
272    "default_width": 480,
273    "dock": "right"
274  }
275}
276```
277
278### LM Studio {#lmstudio}
279
2801. Download and install the latest version of LM Studio from https://lmstudio.ai/download
2812. In the app press ⌘/Ctrl + Shift + M and download at least one model, e.g. qwen2.5-coder-7b
282
283   You can also get models via the LM Studio CLI:
284
285   ```sh
286   lms get qwen2.5-coder-7b
287   ```
288
2893. Make sure the LM Studio API server by running:
290
291   ```sh
292   lms server start
293   ```
294
295Tip: 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.
296
297#### Custom endpoints {#custom-endpoint}
298
299You can use a custom API endpoint for different providers, as long as it's compatible with the providers API structure.
300
301To do so, add the following to your Zed `settings.json`:
302
303```json
304{
305  "language_models": {
306    "some-provider": {
307      "api_url": "http://localhost:11434"
308    }
309  }
310}
311```
312
313Where `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
314
315#### Configuring the default model {#default-model}
316
317The default model can be set via the model dropdown in the assistant panel's top-right corner. Selecting a model saves it as the default.
318You can also manually edit the `default_model` object in your settings:
319
320```json
321{
322  "assistant": {
323    "version": "2",
324    "default_model": {
325      "provider": "zed.dev",
326      "model": "claude-3-5-sonnet"
327    }
328  }
329}
330```
331
332#### Configuring alternative models for inline assists {#alternative-assists}
333
334You can configure additional models that will be used to perform inline assists in parallel. When you do this,
335the inline assist UI will surface controls to cycle between the alternatives generated by each model. The models
336you specify here are always used in _addition_ to your default model. For example, the following configuration
337will generate two outputs for every assist. One with Claude 3.5 Sonnet, and one with GPT-4o.
338
339```json
340{
341  "assistant": {
342    "default_model": {
343      "provider": "zed.dev",
344      "model": "claude-3-5-sonnet"
345    },
346    "inline_alternatives": [
347      {
348        "provider": "zed.dev",
349        "model": "gpt-4o"
350      }
351    ],
352    "version": "2"
353  }
354}
355```
356
357#### Common Panel Settings
358
359| key            | type    | default | description                                                                           |
360| -------------- | ------- | ------- | ------------------------------------------------------------------------------------- |
361| enabled        | boolean | true    | Setting this to `false` will completely disable the assistant                         |
362| button         | boolean | true    | Show the assistant icon in the status bar                                             |
363| dock           | string  | "right" | The default dock position for the assistant panel. Can be ["left", "right", "bottom"] |
364| default_height | string  | null    | The pixel height of the assistant panel when docked to the bottom                     |
365| default_width  | string  | null    | The pixel width of the assistant panel when docked to the left or right               |