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