Home / Learn / Wire Zed to Claude Through the Gateway
Wire Zed to Claude Through the Gateway — Zed Guide

Wire Zed to Claude Through the Gateway

Zed is fast and its assistant is genuinely useful, but the way it accepts a custom Claude endpoint is not where most people look first. The native Anthropic provider does not expose a base-URL override, so the clean path to the gateway runs through Zed's openai_compatible block instead.

Why not the Anthropic provider

Zed ships a native Anthropic provider, and the obvious instinct is to point it at the gateway. The catch is that this provider has no api_url setting, so there is no supported field where you can redirect it away from the default Anthropic host.

That single limitation is why so many people get stuck. Rather than fight it, you route Claude through the generic openai_compatible mechanism, which does expose the base URL and is built precisely for third-party endpoints.

It helps to think of the native provider as hard-wired to one destination and the openai_compatible provider as the configurable one. For a multi-model gateway the configurable path is what you want anyway, because the same block can front Claude and any other model the gateway serves through a single api_url. That keeps the editor's whole model story in one place rather than split across two provider mechanisms with different rules. That single decision shapes the rest of the setup, so it is worth getting clear before you edit anything. Once you accept that the openai_compatible block is the supported path, the rest is just filling in fields.

Add an openai_compatible block

In settings.json, under language_models.openai_compatible, add a named provider. Set its api_url to the gateway with /v1 on the end; Zed targets /chat/completions beneath that, so the gateway's OpenAI-compatible surface is what answers.

The name you choose is arbitrary and becomes the label in Zed's model menu. One block can serve several Claude models, each declared in the next step.

The /v1 suffix is load-bearing here: Zed builds the chat-completions path directly under whatever you give as api_url, so a missing /v1 sends requests to the wrong place and a trailing slash can double the path. Set it to the host plus /v1 exactly and the routing falls into place. A quick reload of settings after the edit confirms Zed has parsed the block without complaint. If the provider fails to appear, a JSON syntax slip in the block is the first thing to check.

Declare available_models

Zed does not auto-discover models on a custom endpoint, so list them by hand in available_models. Each entry needs a name matching the gateway id, a display_name for the menu, and a max_tokens value sized to the model.

Use claude-sonnet-4-5 for routine assistance and add claude-opus-4-8 as a second entry for the hardest tasks. Because you are listing them explicitly, the menu shows exactly the set you intend and nothing else.

The name field must match the gateway's id character for character, while display_name is purely cosmetic and can read however you like in the menu. Getting the name wrong is the usual cause of a model that shows up but errors on use, so copy the id straight from the gateway rather than typing it from memory. Listing only the models you actually use keeps the menu short and the choice obvious in daily work. Adding a model later is a one-line edit, so there is no need to declare everything up front.

Where the key lives

The API key does not go in settings.json. Zed stores it in the OS keychain or reads it from an environment variable named after the provider, such as AIPRIME_API_KEY, which keeps the secret out of your synced config.

After saving, open the assistant, pick your provider from the menu, and enter the key when prompted. From then on Zed authenticates from the keychain and your settings file stays free of credentials.

This separation is genuinely useful if you sync your Zed settings across machines or check them into a dotfiles repo: the config can travel freely because it holds no secret, and each machine supplies its own key through the keychain or environment. It is a cleaner story than tools that bake the key into the config file. This is also why sharing a Zed config with a colleague is safe — they bring their own key and yours never travels. The same applies to committing settings to a dotfiles repository.

The native route via ACP

If you specifically want native Anthropic behaviour rather than the OpenAI-compatible surface, Zed supports the Agent Client Protocol with Claude Code. You run Claude Code as the agent and Zed talks to it over ACP.

In that arrangement Claude Code carries its own ANTHROPIC_BASE_URL pointed at the gateway, so Zed never needs an Anthropic api_url of its own. It is the cleanest way to get true native Messages behaviour inside the editor.

The trade-off is that ACP gives you Claude Code's full agentic loop rather than Zed's lighter built-in assistant, which is more capable but also a heavier experience. Choose the openai_compatible route for quick inline help and the ACP route when you want a full agent driving multi-step edits from inside the editor. Most people start on the lighter route and only adopt ACP once they want a full agent in the editor. You can keep both available and reach for whichever the task calls for.

// Zed settings.json
{
  "language_models": {
    "openai_compatible": {
      "aiprime": {
        "api_url": "https://aiprimetech.io/v1",
        "available_models": [
          { "name": "claude-sonnet-4-5",
            "display_name": "Claude Sonnet",
            "max_tokens": 200000 }
        ]
      }
    }
  }
}
// Key goes in the keychain / AIPRIME_API_KEY env var, NOT this file.

Frequently asked questions

Why can't I set a Claude base URL in Zed?
Zed's native Anthropic provider has no api_url field. Use the openai_compatible block, which exposes api_url, and point it at {SITE}/v1.

Where do I put the api_url?
Under language_models.openai_compatible.<name>.api_url, ending in /v1. Zed targets /chat/completions beneath it.

Where does the API key go?
Not in settings.json — Zed keeps it in the OS keychain or an env var named after the provider, such as AIPRIME_API_KEY.

How do I get native Anthropic behaviour?
Use ACP with Claude Code as the agent; Claude Code carries ANTHROPIC_BASE_URL to the gateway, so Zed needs no Anthropic api_url.

Start using Claude in minutes

Get an API key — no Anthropic account or waitlist required.

Get your API key

AI Prime Tech is an independent API gateway. It is not affiliated with, endorsed by, or a reseller of Anthropic. Claude and related model names are trademarks of their respective owners.