1---
2title: LLM Providers - Use Your Own API Keys in Zed
3description: Bring your own API keys to Zed. Set up Anthropic, OpenAI, Google AI, Ollama, DeepSeek, Mistral, OpenRouter, and more.
4---
5
6# LLM Providers
7
8To use AI in Zed, you need to have at least one large language model provider set up. Once configured, providers are available in the [Agent Panel](./agent-panel.md), [Inline Assistant](./inline-assistant.md), and [Text Threads](./text-threads.md).
9
10You 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. For general AI setup, see [Configuration](./configuration.md).
11
12## Use Your Own Keys {#use-your-own-keys}
13
14If you already have an API key for a provider like Anthropic or OpenAI, you can add it to Zed. No Zed subscription required.
15
16To 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.
17
18> Note: API keys are _not_ stored as plain text in your settings file, but rather in your OS's secure credential storage.
19
20## Supported Providers
21
22Zed supports these providers with your own API keys:
23
24- [Amazon Bedrock](#amazon-bedrock)
25- [Anthropic](#anthropic)
26- [DeepSeek](#deepseek)
27- [GitHub Copilot Chat](#github-copilot-chat)
28- [Google AI](#google-ai)
29- [LM Studio](#lmstudio)
30- [Mistral](#mistral)
31- [Ollama](#ollama)
32- [OpenAI](#openai)
33- [OpenAI API Compatible](#openai-api-compatible)
34- [OpenRouter](#openrouter)
35- [Vercel](#vercel-v0)
36- [xAI](#xai)
37
38### Amazon Bedrock {#amazon-bedrock}
39
40> Supports tool use with models that support streaming tool use.
41> 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).
42
43To use Amazon Bedrock's models, an AWS authentication is required.
44Ensure your credentials have the following permissions set up:
45
46- `bedrock:InvokeModelWithResponseStream`
47- `bedrock:InvokeModel`
48
49Your IAM policy should look similar to:
50
51```json
52{
53 "Version": "2012-10-17",
54 "Statement": [
55 {
56 "Effect": "Allow",
57 "Action": [
58 "bedrock:InvokeModel",
59 "bedrock:InvokeModelWithResponseStream"
60 ],
61 "Resource": "*"
62 }
63 ]
64}
65```
66
67With that done, choose one of the three authentication methods:
68
69#### Authentication via Named Profile (Recommended)
70
711. Ensure you have the AWS CLI installed and configured with a named profile
722. Open your settings file (`zed: open settings file`) and include the `bedrock` key under `language_models` with the following settings:
73 ```json [settings]
74 {
75 "language_models": {
76 "bedrock": {
77 "authentication_method": "named_profile",
78 "region": "your-aws-region",
79 "profile": "your-profile-name"
80 }
81 }
82 }
83 ```
84
85#### Authentication via Static Credentials
86
87While 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.
88To do this:
89
901. 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).
912. Create security credentials for that User, save them and keep them secure.
923. Open the Agent Configuration with (`agent: open settings`) and go to the Amazon Bedrock section
934. Copy the credentials from Step 2 into the respective **Access Key ID**, **Secret Access Key**, and **Region** fields.
94
95#### Authentication via Bedrock API Key
96
97Amazon 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.
98
991. Create an API Key in the [Amazon Bedrock Console](https://console.aws.amazon.com/bedrock/)
1002. Open the Agent Configuration with (`agent: open settings`) and go to the Amazon Bedrock section
1013. Enter your Bedrock API key in the **API Key** field and select your **Region**
102
103```json [settings]
104{
105 "language_models": {
106 "bedrock": {
107 "authentication_method": "api_key",
108 "region": "your-aws-region"
109 }
110 }
111}
112```
113
114The API key itself is stored securely in your OS keychain, not in your settings file.
115
116#### Cross-Region Inference
117
118The 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.
119With Cross-Region inference, you can distribute traffic across multiple AWS Regions, enabling higher throughput.
120
121##### Regional vs Global Inference Profiles
122
123Bedrock supports two types of cross-region inference profiles:
124
125- **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`.
126- **Global profiles**: Route requests across all commercial AWS Regions for maximum availability and performance.
127
128By 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:
129
130```json [settings]
131{
132 "language_models": {
133 "bedrock": {
134 "authentication_method": "named_profile",
135 "region": "your-aws-region",
136 "profile": "your-profile-name",
137 "allow_global": true
138 }
139 }
140}
141```
142
143**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.
144
145Although 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.
146All data will be transmitted encrypted across Amazon's secure network.
147
148We 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).
149
150For 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).
151
152#### Extended Context Window {#bedrock-extended-context}
153
154> **Preview:** This feature is available in Zed Preview. It will be included in the next Stable release.
155
156Anthropic models on Bedrock support a 1M token extended context window through the `anthropic_beta` API parameter. To enable this feature, set `"allow_extended_context": true` in your Bedrock configuration:
157
158```json [settings]
159{
160 "language_models": {
161 "bedrock": {
162 "authentication_method": "named_profile",
163 "region": "your-aws-region",
164 "profile": "your-profile-name",
165 "allow_extended_context": true
166 }
167 }
168}
169```
170
171Zed enables extended context for supported models (Claude Sonnet 4.5 and Claude Opus 4.6). Extended context usage may increase API costs—refer to AWS Bedrock pricing for details.
172
173#### Image Support {#bedrock-image-support}
174
175> **Preview:** This feature is available in Zed Preview. It will be included in the next Stable release.
176
177Bedrock models that support vision (Claude 3 and later, Amazon Nova Pro and Lite, Meta Llama 3.2 Vision models, Mistral Pixtral) can receive images in conversations and tool results.
178
179### Anthropic {#anthropic}
180
181You can use Anthropic models by choosing them via the model dropdown in the Agent Panel.
182
1831. Sign up for Anthropic and [create an API key](https://console.anthropic.com/settings/keys)
1842. Make sure that your Anthropic account has credits
1853. Open the settings view (`agent: open settings`) and go to the Anthropic section
1864. Enter your Anthropic API key
187
188Even 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.
189
190Zed will also use the `ANTHROPIC_API_KEY` environment variable if it's defined.
191
192#### Custom Models {#anthropic-custom-models}
193
194You can add custom models to the Anthropic provider by adding the following to your Zed settings file ([how to edit](../configuring-zed.md#settings-files)):
195
196```json [settings]
197{
198 "language_models": {
199 "anthropic": {
200 "available_models": [
201 {
202 "name": "claude-3-5-sonnet-20240620",
203 "display_name": "Sonnet 2024-June",
204 "max_tokens": 128000,
205 "max_output_tokens": 2560,
206 "cache_configuration": {
207 "max_cache_anchors": 10,
208 "min_total_token": 10000,
209 "should_speculate": false
210 },
211 "tool_override": "some-model-that-supports-toolcalling"
212 }
213 ]
214 }
215 }
216}
217```
218
219Custom models will be listed in the model dropdown in the Agent Panel.
220
221You 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:
222
223```json
224{
225 "name": "claude-sonnet-4-latest",
226 "display_name": "claude-sonnet-4-thinking",
227 "max_tokens": 200000,
228 "mode": {
229 "type": "thinking",
230 "budget_tokens": 4096
231 }
232}
233```
234
235### DeepSeek {#deepseek}
236
2371. Visit the DeepSeek platform and [create an API key](https://platform.deepseek.com/api_keys)
2382. Open the settings view (`agent: open settings`) and go to the DeepSeek section
2393. Enter your DeepSeek API key
240
241The DeepSeek API key will be saved in your keychain.
242
243Zed will also use the `DEEPSEEK_API_KEY` environment variable if it's defined.
244
245#### Custom Models {#deepseek-custom-models}
246
247The Zed agent comes pre-configured to use the latest version for common models (DeepSeek Chat, DeepSeek Reasoner).
248If you wish to use alternate models or customize the API endpoint, you can do so by adding the following to your Zed settings file ([how to edit](../configuring-zed.md#settings-files)):
249
250```json [settings]
251{
252 "language_models": {
253 "deepseek": {
254 "api_url": "https://api.deepseek.com",
255 "available_models": [
256 {
257 "name": "deepseek-chat",
258 "display_name": "DeepSeek Chat",
259 "max_tokens": 64000
260 },
261 {
262 "name": "deepseek-reasoner",
263 "display_name": "DeepSeek Reasoner",
264 "max_tokens": 64000,
265 "max_output_tokens": 4096
266 }
267 ]
268 }
269 }
270}
271```
272
273Custom models will be listed in the model dropdown in the Agent Panel.
274You can also modify the `api_url` to use a custom endpoint if needed.
275
276### GitHub Copilot Chat {#github-copilot-chat}
277
278You can use GitHub Copilot Chat with the Zed agent by choosing it via the model dropdown in the Agent Panel.
279
2801. Open the settings view (`agent: open settings`) and go to the GitHub Copilot Chat section
2812. Click on `Sign in to use GitHub Copilot`, follow the steps shown in the modal.
282
283Alternatively, you can provide an OAuth token via the `GH_COPILOT_TOKEN` environment variable.
284
285> **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).
286
287To 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).
288
289### Google AI {#google-ai}
290
291You can use Gemini models with the Zed agent by choosing it via the model dropdown in the Agent Panel.
292
2931. Go to the Google AI Studio site and [create an API key](https://aistudio.google.com/app/apikey).
2942. Open the settings view (`agent: open settings`) and go to the Google AI section
2953. Enter your Google AI API key and press enter.
296
297The Google AI API key will be saved in your keychain.
298
299Zed 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.
300
301#### Custom Models {#google-ai-custom-models}
302
303By 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.
304
305Here is an example of a custom Google AI model you could add to your Zed settings file ([how to edit](../configuring-zed.md#settings-files)):
306
307```json [settings]
308{
309 "language_models": {
310 "google": {
311 "available_models": [
312 {
313 "name": "gemini-3.1-pro-preview",
314 "display_name": "Gemini 3.1 Pro",
315 "max_tokens": 1000000,
316 "mode": {
317 "type": "thinking",
318 "budget_tokens": 24000
319 }
320 },
321 {
322 "name": "gemini-3-flash-preview",
323 "display_name": "Gemini 3 Flash (Thinking)",
324 "max_tokens": 1000000,
325 "mode": {
326 "type": "thinking",
327 "budget_tokens": 24000
328 }
329 }
330 ]
331 }
332 }
333}
334```
335
336Custom models will be listed in the model dropdown in the Agent Panel.
337
338### LM Studio {#lmstudio}
339
3401. Download and install [the latest version of LM Studio](https://lmstudio.ai/download)
3412. 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:
342
343 ```sh
344 lms get qwen2.5-coder-7b
345 ```
346
3473. Make sure the LM Studio API server is running by executing:
348
349 ```sh
350 lms server start
351 ```
352
353Tip: 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.
354
355### Mistral {#mistral}
356
3571. Visit the Mistral platform and [create an API key](https://console.mistral.ai/api-keys/)
3582. Open the configuration view (`agent: open settings`) and navigate to the Mistral section
3593. Enter your Mistral API key
360
361The Mistral API key will be saved in your keychain.
362
363Zed will also use the `MISTRAL_API_KEY` environment variable if it's defined.
364
365#### Custom Models {#mistral-custom-models}
366
367The 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).
368All the default models support tool use.
369If you wish to use alternate models or customize their parameters, you can do so by adding the following to your Zed settings file ([how to edit](../configuring-zed.md#settings-files)):
370
371```json [settings]
372{
373 "language_models": {
374 "mistral": {
375 "api_url": "https://api.mistral.ai/v1",
376 "available_models": [
377 {
378 "name": "mistral-tiny-latest",
379 "display_name": "Mistral Tiny",
380 "max_tokens": 32000,
381 "max_output_tokens": 4096,
382 "max_completion_tokens": 1024,
383 "supports_tools": true,
384 "supports_images": false
385 }
386 ]
387 }
388 }
389}
390```
391
392Custom models will be listed in the model dropdown in the Agent Panel.
393
394### Ollama {#ollama}
395
396Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
397
3981. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
399
400 ```sh
401 ollama pull mistral
402 ```
403
4042. Make sure that the Ollama server is running. You can start it either via running Ollama.app (macOS) or launching:
405
406 ```sh
407 ollama serve
408 ```
409
4103. In the Agent Panel, select one of the Ollama models using the model dropdown.
411
412#### Ollama Autodiscovery
413
414Zed will automatically discover models that Ollama has pulled. You can turn this off by setting
415the `auto_discover` field in the Ollama settings. If you do this, you should manually specify which
416models are available.
417
418```json [settings]
419{
420 "language_models": {
421 "ollama": {
422 "api_url": "http://localhost:11434",
423 "auto_discover": false,
424 "available_models": [
425 {
426 "name": "qwen2.5-coder",
427 "display_name": "qwen 2.5 coder",
428 "max_tokens": 32768,
429 "supports_tools": true,
430 "supports_thinking": true,
431 "supports_images": true
432 }
433 ]
434 }
435 }
436}
437```
438
439#### Ollama Context Length {#ollama-context}
440
441Zed API requests to Ollama include the context length as the `num_ctx` parameter. By default, Zed uses a context length of `4096` tokens for all Ollama models.
442
443> **Note**: Token counts displayed in the Agent Panel are only estimates and will differ from the model's native tokenizer.
444
445You can set a context length for all Ollama models using the `context_window` setting. This can also be configured in the Ollama provider settings UI:
446
447```json [settings]
448{
449 "language_models": {
450 "ollama": {
451 "context_window": 8192
452 }
453 }
454}
455```
456
457Alternatively, you can configure the context length per-model using the `max_tokens` field in `available_models`:
458
459```json [settings]
460{
461 "language_models": {
462 "ollama": {
463 "api_url": "http://localhost:11434",
464 "available_models": [
465 {
466 "name": "qwen2.5-coder",
467 "display_name": "qwen 2.5 coder 32K",
468 "max_tokens": 32768,
469 "supports_tools": true,
470 "supports_thinking": true,
471 "supports_images": true
472 }
473 ]
474 }
475 }
476}
477```
478
479> **Note**: If `context_window` is set, it overrides any per-model `max_tokens` values.
480
481If you specify a context length that is too large for your hardware, Ollama will log an error.
482You can watch these logs by running: `tail -f ~/.ollama/logs/ollama.log` (macOS) or `journalctl -u ollama -f` (Linux).
483Depending on the memory available on your machine, you may need to adjust the context length to a smaller value.
484
485You may also optionally specify a value for `keep_alive` for each available model.
486This can be an integer (seconds) or alternatively a string duration like "5m", "10m", "1h", "1d", etc.
487For example, `"keep_alive": "120s"` will allow the remote server to unload the model (freeing up GPU VRAM) after 120 seconds.
488
489The `supports_tools` option controls whether the model will use additional tools.
490If 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.
491If 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.
492
493The `supports_thinking` option controls whether the model will perform an explicit "thinking" (reasoning) pass before producing its final answer.
494If the model is tagged with `thinking` in the Ollama catalog, set this option and you can use it in Zed.
495
496The `supports_images` option enables the model's vision capabilities, allowing it to process images included in the conversation context.
497If the model is tagged with `vision` in the Ollama catalog, set this option and you can use it in Zed.
498
499#### Ollama Authentication
500
501In 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.
502
503One such service is [Ollama Turbo](https://ollama.com/turbo). To configure Zed to use Ollama Turbo:
504
5051. Sign in to your Ollama account and subscribe to Ollama Turbo
5062. Visit [ollama.com/settings/keys](https://ollama.com/settings/keys) and create an API key
5073. Open the settings view (`agent: open settings`) and go to the Ollama section
5084. Paste your API key and press enter.
5095. For the API URL enter `https://ollama.com`
510
511Zed will also use the `OLLAMA_API_KEY` environment variables if defined.
512
513### OpenAI {#openai}
514
5151. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
5162. Make sure that your OpenAI account has credits
5173. Open the settings view (`agent: open settings`) and go to the OpenAI section
5184. Enter your OpenAI API key
519
520The OpenAI API key will be saved in your keychain.
521
522Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
523
524#### Custom Models {#openai-custom-models}
525
526The Zed agent comes pre-configured to use the latest version for common OpenAI models (GPT-5.2, GPT-5 mini, GPT-5.2 Codex, and others).
527To 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 file ([how to edit](../configuring-zed.md#settings-files)):
528
529```json [settings]
530{
531 "language_models": {
532 "openai": {
533 "available_models": [
534 {
535 "name": "gpt-5.2",
536 "display_name": "gpt-5.2 high",
537 "reasoning_effort": "high",
538 "max_tokens": 272000,
539 "max_completion_tokens": 20000
540 },
541 {
542 "name": "gpt-5-nano",
543 "display_name": "GPT-5 Nano",
544 "max_tokens": 400000
545 },
546 {
547 "name": "gpt-5.2-codex",
548 "display_name": "GPT-5.2 Codex",
549 "max_tokens": 128000,
550 "capabilities": {
551 "chat_completions": false
552 }
553 }
554 ]
555 }
556 }
557}
558```
559
560You 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).
561
562For reasoning-focused models, set `max_completion_tokens` as well to avoid incurring high reasoning token costs.
563
564If a model does not support the `/chat/completions` endpoint (for example `gpt-5.2-codex`), disable it by setting `capabilities.chat_completions` to `false`. Zed will use the Responses endpoint instead.
565
566Custom models will be listed in the model dropdown in the Agent Panel.
567
568### OpenAI API Compatible {#openai-api-compatible}
569
570Zed 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.
571This is useful for connecting to other hosted services (like Together AI, Anyscale, etc.) or local models.
572
573You can add a custom, OpenAI-compatible model either via the UI or by editing your settings file.
574
575To 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.
576Then, fill up the input fields available in the modal.
577
578To do it via your settings file ([how to edit](../configuring-zed.md#settings-files)), add the following snippet under `language_models`:
579
580```json [settings]
581{
582 "language_models": {
583 "openai_compatible": {
584 // Using Together AI as an example
585 "Together AI": {
586 "api_url": "https://api.together.xyz/v1",
587 "available_models": [
588 {
589 "name": "mistralai/Mixtral-8x7B-Instruct-v0.1",
590 "display_name": "Together Mixtral 8x7B",
591 "max_tokens": 32768,
592 "capabilities": {
593 "tools": true,
594 "images": false,
595 "parallel_tool_calls": false,
596 "prompt_cache_key": false
597 }
598 }
599 ]
600 }
601 }
602 }
603}
604```
605
606By default, OpenAI-compatible models inherit the following capabilities:
607
608- `tools`: true (supports tool/function calling)
609- `images`: false (does not support image inputs)
610- `parallel_tool_calls`: false (does not support `parallel_tool_calls` parameter)
611- `prompt_cache_key`: false (does not support `prompt_cache_key` parameter)
612- `chat_completions`: true (calls the `/chat/completions` endpoint)
613
614If 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.
615
616Note that LLM API keys aren't stored in your settings file.
617So, 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>`.
618
619### OpenRouter {#openrouter}
620
621OpenRouter provides access to multiple AI models through a single API. It supports tool use for compatible models.
622
6231. Visit [OpenRouter](https://openrouter.ai) and create an account
6242. Generate an API key from your [OpenRouter keys page](https://openrouter.ai/keys)
6253. Open the settings view (`agent: open settings`) and go to the OpenRouter section
6264. Enter your OpenRouter API key
627
628The OpenRouter API key will be saved in your keychain.
629
630Zed will also use the `OPENROUTER_API_KEY` environment variable if it's defined.
631
632> **Changed in Preview (v0.225).** See [release notes](/releases#0.225).
633
634When using OpenRouter as your assistant provider, you must explicitly select a model in your settings. OpenRouter no longer provides a default model selection.
635
636Configure your preferred OpenRouter model in `settings.json`:
637
638```json [settings]
639{
640 "agent": {
641 "default_model": {
642 "provider": "openrouter",
643 "model": "openrouter/auto"
644 }
645 }
646}
647```
648
649The `openrouter/auto` model automatically routes your requests to the most appropriate available model. You can also specify any model available through OpenRouter's API.
650
651#### Custom Models {#openrouter-custom-models}
652
653You can add custom models to the OpenRouter provider by adding the following to your Zed settings file ([how to edit](../configuring-zed.md#settings-files)):
654
655```json [settings]
656{
657 "language_models": {
658 "open_router": {
659 "api_url": "https://openrouter.ai/api/v1",
660 "available_models": [
661 {
662 "name": "google/gemini-2.0-flash-thinking-exp",
663 "display_name": "Gemini 2.0 Flash (Thinking)",
664 "max_tokens": 200000,
665 "max_output_tokens": 8192,
666 "supports_tools": true,
667 "supports_images": true,
668 "mode": {
669 "type": "thinking",
670 "budget_tokens": 8000
671 }
672 }
673 ]
674 }
675 }
676}
677```
678
679The available configuration options for each model are:
680
681- `name` (required): The model identifier used by OpenRouter
682- `display_name` (optional): A human-readable name shown in the UI
683- `max_tokens` (required): The model's context window size
684- `max_output_tokens` (optional): Maximum tokens the model can generate
685- `max_completion_tokens` (optional): Maximum completion tokens
686- `supports_tools` (optional): Whether the model supports tool/function calling
687- `supports_images` (optional): Whether the model supports image inputs
688- `mode` (optional): Special mode configuration for thinking models
689
690You can find available models and their specifications on the [OpenRouter models page](https://openrouter.ai/models).
691
692Custom models will be listed in the model dropdown in the Agent Panel.
693
694#### Provider Routing
695
696You can optionally control how OpenRouter routes a given custom model request among underlying upstream providers via the `provider` object on each model entry.
697
698Supported fields (all optional):
699
700- `order`: Array of provider slugs to try first, in order (e.g. `["anthropic", "openai"]`)
701- `allow_fallbacks` (default: `true`): Whether fallback providers may be used if preferred ones are unavailable
702- `require_parameters` (default: `false`): Only use providers that support every parameter you supplied
703- `data_collection` (default: `allow`): `"allow"` or `"disallow"` (controls use of providers that may store data)
704- `only`: Whitelist of provider slugs allowed for this request
705- `ignore`: Provider slugs to skip
706- `quantizations`: Restrict to specific quantization variants (e.g. `["int4","int8"]`)
707- `sort`: Sort strategy for candidate providers (e.g. `"price"` or `"throughput"`)
708
709Example adding routing preferences to a model:
710
711```json [settings]
712{
713 "language_models": {
714 "open_router": {
715 "api_url": "https://openrouter.ai/api/v1",
716 "available_models": [
717 {
718 "name": "openrouter/auto",
719 "display_name": "Auto Router (Tools Preferred)",
720 "max_tokens": 2000000,
721 "supports_tools": true,
722 "provider": {
723 "order": ["anthropic", "openai"],
724 "allow_fallbacks": true,
725 "require_parameters": true,
726 "only": ["anthropic", "openai", "google"],
727 "ignore": ["cohere"],
728 "quantizations": ["int8"],
729 "sort": "price",
730 "data_collection": "allow"
731 }
732 }
733 ]
734 }
735 }
736}
737```
738
739These routing controls let you fine‑tune cost, capability, and reliability trade‑offs without changing the model name you select in the UI.
740
741### Vercel v0 {#vercel-v0}
742
743[Vercel v0](https://v0.app/docs/api/model) is a model for generating full-stack apps, with framework-aware completions for stacks like Next.js and Vercel.
744It supports text and image inputs and provides fast streaming responses.
745
746The v0 models are [OpenAI-compatible models](/#openai-api-compatible), and Vercel appears as a dedicated provider in the panel's settings view.
747
748To start using it with Zed, ensure you have first created a [v0 API key](https://v0.dev/chat/settings/keys).
749Once you have it, paste it directly into the Vercel provider section in the panel's settings view.
750
751You should then find it as `v0-1.5-md` in the model dropdown in the Agent Panel.
752
753### xAI {#xai}
754
755Zed includes a dedicated [xAI](https://x.ai/) provider. You can use your own API key to access Grok models.
756
7571. [Create an API key in the xAI Console](https://console.x.ai/team/default/api-keys)
7582. Open the settings view (`agent: open settings`) and go to the **xAI** section
7593. Enter your xAI API key
760
761The xAI API key will be saved in your keychain. Zed will also use the `XAI_API_KEY` environment variable if it's defined.
762
763> **Note:** The xAI API is OpenAI-compatible, and Zed also includes a dedicated xAI provider. We recommend using the dedicated `x_ai` provider configuration instead of the [OpenAI API Compatible](#openai-api-compatible) method.
764
765#### Custom Models {#xai-custom-models}
766
767The 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 file ([how to edit](../configuring-zed.md#settings-files)):
768
769```json [settings]
770{
771 "language_models": {
772 "x_ai": {
773 "api_url": "https://api.x.ai/v1",
774 "available_models": [
775 {
776 "name": "grok-1.5",
777 "display_name": "Grok 1.5",
778 "max_tokens": 131072,
779 "max_output_tokens": 8192
780 },
781 {
782 "name": "grok-1.5v",
783 "display_name": "Grok 1.5V (Vision)",
784 "max_tokens": 131072,
785 "max_output_tokens": 8192,
786 "supports_images": true
787 }
788 ]
789 }
790 }
791}
792```
793
794## Custom Provider Endpoints {#custom-provider-endpoint}
795
796You can use a custom API endpoint for different providers, as long as it's compatible with the provider's API structure.
797To do so, add the following to your settings file ([how to edit](../configuring-zed.md#settings-files)):
798
799```json
800{
801 "language_models": {
802 "some-provider": {
803 "api_url": "http://localhost:11434"
804 }
805 }
806}
807```
808
809Currently, `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
810
811This is the same infrastructure that powers models that are, for example, [OpenAI-compatible](#openai-api-compatible).