llm-providers.md

  1# LLM Providers
  2
  3To use AI in Zed, you need to have at least one large language model provider set up.
  4
  5You can do that by either subscribing to [one of Zed's plans](./plans-and-usage.md), or by using API keys you already have for the supported providers.
  6
  7## Use Your Own Keys {#use-your-own-keys}
  8
  9If you already have an API key for a provider like Anthropic or OpenAI, you can add it to Zed. No Zed subscription required.
 10
 11To add an existing API key to a given provider, go to the Agent Panel settings (`agent: open settings`), look for the desired provider, paste the key into the input, and hit enter.
 12
 13> Note: API keys are _not_ stored as plain text in your `settings.json`, but rather in your OS's secure credential storage.
 14
 15## Supported Providers
 16
 17Zed supports these providers with your own API keys:
 18
 19- [Amazon Bedrock](#amazon-bedrock)
 20- [Anthropic](#anthropic)
 21- [DeepSeek](#deepseek)
 22- [GitHub Copilot Chat](#github-copilot-chat)
 23- [Google AI](#google-ai)
 24- [LM Studio](#lmstudio)
 25- [Mistral](#mistral)
 26- [Ollama](#ollama)
 27- [OpenAI](#openai)
 28- [OpenAI API Compatible](#openai-api-compatible)
 29- [OpenRouter](#openrouter)
 30- [Vercel](#vercel-v0)
 31- [xAI](#xai)
 32
 33### Amazon Bedrock {#amazon-bedrock}
 34
 35> Supports tool use with models that support streaming tool use.
 36> More details can be found in the [Amazon Bedrock's Tool Use documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html).
 37
 38To use Amazon Bedrock's models, an AWS authentication is required.
 39Ensure your credentials have the following permissions set up:
 40
 41- `bedrock:InvokeModelWithResponseStream`
 42- `bedrock:InvokeModel`
 43
 44Your IAM policy should look similar to:
 45
 46```json [settings]
 47{
 48  "Version": "2012-10-17",
 49  "Statement": [
 50    {
 51      "Effect": "Allow",
 52      "Action": [
 53        "bedrock:InvokeModel",
 54        "bedrock:InvokeModelWithResponseStream"
 55      ],
 56      "Resource": "*"
 57    }
 58  ]
 59}
 60```
 61
 62With that done, choose one of the three authentication methods:
 63
 64#### Authentication via Named Profile (Recommended)
 65
 661. Ensure you have the AWS CLI installed and configured with a named profile
 672. Open your `settings.json` (`zed: open settings file`) and include the `bedrock` key under `language_models` with the following settings:
 68   ```json [settings]
 69   {
 70     "language_models": {
 71       "bedrock": {
 72         "authentication_method": "named_profile",
 73         "region": "your-aws-region",
 74         "profile": "your-profile-name"
 75       }
 76     }
 77   }
 78   ```
 79
 80#### Authentication via Static Credentials
 81
 82While it's possible to configure through the Agent Panel settings UI by entering your AWS access key and secret directly, we recommend using named profiles instead for better security practices.
 83To do this:
 84
 851. Create an IAM User that you can assume in the [IAM Console](https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/users).
 862. Create security credentials for that User, save them and keep them secure.
 873. Open the Agent Configuration with (`agent: open settings`) and go to the Amazon Bedrock section
 884. Copy the credentials from Step 2 into the respective **Access Key ID**, **Secret Access Key**, and **Region** fields.
 89
 90#### Authentication via Bedrock API Key
 91
 92Amazon Bedrock also supports [API Keys](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-use.html), which authenticate directly without requiring IAM users or named profiles.
 93
 941. Create an API Key in the [Amazon Bedrock Console](https://console.aws.amazon.com/bedrock/)
 952. Open the Agent Configuration with (`agent: open settings`) and go to the Amazon Bedrock section
 963. Enter your Bedrock API key in the **API Key** field and select your **Region**
 97
 98```json [settings]
 99{
100  "language_models": {
101    "bedrock": {
102      "authentication_method": "api_key",
103      "region": "your-aws-region"
104    }
105  }
106}
107```
108
109The API key itself is stored securely in your OS keychain, not in your settings file.
110
111#### Cross-Region Inference
112
113The Zed implementation of Amazon Bedrock uses [Cross-Region inference](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) to improve availability and throughput.
114With Cross-Region inference, you can distribute traffic across multiple AWS Regions, enabling higher throughput.
115
116##### Regional vs Global Inference Profiles
117
118Bedrock supports two types of cross-region inference profiles:
119
120- **Regional profiles** (default): Route requests within a specific geography (US, EU, APAC). For example, `us-east-1` uses the `us.*` profile which routes across `us-east-1`, `us-east-2`, and `us-west-2`.
121- **Global profiles**: Route requests across all commercial AWS Regions for maximum availability and performance.
122
123By default, Zed uses **regional profiles** which keep your data within the same geography. You can opt into global profiles by adding `"allow_global": true` to your Bedrock configuration:
124
125```json [settings]
126{
127  "language_models": {
128    "bedrock": {
129      "authentication_method": "named_profile",
130      "region": "your-aws-region",
131      "profile": "your-profile-name",
132      "allow_global": true
133    }
134  }
135}
136```
137
138**Note:** Only select newer models support global inference profiles. See the [AWS Bedrock supported models documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-system) for the current list of models that support global inference. If you encounter availability issues with a model in your region, enabling `allow_global` may resolve them.
139
140Although the data remains stored only in the source Region, your input prompts and output results might move outside of your source Region during cross-Region inference.
141All data will be transmitted encrypted across Amazon's secure network.
142
143We will support Cross-Region inference for each of the models on a best-effort basis, please refer to the [Cross-Region Inference method Code](https://github.com/zed-industries/zed/blob/main/crates/bedrock/src/models.rs#L297).
144
145For the most up-to-date supported regions and models, refer to the [Supported Models and Regions for Cross Region inference](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).
146
147### Anthropic {#anthropic}
148
149You can use Anthropic models by choosing them via the model dropdown in the Agent Panel.
150
1511. Sign up for Anthropic and [create an API key](https://console.anthropic.com/settings/keys)
1522. Make sure that your Anthropic account has credits
1533. Open the settings view (`agent: open settings`) and go to the Anthropic section
1544. Enter your Anthropic API key
155
156Even 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.
157
158Zed will also use the `ANTHROPIC_API_KEY` environment variable if it's defined.
159
160#### Custom Models {#anthropic-custom-models}
161
162You can add custom models to the Anthropic provider by adding the following to your Zed `settings.json`:
163
164```json [settings]
165{
166  "language_models": {
167    "anthropic": {
168      "available_models": [
169        {
170          "name": "claude-3-5-sonnet-20240620",
171          "display_name": "Sonnet 2024-June",
172          "max_tokens": 128000,
173          "max_output_tokens": 2560,
174          "cache_configuration": {
175            "max_cache_anchors": 10,
176            "min_total_token": 10000,
177            "should_speculate": false
178          },
179          "tool_override": "some-model-that-supports-toolcalling"
180        }
181      ]
182    }
183  }
184}
185```
186
187Custom models will be listed in the model dropdown in the Agent Panel.
188
189You can configure a model to use [extended thinking](https://docs.anthropic.com/en/docs/about-claude/models/extended-thinking-models) (if it supports it) by changing the mode in your model's configuration to `thinking`, for example:
190
191```json [settings]
192{
193  "name": "claude-sonnet-4-latest",
194  "display_name": "claude-sonnet-4-thinking",
195  "max_tokens": 200000,
196  "mode": {
197    "type": "thinking",
198    "budget_tokens": 4096
199  }
200}
201```
202
203### DeepSeek {#deepseek}
204
2051. Visit the DeepSeek platform and [create an API key](https://platform.deepseek.com/api_keys)
2062. Open the settings view (`agent: open settings`) and go to the DeepSeek section
2073. Enter your DeepSeek API key
208
209The DeepSeek API key will be saved in your keychain.
210
211Zed will also use the `DEEPSEEK_API_KEY` environment variable if it's defined.
212
213#### Custom Models {#deepseek-custom-models}
214
215The Zed agent comes pre-configured to use the latest version for common models (DeepSeek Chat, DeepSeek Reasoner).
216If you wish to use alternate models or customize the API endpoint, you can do so by adding the following to your Zed `settings.json`:
217
218```json [settings]
219{
220  "language_models": {
221    "deepseek": {
222      "api_url": "https://api.deepseek.com",
223      "available_models": [
224        {
225          "name": "deepseek-chat",
226          "display_name": "DeepSeek Chat",
227          "max_tokens": 64000
228        },
229        {
230          "name": "deepseek-reasoner",
231          "display_name": "DeepSeek Reasoner",
232          "max_tokens": 64000,
233          "max_output_tokens": 4096
234        }
235      ]
236    }
237  }
238}
239```
240
241Custom models will be listed in the model dropdown in the Agent Panel.
242You can also modify the `api_url` to use a custom endpoint if needed.
243
244### GitHub Copilot Chat {#github-copilot-chat}
245
246You can use GitHub Copilot Chat with the Zed agent by choosing it via the model dropdown in the Agent Panel.
247
2481. Open the settings view (`agent: open settings`) and go to the GitHub Copilot Chat section
2492. Click on `Sign in to use GitHub Copilot`, follow the steps shown in the modal.
250
251Alternatively, you can provide an OAuth token via the `GH_COPILOT_TOKEN` environment variable.
252
253> **Note**: If you don't see specific models in the dropdown, you may need to enable them in your [GitHub Copilot settings](https://github.com/settings/copilot/features).
254
255To use Copilot Enterprise with Zed (for both agent and completions), you must configure your enterprise endpoint as described in [Configuring GitHub Copilot Enterprise](./edit-prediction.md#github-copilot-enterprise).
256
257### Google AI {#google-ai}
258
259You can use Gemini models with the Zed agent by choosing it via the model dropdown in the Agent Panel.
260
2611. Go to the Google AI Studio site and [create an API key](https://aistudio.google.com/app/apikey).
2622. Open the settings view (`agent: open settings`) and go to the Google AI section
2633. Enter your Google AI API key and press enter.
264
265The Google AI API key will be saved in your keychain.
266
267Zed will also use the `GEMINI_API_KEY` environment variable if it's defined. See [Using Gemini API keys](https://ai.google.dev/gemini-api/docs/api-key) in the Gemini docs for more.
268
269#### Custom Models {#google-ai-custom-models}
270
271By 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). You can configure a model to use [thinking mode](https://ai.google.dev/gemini-api/docs/thinking) (if it supports it) by adding a `mode` configuration to your model. This is useful for controlling reasoning token usage and response speed. If not specified, Gemini will automatically choose the thinking budget.
272
273Here is an example of a custom Google AI model you could add to your Zed `settings.json`:
274
275```json [settings]
276{
277  "language_models": {
278    "google": {
279      "available_models": [
280        {
281          "name": "gemini-2.5-flash-preview-05-20",
282          "display_name": "Gemini 2.5 Flash (Thinking)",
283          "max_tokens": 1000000,
284          "mode": {
285            "type": "thinking",
286            "budget_tokens": 24000
287          }
288        }
289      ]
290    }
291  }
292}
293```
294
295Custom models will be listed in the model dropdown in the Agent Panel.
296
297### LM Studio {#lmstudio}
298
2991. Download and install [the latest version of LM Studio](https://lmstudio.ai/download)
3002. In the app press `cmd/ctrl-shift-m` and download at least one model (e.g., qwen2.5-coder-7b). Alternatively, you can get models via the LM Studio CLI:
301
302   ```sh
303   lms get qwen2.5-coder-7b
304   ```
305
3063. Make sure the LM Studio API server is running by executing:
307
308   ```sh
309   lms server start
310   ```
311
312Tip: 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.
313
314### Mistral {#mistral}
315
3161. Visit the Mistral platform and [create an API key](https://console.mistral.ai/api-keys/)
3172. Open the configuration view (`agent: open settings`) and navigate to the Mistral section
3183. Enter your Mistral API key
319
320The Mistral API key will be saved in your keychain.
321
322Zed will also use the `MISTRAL_API_KEY` environment variable if it's defined.
323
324#### Custom Models {#mistral-custom-models}
325
326The Zed agent 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).
327All the default models support tool use.
328If you wish to use alternate models or customize their parameters, you can do so by adding the following to your Zed `settings.json`:
329
330```json [settings]
331{
332  "language_models": {
333    "mistral": {
334      "api_url": "https://api.mistral.ai/v1",
335      "available_models": [
336        {
337          "name": "mistral-tiny-latest",
338          "display_name": "Mistral Tiny",
339          "max_tokens": 32000,
340          "max_output_tokens": 4096,
341          "max_completion_tokens": 1024,
342          "supports_tools": true,
343          "supports_images": false
344        }
345      ]
346    }
347  }
348}
349```
350
351Custom models will be listed in the model dropdown in the Agent Panel.
352
353### Ollama {#ollama}
354
355Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
356
3571. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
358
359   ```sh
360   ollama pull mistral
361   ```
362
3632. Make sure that the Ollama server is running. You can start it either via running Ollama.app (macOS) or launching:
364
365   ```sh
366   ollama serve
367   ```
368
3693. In the Agent Panel, select one of the Ollama models using the model dropdown.
370
371#### Ollama Autodiscovery
372
373Zed will automatically discover models that Ollama has pulled. You can turn this off by setting
374the `auto_discover` field in the Ollama settings. If you do this, you should manually specify which
375models are available.
376
377```json [settings]
378{
379  "language_models": {
380    "ollama": {
381      "api_url": "http://localhost:11434",
382      "auto_discover": false,
383      "available_models": [
384        {
385          "name": "qwen2.5-coder",
386          "display_name": "qwen 2.5 coder",
387          "max_tokens": 32768,
388          "supports_tools": true,
389          "supports_thinking": true,
390          "supports_images": true
391        }
392      ]
393    }
394  }
395}
396```
397
398#### Ollama Context Length {#ollama-context}
399
400Zed has pre-configured maximum context lengths (`max_tokens`) to match the capabilities of common models.
401Zed API requests to Ollama include this as the `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.
402
403See [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.
404
405> **Note**: Token counts displayed in the Agent Panel are only estimates and will differ from the model's native tokenizer.
406
407Depending on your hardware or use-case you may wish to limit or increase the context length for a specific model via settings.json:
408
409```json [settings]
410{
411  "language_models": {
412    "ollama": {
413      "api_url": "http://localhost:11434",
414      "available_models": [
415        {
416          "name": "qwen2.5-coder",
417          "display_name": "qwen 2.5 coder 32K",
418          "max_tokens": 32768,
419          "supports_tools": true,
420          "supports_thinking": true,
421          "supports_images": true
422        }
423      ]
424    }
425  }
426}
427```
428
429If you specify a context length that is too large for your hardware, Ollama will log an error.
430You can watch these logs by running: `tail -f ~/.ollama/logs/ollama.log` (macOS) or `journalctl -u ollama -f` (Linux).
431Depending on the memory available on your machine, you may need to adjust the context length to a smaller value.
432
433You may also optionally specify a value for `keep_alive` for each available model.
434This can be an integer (seconds) or alternatively a string duration like "5m", "10m", "1h", "1d", etc.
435For example, `"keep_alive": "120s"` will allow the remote server to unload the model (freeing up GPU VRAM) after 120 seconds.
436
437The `supports_tools` option controls whether the model will use additional tools.
438If the model is tagged with `tools` in the Ollama catalog, this option should be supplied, and the built-in profiles `Ask` and `Write` can be used.
439If the model is not tagged with `tools` in the Ollama catalog, this option can still be supplied with the value `true`; however, be aware that only the `Minimal` built-in profile will work.
440
441The `supports_thinking` option controls whether the model will perform an explicit "thinking" (reasoning) pass before producing its final answer.
442If the model is tagged with `thinking` in the Ollama catalog, set this option and you can use it in Zed.
443
444The `supports_images` option enables the model's vision capabilities, allowing it to process images included in the conversation context.
445If the model is tagged with `vision` in the Ollama catalog, set this option and you can use it in Zed.
446
447#### Ollama Authentication
448
449In addition to running Ollama on your own hardware, which generally does not require authentication, Zed also supports connecting to remote Ollama instances. API keys are required for authentication.
450
451One such service is [Ollama Turbo](https://ollama.com/turbo). To configure Zed to use Ollama Turbo:
452
4531. Sign in to your Ollama account and subscribe to Ollama Turbo
4542. Visit [ollama.com/settings/keys](https://ollama.com/settings/keys) and create an API key
4553. Open the settings view (`agent: open settings`) and go to the Ollama section
4564. Paste your API key and press enter.
4575. For the API URL enter `https://ollama.com`
458
459Zed will also use the `OLLAMA_API_KEY` environment variables if defined.
460
461### OpenAI {#openai}
462
4631. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
4642. Make sure that your OpenAI account has credits
4653. Open the settings view (`agent: open settings`) and go to the OpenAI section
4664. Enter your OpenAI API key
467
468The OpenAI API key will be saved in your keychain.
469
470Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
471
472#### Custom Models {#openai-custom-models}
473
474The Zed agent comes pre-configured to use the latest version for common models (GPT-5, GPT-5 mini, o4-mini, GPT-4.1, and others).
475To use alternate models, perhaps a preview release, or if you wish to control the request parameters, you can do so by adding the following to your Zed `settings.json`:
476
477```json [settings]
478{
479  "language_models": {
480    "openai": {
481      "available_models": [
482        {
483          "name": "gpt-5",
484          "display_name": "gpt-5 high",
485          "reasoning_effort": "high",
486          "max_tokens": 272000,
487          "max_completion_tokens": 20000
488        },
489        {
490          "name": "gpt-4o-2024-08-06",
491          "display_name": "GPT 4o Summer 2024",
492          "max_tokens": 128000
493        },
494        {
495          "name": "gpt-5-codex",
496          "display_name": "GPT-5 Codex",
497          "max_tokens": 128000,
498          "capabilities": {
499            "chat_completions": false
500          }
501        }
502      ]
503    }
504  }
505}
506```
507
508You must provide the model's context window in the `max_tokens` parameter; this can be found in the [OpenAI model documentation](https://platform.openai.com/docs/models).
509
510OpenAI `o1` and `o`-class models should set `max_completion_tokens` as well to avoid incurring high reasoning token costs.
511
512If a model does not support the `/chat/completions` endpoint (for example `gpt-5-codex`), disable it by setting `capabilities.chat_completions` to `false`. Zed will use the Responses endpoint instead.
513
514Custom models will be listed in the model dropdown in the Agent Panel.
515
516### OpenAI API Compatible {#openai-api-compatible}
517
518Zed supports using [OpenAI compatible APIs](https://platform.openai.com/docs/api-reference/chat) by specifying a custom `api_url` and `available_models` for the OpenAI provider.
519This is useful for connecting to other hosted services (like Together AI, Anyscale, etc.) or local models.
520
521You can add a custom, OpenAI-compatible model either via the UI or by editing your `settings.json`.
522
523To do it via the UI, go to the Agent Panel settings (`agent: open settings`) and look for the "Add Provider" button to the right of the "LLM Providers" section title.
524Then, fill up the input fields available in the modal.
525
526To do it via your `settings.json`, add the following snippet under `language_models`:
527
528```json [settings]
529{
530  "language_models": {
531    "openai_compatible": {
532      // Using Together AI as an example
533      "Together AI": {
534        "api_url": "https://api.together.xyz/v1",
535        "available_models": [
536          {
537            "name": "mistralai/Mixtral-8x7B-Instruct-v0.1",
538            "display_name": "Together Mixtral 8x7B",
539            "max_tokens": 32768,
540            "capabilities": {
541              "tools": true,
542              "images": false,
543              "parallel_tool_calls": false,
544              "prompt_cache_key": false
545            }
546          }
547        ]
548      }
549    }
550  }
551}
552```
553
554By default, OpenAI-compatible models inherit the following capabilities:
555
556- `tools`: true (supports tool/function calling)
557- `images`: false (does not support image inputs)
558- `parallel_tool_calls`: false (does not support `parallel_tool_calls` parameter)
559- `prompt_cache_key`: false (does not support `prompt_cache_key` parameter)
560- `chat_completions`: true (calls the `/chat/completions` endpoint)
561
562If a provider exposes models that only work with the Responses API, set `chat_completions` to `false` for those entries. Zed uses the Responses endpoint for these models.
563
564Note that LLM API keys aren't stored in your settings file.
565So, ensure you have it set in your environment variables (`<PROVIDER_NAME>_API_KEY=<your api key>`) so your settings can pick it up. In the example above, it would be `TOGETHER_AI_API_KEY=<your api key>`.
566
567### OpenRouter {#openrouter}
568
569OpenRouter provides access to multiple AI models through a single API. It supports tool use for compatible models.
570
5711. Visit [OpenRouter](https://openrouter.ai) and create an account
5722. Generate an API key from your [OpenRouter keys page](https://openrouter.ai/keys)
5733. Open the settings view (`agent: open settings`) and go to the OpenRouter section
5744. Enter your OpenRouter API key
575
576The OpenRouter API key will be saved in your keychain.
577
578Zed will also use the `OPENROUTER_API_KEY` environment variable if it's defined.
579
580#### Custom Models {#openrouter-custom-models}
581
582You can add custom models to the OpenRouter provider by adding the following to your Zed `settings.json`:
583
584```json [settings]
585{
586  "language_models": {
587    "open_router": {
588      "api_url": "https://openrouter.ai/api/v1",
589      "available_models": [
590        {
591          "name": "google/gemini-2.0-flash-thinking-exp",
592          "display_name": "Gemini 2.0 Flash (Thinking)",
593          "max_tokens": 200000,
594          "max_output_tokens": 8192,
595          "supports_tools": true,
596          "supports_images": true,
597          "mode": {
598            "type": "thinking",
599            "budget_tokens": 8000
600          }
601        }
602      ]
603    }
604  }
605}
606```
607
608The available configuration options for each model are:
609
610- `name` (required): The model identifier used by OpenRouter
611- `display_name` (optional): A human-readable name shown in the UI
612- `max_tokens` (required): The model's context window size
613- `max_output_tokens` (optional): Maximum tokens the model can generate
614- `max_completion_tokens` (optional): Maximum completion tokens
615- `supports_tools` (optional): Whether the model supports tool/function calling
616- `supports_images` (optional): Whether the model supports image inputs
617- `mode` (optional): Special mode configuration for thinking models
618
619You can find available models and their specifications on the [OpenRouter models page](https://openrouter.ai/models).
620
621Custom models will be listed in the model dropdown in the Agent Panel.
622
623#### Provider Routing
624
625You can optionally control how OpenRouter routes a given custom model request among underlying upstream providers via the `provider` object on each model entry.
626
627Supported fields (all optional):
628
629- `order`: Array of provider slugs to try first, in order (e.g. `["anthropic", "openai"]`)
630- `allow_fallbacks` (default: `true`): Whether fallback providers may be used if preferred ones are unavailable
631- `require_parameters` (default: `false`): Only use providers that support every parameter you supplied
632- `data_collection` (default: `allow`): `"allow"` or `"disallow"` (controls use of providers that may store data)
633- `only`: Whitelist of provider slugs allowed for this request
634- `ignore`: Provider slugs to skip
635- `quantizations`: Restrict to specific quantization variants (e.g. `["int4","int8"]`)
636- `sort`: Sort strategy for candidate providers (e.g. `"price"` or `"throughput"`)
637
638Example adding routing preferences to a model:
639
640```json [settings]
641{
642  "language_models": {
643    "open_router": {
644      "api_url": "https://openrouter.ai/api/v1",
645      "available_models": [
646        {
647          "name": "openrouter/auto",
648          "display_name": "Auto Router (Tools Preferred)",
649          "max_tokens": 2000000,
650          "supports_tools": true,
651          "provider": {
652            "order": ["anthropic", "openai"],
653            "allow_fallbacks": true,
654            "require_parameters": true,
655            "only": ["anthropic", "openai", "google"],
656            "ignore": ["cohere"],
657            "quantizations": ["int8"],
658            "sort": "price",
659            "data_collection": "allow"
660          }
661        }
662      ]
663    }
664  }
665}
666```
667
668These routing controls let you fine‑tune cost, capability, and reliability trade‑offs without changing the model name you select in the UI.
669
670### Vercel v0 {#vercel-v0}
671
672[Vercel v0](https://v0.app/docs/api/model) is an expert model for generating full-stack apps, with framework-aware completions optimized for modern stacks like Next.js and Vercel.
673It supports text and image inputs and provides fast streaming responses.
674
675The v0 models are [OpenAI-compatible models](/#openai-api-compatible), but Vercel is listed as first-class provider in the panel's settings view.
676
677To start using it with Zed, ensure you have first created a [v0 API key](https://v0.dev/chat/settings/keys).
678Once you have it, paste it directly into the Vercel provider section in the panel's settings view.
679
680You should then find it as `v0-1.5-md` in the model dropdown in the Agent Panel.
681
682### xAI {#xai}
683
684Zed has first-class support for [xAI](https://x.ai/) models. You can use your own API key to access Grok models.
685
6861. [Create an API key in the xAI Console](https://console.x.ai/team/default/api-keys)
6872. Open the settings view (`agent: open settings`) and go to the **xAI** section
6883. Enter your xAI API key
689
690The xAI API key will be saved in your keychain. Zed will also use the `XAI_API_KEY` environment variable if it's defined.
691
692> **Note:** While the xAI API is OpenAI-compatible, Zed has first-class support for it as a dedicated provider. For the best experience, we recommend using the dedicated `x_ai` provider configuration instead of the [OpenAI API Compatible](#openai-api-compatible) method.
693
694#### Custom Models {#xai-custom-models}
695
696The Zed agent comes pre-configured with common Grok models. If you wish to use alternate models or customize their parameters, you can do so by adding the following to your Zed `settings.json`:
697
698```json [settings]
699{
700  "language_models": {
701    "x_ai": {
702      "api_url": "https://api.x.ai/v1",
703      "available_models": [
704        {
705          "name": "grok-1.5",
706          "display_name": "Grok 1.5",
707          "max_tokens": 131072,
708          "max_output_tokens": 8192
709        },
710        {
711          "name": "grok-1.5v",
712          "display_name": "Grok 1.5V (Vision)",
713          "max_tokens": 131072,
714          "max_output_tokens": 8192,
715          "supports_images": true
716        }
717      ]
718    }
719  }
720}
721```
722
723## Custom Provider Endpoints {#custom-provider-endpoint}
724
725You can use a custom API endpoint for different providers, as long as it's compatible with the provider's API structure.
726To do so, add the following to your `settings.json`:
727
728```json [settings]
729{
730  "language_models": {
731    "some-provider": {
732      "api_url": "http://localhost:11434"
733    }
734  }
735}
736```
737
738Currently, `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
739
740This is the same infrastructure that powers models that are, for example, [OpenAI-compatible](#openai-api-compatible).