# Zed

> Add Deference to Zed as an OpenAI-compatible language model provider.

Zed reads OpenAI-compatible providers from `language_models.openai_compatible` in `settings.json`. It speaks Chat Completions, so the base URL is `https://deference.si/v1`.

## Set up

1. Create a key in [API keys](https://deference.si/keys).
2. Open the settings file with the command palette action `zed: open settings file`. It lives at `~/.config/zed/settings.json` on macOS and Linux, and at `%APPDATA%\Zed\settings.json` on Windows.
3. Add the provider.

```json
{
  "language_models": {
    "openai_compatible": {
      "Deference": {
        "api_url": "https://deference.si/v1",
        "available_models": [
          {
            "name": "anthropic/claude-sonnet-5.5",
            "display_name": "Claude Sonnet 5.5",
            "max_tokens": 200000,
            "max_output_tokens": 64000,
            "capabilities": {
              "tools": true,
              "images": true,
              "parallel_tool_calls": false,
              "prompt_cache_key": false
            }
          }
        ]
      }
    }
  }
}
```

4. Open the Agent panel's settings, find **Deference** and paste your key. Zed keeps it in your system keychain. The key never goes in `settings.json`.

`max_tokens` is the context window Zed plans for and `max_output_tokens` is the reply limit. Use the limits on the model's page on [Models](https://deference.si/models) or lower ones. Lower values make Zed summarize earlier and spend less.

To use an environment variable instead of the keychain, export `DEFERENCE_API_KEY` and start Zed from that shell, for example with `zed .`. The variable name is the provider name in capitals plus `_API_KEY`. An app launched from the Dock or Start menu does not see your shell exports.

## Verify

Open the Agent panel, pick the model under **Deference** and send a message. A streamed reply means the connection works. Then open [Activity](https://deference.si/activity): the request is the top row, with the model you chose.

## Pick a model

* Add one entry to `available_models` for each model you want. `name` is the exact model id.
* `tools` is on by default. Set it to `false` for models that do not list `tools` as a supported parameter.
* Add `"chat_completions": false` to a model's `capabilities` to send it to `POST /v1/responses` instead.
* Zed's edit predictions need `POST /v1/completions`, which Deference does not serve.

## Troubleshooting

| You see                              | Cause                                                      | Fix                                                                  |
| ------------------------------------ | ---------------------------------------------------------- | -------------------------------------------------------------------- |
| The model is missing from the picker | The provider block is not valid JSON, or `name` has a typo | Fix the file, then copy the id from the Models page                  |
| Zed asks for the key every time      | The keychain write failed                                  | Export `DEFERENCE_API_KEY` and start Zed from that shell             |
| `401 invalid_api_key`                | An old key is stored                                       | Remove the stored key in the provider settings and enter the new one |
| `404 model_not_found`                | `name` differs from the catalog id                         | Copy the id from the Models page                                     |
| Tool calls fail                      | The model does not support tools                           | Set `"tools": false` for it                                          |
| `402 insufficient_credit`            | No available credit                                        | [Add credit](https://deference.si/wallet?tab=add)                                        |
