Download

Use API Access

Use API access when a provider gives you an API key, API credits, top-ups, or usage billing.

Paid API credits, usage billing, and top-ups are API access, even when you pay the provider directly. Use this path when the provider gives you an API key.

Supported API Providers

Zed supports these first-class API providers for model-backed Zed AI features:

What API Access Applies To

Use API access for the Zed Agent, Inline Assistant, Git commit generation, thread summaries, and similar Zed-owned AI features.

External Agents and Terminal Threads usually configure model access in the agent or CLI itself. See Agents for the difference between agent paths and model access paths.

API Keys and Environment Variables

Most API-access providers can be configured in Zed's Agent Settings panel with agent: open settings. Keys saved through Zed are stored in the system keychain, not in settings.json.

Zed also reads provider-specific environment variables. Non-empty environment variables take precedence over keychain values. If a key comes from an environment variable, unset the variable and restart Zed to stop using it.

ProviderEnvironment variable
AnthropicANTHROPIC_API_KEY
OpenAIOPENAI_API_KEY
Google AIGEMINI_API_KEY, falling back to GOOGLE_AI_API_KEY
MistralMISTRAL_API_KEY
DeepSeekDEEPSEEK_API_KEY
xAIXAI_API_KEY
OpenCodeOPENCODE_API_KEY
OpenRouterOPENROUTER_API_KEY
Vercel AI GatewayVERCEL_AI_GATEWAY_API_KEY
OllamaOLLAMA_API_KEY
LM StudioLMSTUDIO_API_KEY

OpenAI-compatible provider environment variables are generated from the configured provider ID as upper snake case plus _API_KEY. For example, provider ID my-gateway uses MY_GATEWAY_API_KEY.

Remote Projects

Zed LLM providers for Zed AI features are initialized in the local Zed app. In SSH, dev container, and other remote projects, API keys saved in Zed are read from the local system keychain, and provider environment variables are read from the local Zed process environment.

External Agents and Terminal Threads may run their own processes and use their own remote or local environment. See External Agents and Terminal Threads.

Provider Notes

Anthropic

Use Anthropic API access when you have an Anthropic API key or API credits. Claude Pro and Max subscriptions are separate; see Use an Existing Subscription.

  1. Sign up for Anthropic and create an API key.
  2. Make sure your Anthropic account has API credits.
  3. Open Agent Settings with agent: open settings and go to the Anthropic section.
  4. Enter your Anthropic API key.

Zed also reads ANTHROPIC_API_KEY from the local Zed process environment.

Custom Anthropic Models

Add custom Anthropic models in settings when you need an alternate model ID, display name, context window, output limit, tool override, or thinking mode.

{
  "language_models": {
    "anthropic": {
      "available_models": [
        {
          "name": "claude-3-5-sonnet-20240620",
          "display_name": "Sonnet 2024-June",
          "max_tokens": 128000,
          "max_output_tokens": 2560,
          "tool_override": "some-model-that-supports-toolcalling"
        }
      ]
    }
  }
}

For Anthropic models that support extended thinking, add a mode configuration:

{
  "language_models": {
    "anthropic": {
      "available_models": [
        {
          "name": "claude-sonnet-4-latest",
          "display_name": "claude-sonnet-4-thinking",
          "max_tokens": 200000,
          "mode": {
            "type": "thinking",
            "budget_tokens": 4096
          }
        }
      ]
    }
  }
}

OpenAI API

Use OpenAI API access when you have an OpenAI API key or API billing. ChatGPT Plus and Pro subscriptions use a different setup path; see Use an Existing Subscription.

  1. Visit the OpenAI platform and create an API key.
  2. Make sure your OpenAI account has credits or billing enabled.
  3. Open Agent Settings with agent: open settings and go to the OpenAI section.
  4. Enter your OpenAI API key.

Zed also reads OPENAI_API_KEY from the local Zed process environment.

Custom OpenAI Models

Add custom OpenAI models in your settings file when you need alternate model IDs, preview releases, or custom request parameters.

{
  "language_models": {
    "openai": {
      "available_models": [
        {
          "name": "gpt-5.2",
          "display_name": "gpt-5.2 high",
          "reasoning_effort": "high",
          "max_tokens": 272000,
          "max_completion_tokens": 20000
        }
      ]
    }
  }
}

You must provide the model's context window in max_tokens. For reasoning-focused models, set max_completion_tokens to avoid high reasoning-token costs.

Google AI

Use Google AI API access when you have a Gemini API key.

  1. Go to Google AI Studio and create an API key.
  2. Open Agent Settings with agent: open settings and go to the Google AI section.
  3. Enter your Google AI API key.

Zed reads GEMINI_API_KEY, falling back to GOOGLE_AI_API_KEY, from the local Zed process environment.

Custom Google AI Models

Add custom Google AI models when you need a specific Gemini model version, including experimental models, or a thinking-mode configuration.

{
  "language_models": {
    "google": {
      "available_models": [
        {
          "name": "gemini-3.1-pro-preview",
          "display_name": "Gemini 3.1 Pro",
          "max_tokens": 1000000,
          "mode": {
            "type": "thinking",
            "budget_tokens": 24000
          }
        },
        {
          "name": "gemini-3-flash-preview",
          "display_name": "Gemini 3 Flash (Thinking)",
          "max_tokens": 1000000,
          "mode": {
            "type": "thinking",
            "budget_tokens": 24000
          }
        }
      ]
    }
  }
}

Mistral

Use Mistral API access when you have a Mistral API key.

  1. Visit the Mistral platform and create an API key.
  2. Open Agent Settings with agent: open settings and go to the Mistral section.
  3. Enter your Mistral API key.

Zed also reads MISTRAL_API_KEY from the local Zed process environment.

Custom Mistral Models

Add custom Mistral models when you need alternate model IDs, custom limits, tool support, image support, or a custom endpoint.

{
  "language_models": {
    "mistral": {
      "api_url": "https://api.mistral.ai/v1",
      "available_models": [
        {
          "name": "mistral-tiny-latest",
          "display_name": "Mistral Tiny",
          "max_tokens": 32000,
          "max_output_tokens": 4096,
          "max_completion_tokens": 1024,
          "supports_tools": true,
          "supports_images": false
        }
      ]
    }
  }
}

DeepSeek

Use DeepSeek API access when you have paid API usage, top-ups, or an API key. In Zed, DeepSeek is API access, not subscription sign-in.

  1. Visit the DeepSeek platform and create an API key.
  2. Open Agent Settings with agent: open settings and go to the DeepSeek section.
  3. Enter your DeepSeek API key.

Zed also reads DEEPSEEK_API_KEY from the local Zed process environment.

Custom DeepSeek Models

Add custom DeepSeek models when you need alternate model IDs, custom token limits, or a custom endpoint.

{
  "language_models": {
    "deepseek": {
      "api_url": "https://api.deepseek.com",
      "available_models": [
        {
          "name": "deepseek-v4-flash",
          "display_name": "DeepSeek V4 Flash",
          "max_tokens": 1000000,
          "max_output_tokens": 384000
        },
        {
          "name": "deepseek-v4-pro",
          "display_name": "DeepSeek V4 Pro",
          "max_tokens": 1000000,
          "max_output_tokens": 384000
        }
      ]
    }
  }
}

xAI

Use xAI API access when you have an xAI API key.

  1. Create an API key in the xAI Console.
  2. Open Agent Settings with agent: open settings and go to the xAI section.
  3. Enter your xAI API key.

Zed also reads XAI_API_KEY from the local Zed process environment.

Custom xAI Models

Add custom xAI models when you need alternate Grok model IDs, custom limits, image support, or a custom endpoint.

{
  "language_models": {
    "x_ai": {
      "api_url": "https://api.x.ai/v1",
      "available_models": [
        {
          "name": "grok-1.5",
          "display_name": "Grok 1.5",
          "max_tokens": 131072,
          "max_output_tokens": 8192
        },
        {
          "name": "grok-1.5v",
          "display_name": "Grok 1.5V (Vision)",
          "max_tokens": 131072,
          "max_output_tokens": 8192,
          "supports_images": true
        }
      ]
    }
  }
}

OpenCode API

Use OpenCode API access when you have an OpenCode API key. OpenCode Zen and Go affect which OpenCode models are available.

Zed does not sign in to OpenCode with OAuth or detect your OpenCode subscription; it uses an OpenCode API key saved in the system keychain or OPENCODE_API_KEY.

  1. Visit OpenCode Console and create an account.
  2. Free models are available without payment. To use Zen or Go models, make sure you have enough credits or an active subscription.
  3. Generate an API key from the API Keys section in the OpenCode Console.
  4. Open Agent Settings with agent: open settings and go to the OpenCode section.
  5. Enter your OpenCode API key.

Zed also reads OPENCODE_API_KEY from the local Zed process environment.

By default, models from all OpenCode subscription types are shown. You can hide subscriptions that are not relevant to you in the provider UI or in settings:

{
  "language_models": {
    "opencode": {
      "show_zen_models": true,
      "show_go_models": false,
      "show_free_models": false
    }
  }
}

Note: Zed only bundles configuration for long-term OpenCode Free models. Free models that are available for a limited time are not included in Zed. To use those models, add a custom OpenCode model with configuration from the OpenCode website and models.dev.

Custom OpenCode Models

The Zed Agent comes preconfigured with OpenCode models. Add custom OpenCode models when you need newer models, limited-time Free models, or models with custom endpoints.

Add custom models in your settings file:

{
  "language_models": {
    "opencode": {
      "available_models": [
        {
          "name": "my-custom-model",
          "display_name": "My Custom Model",
          "max_tokens": 123456,
          "max_output_tokens": 98765,
          "protocol": "openai_chat",
          "reasoning_effort_levels": ["low", "medium", "high"],
          "interleaved_reasoning": false,
          "subscription": "go",
          "custom_model_api_url": "https://example.com/zen"
        }
      ]
    }
  }
}

The available configuration options for custom OpenCode models are:

  • name (required): model ID used by OpenCode, such as glm-9000
  • display_name (optional): human-readable model name shown in the UI, such as Custom GLM 9000
  • max_tokens (required): maximum model context window size, such as 1000000
  • max_output_tokens (optional): maximum tokens the model can generate, such as 64000
  • protocol (required): model API protocol, one of "anthropic", "openai_responses", "openai_chat", or "google"
  • reasoning_effort_levels (optional): list of supported reasoning effort levels, such as ["low", "medium", "high"]. The last value in the list is used as the default
  • interleaved_reasoning (optional, default false): whether thinking tokens are sent as a dedicated reasoning_content field. Applies only when using the openai_chat protocol
  • subscription (optional): "zen", "go", or "free"; defaults to "zen"
  • custom_model_api_url (optional): custom API base URL to use instead of the default OpenCode API

Custom OpenCode models are listed in the model dropdown in the Agent Panel.

OpenAI-Compatible Endpoints

Use an OpenAI-compatible endpoint when you have a custom base URL, model ID, and API key.

You can add a custom OpenAI-compatible provider from Agent Settings with agent: open settings. Look for Add Provider in the LLM Providers section and fill in the provider name, API URL, model ID, and context window.

You can also configure the provider in your settings file:

{
  "language_models": {
    "openai_compatible": {
      "my-provider": {
        "api_url": "https://example.com/v1",
        "available_models": [
          {
            "name": "my-model",
            "display_name": "My Model",
            "max_tokens": 128000
          }
        ]
      }
    }
  }
}

By default, OpenAI-compatible models inherit these capabilities:

  • tools: true
  • images: false
  • parallel_tool_calls: false
  • prompt_cache_key: false
  • chat_completions: true
  • interleaved_reasoning: false

If a model only works with the Responses API, set capabilities.chat_completions to false. Zed will use the Responses endpoint for that model.

Enter the API key in the provider settings UI or set the generated environment variable. Do not put API keys in settings.json.