# Zed

> [!NOTE]
> AI Gateway requires the [AI Governance Add-On](https://coder.com/docs/ai-coder/ai-governance.md).
> As of Coder v2.32, deployments without the add-on will not be able to
> access AI Gateway.

Zed IDE supports AI Gateway via its `language_models` configuration in `settings.json`.

## Centralized API Key

To configure Zed to use AI Gateway, you need to edit your `settings.json` file. You can access this by pressing `Cmd/Ctrl + ,` or opening the command palette and searching for "Open Settings".

You can configure both Anthropic and OpenAI providers to point to AI Gateway.

```json
{
  "language_models": {
    "anthropic": {
      "api_url": "https://coder.example.com/api/v2/aibridge/anthropic",
    },
    "openai": {
      "api_url": "https://coder.example.com/api/v2/aibridge/openai/v1",
    },
  },
  // optional settings to set favorite models for the AI
  "agent": {
    "favorite_models": [
      {
        "provider": "anthropic",
        "model": "claude-sonnet-4-5-thinking-latest"
      },
      {
        "provider": "openai",
        "model": "gpt-5.2-codex"
      }
    ],
  },
}
```

*Replace `coder.example.com` with your Coder deployment URL.*

> [!NOTE]
> These settings and environment variables need to be configured from client side. Zed currently does not support reading these settings from remote configuration. See this [feature request](https://github.com/zed-industries/zed/discussions/47058) for more details.

## Authentication

Zed requires an API key for these providers. For AI Gateway, this key is your **[Coder API token](https://coder.com/docs/admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)**.

You can set this in two ways:

<div class="tabs">

### Zed UI

1. Open the **Assistant Panel** (right sidebar).
1. Click **Configuration** or the settings icon.
1. Select your provider ("Anthropic" or "OpenAI").
1. Paste your **[Coder API token](https://coder.com/docs/admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)** for the API Key.

### Environment Variables

1. Set `ANTHROPIC_API_KEY` and `OPENAI_API_KEY` to your **[Coder API token](https://coder.com/docs/admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)** in the environment where you launch Zed.

</div>

## BYOK (Personal API Key)

> [!NOTE]
> At the time of writing, Zed Agent does not support sending custom headers, so BYOK mode is not available.

**References:** [Configuring Zed - Language Models](https://zed.dev/docs/reference/all-settings#language-models)
