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) and [Inline Assistant](./inline-assistant.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 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
155Anthropic 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:
156
157```json [settings]
158{
159 "language_models": {
160 "bedrock": {
161 "authentication_method": "named_profile",
162 "region": "your-aws-region",
163 "profile": "your-profile-name",
164 "allow_extended_context": true
165 }
166 }
167}
168```
169
170Zed 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.
171
172#### Image Support {#bedrock-image-support}
173
174Bedrock 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.
175
176### Anthropic {#anthropic}
177
178You can use Anthropic models by choosing them via the model dropdown in the Agent Panel.
179
1801. Sign up for Anthropic and [create an API key](https://console.anthropic.com/settings/keys)
1812. Make sure that your Anthropic account has credits
1823. Open the settings view (`agent: open settings`) and go to the Anthropic section
1834. Enter your Anthropic API key
184
185Even 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.
186
187Zed will also use the `ANTHROPIC_API_KEY` environment variable if it's defined.
188
189#### Custom Models {#anthropic-custom-models}
190
191You 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)):
192
193```json [settings]
194{
195 "language_models": {
196 "anthropic": {
197 "available_models": [
198 {
199 "name": "claude-3-5-sonnet-20240620",
200 "display_name": "Sonnet 2024-June",
201 "max_tokens": 128000,
202 "max_output_tokens": 2560,
203 "cache_configuration": {
204 "max_cache_anchors": 10,
205 "min_total_token": 10000,
206 "should_speculate": false
207 },
208 "tool_override": "some-model-that-supports-toolcalling"
209 }
210 ]
211 }
212 }
213}
214```
215
216Custom models will be listed in the model dropdown in the Agent Panel.
217
218You 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:
219
220```json
221{
222 "name": "claude-sonnet-4-latest",
223 "display_name": "claude-sonnet-4-thinking",
224 "max_tokens": 200000,
225 "mode": {
226 "type": "thinking",
227 "budget_tokens": 4096
228 }
229}
230```
231
232### DeepSeek {#deepseek}
233
2341. Visit the DeepSeek platform and [create an API key](https://platform.deepseek.com/api_keys)
2352. Open the settings view (`agent: open settings`) and go to the DeepSeek section
2363. Enter your DeepSeek API key
237
238The DeepSeek API key will be saved in your keychain.
239
240Zed will also use the `DEEPSEEK_API_KEY` environment variable if it's defined.
241
242#### Custom Models {#deepseek-custom-models}
243
244The Zed agent comes pre-configured to use the latest version for common models (DeepSeek Chat, DeepSeek Reasoner).
245If 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)):
246
247```json [settings]
248{
249 "language_models": {
250 "deepseek": {
251 "api_url": "https://api.deepseek.com",
252 "available_models": [
253 {
254 "name": "deepseek-chat",
255 "display_name": "DeepSeek Chat",
256 "max_tokens": 64000
257 },
258 {
259 "name": "deepseek-reasoner",
260 "display_name": "DeepSeek Reasoner",
261 "max_tokens": 64000,
262 "max_output_tokens": 4096
263 }
264 ]
265 }
266 }
267}
268```
269
270Custom models will be listed in the model dropdown in the Agent Panel.
271You can also modify the `api_url` to use a custom endpoint if needed.
272
273### GitHub Copilot Chat {#github-copilot-chat}
274
275You can use GitHub Copilot Chat with the Zed agent by choosing it via the model dropdown in the Agent Panel.
276
2771. Open the settings view (`agent: open settings`) and go to the GitHub Copilot Chat section
2782. Click on `Sign in to use GitHub Copilot`, follow the steps shown in the modal.
279
280Alternatively, you can provide an OAuth token via the `GH_COPILOT_TOKEN` environment variable.
281
282> **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).
283
284To 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).
285
286### Google AI {#google-ai}
287
288You can use Gemini models with the Zed agent by choosing it via the model dropdown in the Agent Panel.
289
2901. Go to the Google AI Studio site and [create an API key](https://aistudio.google.com/app/apikey).
2912. Open the settings view (`agent: open settings`) and go to the Google AI section
2923. Enter your Google AI API key and press enter.
293
294The Google AI API key will be saved in your keychain.
295
296Zed 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.
297
298#### Custom Models {#google-ai-custom-models}
299
300By 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.
301
302Here 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)):
303
304```json [settings]
305{
306 "language_models": {
307 "google": {
308 "available_models": [
309 {
310 "name": "gemini-3.1-pro-preview",
311 "display_name": "Gemini 3.1 Pro",
312 "max_tokens": 1000000,
313 "mode": {
314 "type": "thinking",
315 "budget_tokens": 24000
316 }
317 },
318 {
319 "name": "gemini-3-flash-preview",
320 "display_name": "Gemini 3 Flash (Thinking)",
321 "max_tokens": 1000000,
322 "mode": {
323 "type": "thinking",
324 "budget_tokens": 24000
325 }
326 }
327 ]
328 }
329 }
330}
331```
332
333Custom models will be listed in the model dropdown in the Agent Panel.
334
335### LM Studio {#lmstudio}
336
3371. Download and install [the latest version of LM Studio](https://lmstudio.ai/download)
3382. 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:
339
340 ```sh
341 lms get qwen2.5-coder-7b
342 ```
343
3443. Make sure the LM Studio API server is running by executing:
345
346 ```sh
347 lms server start
348 ```
349
350Tip: 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.
351
352### Mistral {#mistral}
353
3541. Visit the Mistral platform and [create an API key](https://console.mistral.ai/api-keys/)
3552. Open the configuration view (`agent: open settings`) and navigate to the Mistral section
3563. Enter your Mistral API key
357
358The Mistral API key will be saved in your keychain.
359
360Zed will also use the `MISTRAL_API_KEY` environment variable if it's defined.
361
362#### Custom Models {#mistral-custom-models}
363
364The 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).
365All the default models support tool use.
366If 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)):
367
368```json [settings]
369{
370 "language_models": {
371 "mistral": {
372 "api_url": "https://api.mistral.ai/v1",
373 "available_models": [
374 {
375 "name": "mistral-tiny-latest",
376 "display_name": "Mistral Tiny",
377 "max_tokens": 32000,
378 "max_output_tokens": 4096,
379 "max_completion_tokens": 1024,
380 "supports_tools": true,
381 "supports_images": false
382 }
383 ]
384 }
385 }
386}
387```
388
389Custom models will be listed in the model dropdown in the Agent Panel.
390
391### Ollama {#ollama}
392
393Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`.
394
3951. Download one of the [available models](https://ollama.com/models), for example, for `mistral`:
396
397 ```sh
398 ollama pull mistral
399 ```
400
4012. Make sure that the Ollama server is running. You can start it either via running Ollama.app (macOS) or launching:
402
403 ```sh
404 ollama serve
405 ```
406
4073. In the Agent Panel, select one of the Ollama models using the model dropdown.
408
409#### Ollama Autodiscovery
410
411Zed will automatically discover models that Ollama has pulled. You can turn this off by setting
412the `auto_discover` field in the Ollama settings. If you do this, you should manually specify which
413models are available.
414
415```json [settings]
416{
417 "language_models": {
418 "ollama": {
419 "api_url": "http://localhost:11434",
420 "auto_discover": false,
421 "available_models": [
422 {
423 "name": "qwen2.5-coder",
424 "display_name": "qwen 2.5 coder",
425 "max_tokens": 32768,
426 "supports_tools": true,
427 "supports_thinking": true,
428 "supports_images": true
429 }
430 ]
431 }
432 }
433}
434```
435
436#### Ollama Context Length {#ollama-context}
437
438Zed 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.
439
440> **Note**: Token counts displayed in the Agent Panel are only estimates and will differ from the model's native tokenizer.
441
442You 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:
443
444```json [settings]
445{
446 "language_models": {
447 "ollama": {
448 "context_window": 8192
449 }
450 }
451}
452```
453
454Alternatively, you can configure the context length per-model using the `max_tokens` field in `available_models`:
455
456```json [settings]
457{
458 "language_models": {
459 "ollama": {
460 "api_url": "http://localhost:11434",
461 "available_models": [
462 {
463 "name": "qwen2.5-coder",
464 "display_name": "qwen 2.5 coder 32K",
465 "max_tokens": 32768,
466 "supports_tools": true,
467 "supports_thinking": true,
468 "supports_images": true
469 }
470 ]
471 }
472 }
473}
474```
475
476> **Note**: If `context_window` is set, it overrides any per-model `max_tokens` values.
477
478If you specify a context length that is too large for your hardware, Ollama will log an error.
479You can watch these logs by running: `tail -f ~/.ollama/logs/ollama.log` (macOS) or `journalctl -u ollama -f` (Linux).
480Depending on the memory available on your machine, you may need to adjust the context length to a smaller value.
481
482You may also optionally specify a value for `keep_alive` for each available model.
483This can be an integer (seconds) or alternatively a string duration like "5m", "10m", "1h", "1d", etc.
484For example, `"keep_alive": "120s"` will allow the remote server to unload the model (freeing up GPU VRAM) after 120 seconds.
485
486The `supports_tools` option controls whether the model will use additional tools.
487If 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.
488If 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.
489
490The `supports_thinking` option controls whether the model will perform an explicit "thinking" (reasoning) pass before producing its final answer.
491If the model is tagged with `thinking` in the Ollama catalog, set this option and you can use it in Zed.
492
493The `supports_images` option enables the model's vision capabilities, allowing it to process images included in the conversation context.
494If the model is tagged with `vision` in the Ollama catalog, set this option and you can use it in Zed.
495
496#### Ollama Authentication
497
498In 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.
499
500One such service is [Ollama Turbo](https://ollama.com/turbo). To configure Zed to use Ollama Turbo:
501
5021. Sign in to your Ollama account and subscribe to Ollama Turbo
5032. Visit [ollama.com/settings/keys](https://ollama.com/settings/keys) and create an API key
5043. Open the settings view (`agent: open settings`) and go to the Ollama section
5054. Paste your API key and press enter.
5065. For the API URL enter `https://ollama.com`
507
508Zed will also use the `OLLAMA_API_KEY` environment variables if defined.
509
510### OpenAI {#openai}
511
5121. Visit the OpenAI platform and [create an API key](https://platform.openai.com/account/api-keys)
5132. Make sure that your OpenAI account has credits
5143. Open the settings view (`agent: open settings`) and go to the OpenAI section
5154. Enter your OpenAI API key
516
517The OpenAI API key will be saved in your keychain.
518
519Zed will also use the `OPENAI_API_KEY` environment variable if it's defined.
520
521#### Custom Models {#openai-custom-models}
522
523The 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).
524To 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)):
525
526```json [settings]
527{
528 "language_models": {
529 "openai": {
530 "available_models": [
531 {
532 "name": "gpt-5.2",
533 "display_name": "gpt-5.2 high",
534 "reasoning_effort": "high",
535 "max_tokens": 272000,
536 "max_completion_tokens": 20000
537 },
538 {
539 "name": "gpt-5-nano",
540 "display_name": "GPT-5 Nano",
541 "max_tokens": 400000
542 },
543 {
544 "name": "gpt-5.2-codex",
545 "display_name": "GPT-5.2 Codex",
546 "max_tokens": 128000,
547 "capabilities": {
548 "chat_completions": false
549 }
550 }
551 ]
552 }
553 }
554}
555```
556
557You 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).
558
559For reasoning-focused models, set `max_completion_tokens` as well to avoid incurring high reasoning token costs.
560
561If 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.
562
563Custom models will be listed in the model dropdown in the Agent Panel.
564
565### OpenAI API Compatible {#openai-api-compatible}
566
567Zed 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.
568This is useful for connecting to other hosted services (like Together AI, Anyscale, etc.) or local models.
569
570You can add a custom, OpenAI-compatible model either via the UI or by editing your settings file.
571
572To 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.
573Then, fill up the input fields available in the modal.
574
575To do it via your settings file ([how to edit](../configuring-zed.md#settings-files)), add the following snippet under `language_models`:
576
577```json [settings]
578{
579 "language_models": {
580 "openai_compatible": {
581 // Using Together AI as an example
582 "Together AI": {
583 "api_url": "https://api.together.xyz/v1",
584 "available_models": [
585 {
586 "name": "mistralai/Mixtral-8x7B-Instruct-v0.1",
587 "display_name": "Together Mixtral 8x7B",
588 "max_tokens": 32768,
589 "capabilities": {
590 "tools": true,
591 "images": false,
592 "parallel_tool_calls": false,
593 "prompt_cache_key": false
594 }
595 }
596 ]
597 }
598 }
599 }
600}
601```
602
603By default, OpenAI-compatible models inherit the following capabilities:
604
605- `tools`: true (supports tool/function calling)
606- `images`: false (does not support image inputs)
607- `parallel_tool_calls`: false (does not support `parallel_tool_calls` parameter)
608- `prompt_cache_key`: false (does not support `prompt_cache_key` parameter)
609- `chat_completions`: true (calls the `/chat/completions` endpoint)
610
611If 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.
612
613Note that LLM API keys aren't stored in your settings file.
614So, 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>`.
615
616### OpenRouter {#openrouter}
617
618OpenRouter provides access to multiple AI models through a single API. It supports tool use for compatible models.
619
6201. Visit [OpenRouter](https://openrouter.ai) and create an account
6212. Generate an API key from your [OpenRouter keys page](https://openrouter.ai/keys)
6223. Open the settings view (`agent: open settings`) and go to the OpenRouter section
6234. Enter your OpenRouter API key
624
625The OpenRouter API key will be saved in your keychain.
626
627Zed will also use the `OPENROUTER_API_KEY` environment variable if it's defined.
628
629When using OpenRouter as your assistant provider, you must explicitly select a model in your settings. OpenRouter no longer provides a default model selection.
630
631Configure your preferred OpenRouter model in `settings.json`:
632
633```json [settings]
634{
635 "agent": {
636 "default_model": {
637 "provider": "openrouter",
638 "model": "openrouter/auto"
639 }
640 }
641}
642```
643
644The `openrouter/auto` model automatically routes your requests to the most appropriate available model. You can also specify any model available through OpenRouter's API.
645
646#### Custom Models {#openrouter-custom-models}
647
648You 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)):
649
650```json [settings]
651{
652 "language_models": {
653 "open_router": {
654 "api_url": "https://openrouter.ai/api/v1",
655 "available_models": [
656 {
657 "name": "google/gemini-2.0-flash-thinking-exp",
658 "display_name": "Gemini 2.0 Flash (Thinking)",
659 "max_tokens": 200000,
660 "max_output_tokens": 8192,
661 "supports_tools": true,
662 "supports_images": true,
663 "mode": {
664 "type": "thinking",
665 "budget_tokens": 8000
666 }
667 }
668 ]
669 }
670 }
671}
672```
673
674The available configuration options for each model are:
675
676- `name` (required): The model identifier used by OpenRouter
677- `display_name` (optional): A human-readable name shown in the UI
678- `max_tokens` (required): The model's context window size
679- `max_output_tokens` (optional): Maximum tokens the model can generate
680- `max_completion_tokens` (optional): Maximum completion tokens
681- `supports_tools` (optional): Whether the model supports tool/function calling
682- `supports_images` (optional): Whether the model supports image inputs
683- `mode` (optional): Special mode configuration for thinking models
684
685You can find available models and their specifications on the [OpenRouter models page](https://openrouter.ai/models).
686
687Custom models will be listed in the model dropdown in the Agent Panel.
688
689#### Provider Routing
690
691You can optionally control how OpenRouter routes a given custom model request among underlying upstream providers via the `provider` object on each model entry.
692
693Supported fields (all optional):
694
695- `order`: Array of provider slugs to try first, in order (e.g. `["anthropic", "openai"]`)
696- `allow_fallbacks` (default: `true`): Whether fallback providers may be used if preferred ones are unavailable
697- `require_parameters` (default: `false`): Only use providers that support every parameter you supplied
698- `data_collection` (default: `allow`): `"allow"` or `"disallow"` (controls use of providers that may store data)
699- `only`: Whitelist of provider slugs allowed for this request
700- `ignore`: Provider slugs to skip
701- `quantizations`: Restrict to specific quantization variants (e.g. `["int4","int8"]`)
702- `sort`: Sort strategy for candidate providers (e.g. `"price"` or `"throughput"`)
703
704Example adding routing preferences to a model:
705
706```json [settings]
707{
708 "language_models": {
709 "open_router": {
710 "api_url": "https://openrouter.ai/api/v1",
711 "available_models": [
712 {
713 "name": "openrouter/auto",
714 "display_name": "Auto Router (Tools Preferred)",
715 "max_tokens": 2000000,
716 "supports_tools": true,
717 "provider": {
718 "order": ["anthropic", "openai"],
719 "allow_fallbacks": true,
720 "require_parameters": true,
721 "only": ["anthropic", "openai", "google"],
722 "ignore": ["cohere"],
723 "quantizations": ["int8"],
724 "sort": "price",
725 "data_collection": "allow"
726 }
727 }
728 ]
729 }
730 }
731}
732```
733
734These routing controls let you fine‑tune cost, capability, and reliability trade‑offs without changing the model name you select in the UI.
735
736### Vercel AI Gateway {#vercel-ai-gateway}
737
738[Vercel AI Gateway](https://vercel.com/ai-gateway) provides access to many models through a single OpenAI-compatible endpoint.
739
7401. 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)
7412. Open the settings view (`agent: open settings`) and go to the **Vercel AI Gateway** section
7423. Enter your Vercel AI Gateway API key
743
744The Vercel AI Gateway API key will be saved in your keychain.
745
746Zed will also use the `VERCEL_AI_GATEWAY_API_KEY` environment variable if it's defined.
747
748You can also set a custom endpoint for Vercel AI Gateway in your settings file:
749
750```json [settings]
751{
752 "language_models": {
753 "vercel_ai_gateway": {
754 "api_url": "https://ai-gateway.vercel.sh/v1"
755 }
756 }
757}
758```
759
760### Vercel v0 {#vercel-v0}
761
762[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.
763It supports text and image inputs and provides fast streaming responses.
764
765The v0 models are [OpenAI-compatible models](/#openai-api-compatible), and Vercel appears as a dedicated provider in the panel's settings view.
766
767To start using it with Zed, ensure you have first created a [v0 API key](https://v0.dev/chat/settings/keys).
768Once you have it, paste it directly into the Vercel provider section in the panel's settings view.
769
770You should then find it as `v0-1.5-md` in the model dropdown in the Agent Panel.
771
772### xAI {#xai}
773
774Zed includes a dedicated [xAI](https://x.ai/) provider. You can use your own API key to access Grok models.
775
7761. [Create an API key in the xAI Console](https://console.x.ai/team/default/api-keys)
7772. Open the settings view (`agent: open settings`) and go to the **xAI** section
7783. Enter your xAI API key
779
780The xAI API key will be saved in your keychain. Zed will also use the `XAI_API_KEY` environment variable if it's defined.
781
782> **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.
783
784#### Custom Models {#xai-custom-models}
785
786The 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)):
787
788```json [settings]
789{
790 "language_models": {
791 "x_ai": {
792 "api_url": "https://api.x.ai/v1",
793 "available_models": [
794 {
795 "name": "grok-1.5",
796 "display_name": "Grok 1.5",
797 "max_tokens": 131072,
798 "max_output_tokens": 8192
799 },
800 {
801 "name": "grok-1.5v",
802 "display_name": "Grok 1.5V (Vision)",
803 "max_tokens": 131072,
804 "max_output_tokens": 8192,
805 "supports_images": true
806 }
807 ]
808 }
809 }
810}
811```
812
813## Custom Provider Endpoints {#custom-provider-endpoint}
814
815You can use a custom API endpoint for different providers, as long as it's compatible with the provider's API structure.
816To do so, add the following to your settings file ([how to edit](../configuring-zed.md#settings-files)):
817
818```json
819{
820 "language_models": {
821 "some-provider": {
822 "api_url": "http://localhost:11434"
823 }
824 }
825}
826```
827
828Currently, `some-provider` can be any of the following values: `anthropic`, `google`, `ollama`, `openai`.
829
830This is the same infrastructure that powers models that are, for example, [OpenAI-compatible](#openai-api-compatible).