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