# Use Xantly with Zed

[Zed](https://zed.dev) is the high-performance Rust-native editor from the Atom team. Its assistant panel supports an `openai_compatible` provider block, drop in Xantly and every inline chat, edit, and inline assistant call routes through smart routing + cache + memory.

## Prerequisites

- Zed installed, download from [zed.dev](https://zed.dev)
- A Xantly API key, [create one](/dashboard/api-keys)

## Setup

Open your Zed settings (`Cmd+,` on macOS, `Ctrl+,` on Linux) and add an `openai_compatible` provider under `language_models`:

```jsonc
{
  "language_models": {
    "openai_compatible": {
      "Xantly": {
        "api_url": "https://api.xantly.com/v1",
        "available_models": [
          {
            "name": "xantly/auto-quality",
            "display_name": "Xantly Quality",
            "max_tokens": 200000,
            "max_completion_tokens": 8192
          },
          {
            "name": "xantly/auto-value",
            "display_name": "Xantly Value",
            "max_tokens": 128000,
            "max_completion_tokens": 4096
          },
          {
            "name": "anthropic/claude-sonnet-4.6",
            "display_name": "Claude Sonnet 4.6",
            "max_tokens": 200000,
            "max_completion_tokens": 8192
          },
          {
            "name": "openai/gpt-5.4",
            "display_name": "GPT-5.4",
            "max_tokens": 200000,
            "max_completion_tokens": 8192
          }
        ]
      }
    }
  },
  "assistant": {
    "default_model": {
      "provider": "openai_compatible/Xantly",
      "model": "xantly/auto-quality"
    }
  }
}
```

Set your API key via the Zed UI (`Cmd+Shift+P` → "Assistant: Configure Provider" → paste `xantly_sk_...`) or export it:

```bash
export OPENAI_COMPATIBLE_XANTLY_API_KEY=xantly_sk_...
```

Restart Zed. The model picker in the Assistant panel now shows Xantly models.

## Using the Assistant panel

- `Cmd+R`: Open the Assistant panel.
- `Cmd+Enter`: Send prompt.
- Select code + `Cmd+Enter`: Inline assist on the selection.
- `/` commands: `/edit`, `/file`, `/tab` to reference context.

Everything streams through Xantly, routed model, cache status, and cost all appear in your Xantly dashboard.

## Inline assistant (edit in place)

Select a block of code, press `Cmd+Enter`, and describe the change:

```
Convert this function to async/await and add error handling.
```

Zed's inline assistant fires an edit request against Xantly's `auto-quality` (via the default_model setting), applies the diff, shows you the preview.

## Model choice

| Model ID | When |
|---|---|
| `xantly/auto-quality` | Assistant panel default, most reliable. |
| `xantly/auto-value` | Higher-volume edit/refactor work. |
| `anthropic/claude-sonnet-4.6` | Long-context refactors, multi-file reasoning. |
| `openai/gpt-5.4` | Structured output (schemas, configs). |
| `groq/llama-3.3-70b` | Ultra-fast inline completions. |

## Verify

In the Assistant panel:

```
Reply with just the word "pong".
```

Check your Xantly dashboard, the request logs with routed-to model, cache status, USD cost.

## What you get

- **Fast editor + smart routing.** Zed is the fastest mainstream editor; Xantly adds smart routing without slowing it down (12ms p50 overhead).
- **Semantic cache.** Inline refactors often re-ask similar prompts, cache returns instantly.
- **Waterfall fallback.** Mid-edit provider outages don't kill the inline assist.
- **Memory.** Set `X-Xantly-Memory-Mode: recall` via... (see below) to opt in.
- **Cost per edit** tracked in your dashboard.

## Gotchas

**`api_url` with `/v1`.** Zed's `openai_compatible` provider expects the path-less OpenAI-compatible base. Include `/v1`.

**`available_models` is required.** Zed doesn't hit `/v1/models` to discover the catalog, you list what you want available in the settings. Add whatever Xantly slugs you use.

**Custom headers.** Zed doesn't yet expose a custom-headers setting on the `openai_compatible` provider, so `X-Xantly-Memory-Mode` can't be set per-call from Zed natively. Workaround: use a CLI tool for memory-heavy workflows, or wait for upstream Zed support.

**Max tokens.** `max_tokens` in Zed config is the **context window**; `max_completion_tokens` is the generation limit. Set both to match the model.

**Model picker caches.** After adding new entries, restart Zed, it doesn't hot-reload the models list.

## Next steps

- [OpenAI SDK (Python)](/docs/use-with-openai-sdk-python), for Zed extension authors building custom LLM features.
- [Cline](/docs/use-with-cline), VS Code equivalent with more extensive agent features.
- [Continue.dev](/docs/use-with-continue-dev), also supports Zed.
- [Bring Your Own Key](/docs/bring-your-own-key), route Zed through your own OpenAI/Anthropic credits via Xantly.
