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) [^1]
 10- [Google AI](#google-ai) [^1]
 11- [Ollama](#ollama)
 12- [OpenAI](#openai)
 13
 14To 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".
 15
 16[^1]: This provider does not support the [`/workflow`](./commands#workflow-not-generally-available) command.
 17
 18To further customize providers, you can use `settings.json` to do that as follows:
 19
 20- [Configuring endpoints](#custom-endpoint)
 21- [Configuring timeouts](#provider-timeout)
 22- [Configuring default model](#default-model)
 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": "some-model",
 52          "display_name": "some-model",
 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
 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
 88You can add custom models to 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": "custom-model",
 97          "max_tokens": 128000
 98        }
 99      ]
100    }
101  }
102}
103```
104
105Custom models will be listed in the model dropdown in the assistant panel.
106
107### Ollama {#ollama}
108
109Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
110
1111. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
112
113   ```sh
114   ollama pull mistral
115   ```
116
1172. Make sure that the Ollama server is running. You can start it either via running Ollama.app (MacOS) or launching:
118
119   ```sh
120   ollama serve
121   ```
122
1233. In the assistant panel, select one of the Ollama models using the model dropdown.
124
1254. (Optional) Specify a [custom api_url](#custom-endpoint) or [custom `low_speed_timeout_in_seconds`](#provider-timeout) if required.
126
127#### Ollama Context Length {#ollama-context}
128
129Zed 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.
130
131**Note**: Tokens counts displayed in the assistant panel are only estimates and will differ from the models native tokenizer.
132
133Depending on your hardware or use-case you may wish to limit or increase the context length for a specific model via settings.json:
134
135```json
136{
137  "language_models": {
138    "ollama": {
139      "low_speed_timeout_in_seconds": 120,
140      "available_models": [
141        {
142          "provider": "ollama",
143          "name": "mistral:latest",
144          "max_tokens": 32768
145        }
146      ]
147    }
148  }
149}
150```
151
152If 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.
153
154### OpenAI {#openai}
155
1561. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
1572. Make sure that your OpenAI account has credits
1583. Open the configuration view (`assistant: show configuration`) and navigate to the OpenAI section
1594. Enter your OpenAI API key
160
161The OpenAI API key will be saved in your keychain.
162
163Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
164
165#### OpenAI Custom Models {#openai-custom-models}
166
167You can add custom models to the OpenAI provider, by adding the following to your Zed `settings.json`:
168
169```json
170{
171  "language_models": {
172    "openai": {
173      "version": "1",
174      "available_models": [
175        {
176          "name": "custom-model",
177          "max_tokens": 128000
178        }
179      ]
180    }
181  }
182}
183```
184
185Custom models will be listed in the model dropdown in the assistant panel.
186
187### Advanced configuration {#advanced-configuration}
188
189#### Example Configuration
190
191```json
192{
193  "assistant": {
194    "enabled": true,
195    "default_model": {
196      "provider": "zed.dev",
197      "model": "claude-3-5-sonnet"
198    },
199    "version": "2",
200    "button": true,
201    "default_width": 480,
202    "dock": "right"
203  }
204}
205```
206
207#### Custom endpoints {#custom-endpoint}
208
209You can use a custom API endpoint for different providers, as long as it's compatible with the providers API structure.
210
211To do so, add the following to your Zed `settings.json`:
212
213```json
214{
215  "language_models": {
216    "some-provider": {
217      "api_url": "http://localhost:11434/v1"
218    }
219  }
220}
221```
222
223Where `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
224
225#### Custom timeout {#provider-timeout}
226
227You can customize the timeout that's used for LLM requests, by adding the following to your Zed `settings.json`:
228
229```json
230{
231  "language_models": {
232    "some-provider": {
233      "low_speed_timeout_in_seconds": 10
234    }
235  }
236}
237```
238
239Where `some-provider` can be any of the following values: `anthropic`, `copilot_chat`, `google`, `ollama`, `openai`.
240
241#### Configuring the default model {#default-model}
242
243The 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.
244You can also manually edit the `default_model` object in your settings:
245
246```json
247{
248  "assistant": {
249    "version": "2",
250    "default_model": {
251      "provider": "zed.dev",
252      "model": "claude-3-5-sonnet"
253    }
254  }
255}
256```
257
258#### Common Panel Settings
259
260| key            | type    | default | description                                                                           |
261| -------------- | ------- | ------- | ------------------------------------------------------------------------------------- |
262| enabled        | boolean | true    | Setting this to `false` will completely disable the assistant                         |
263| button         | boolean | true    | Show the assistant icon in the status bar                                             |
264| dock           | string  | "right" | The default dock position for the assistant panel. Can be ["left", "right", "bottom"] |
265| default_height | string  | null    | The pixel height of the assistant panel when docked to the bottom                     |
266| default_width  | string  | null    | The pixel width of the assistant panel when docked to the left or right               |