Zed
Zed reaches LunaRoute through its OpenAI-compatible provider
(language_models.openai_compatible). lunaroute setup zed merges one entry — lunaroute, with the
gateway URL and your catalog’s models — into ~/.config/zed/settings.json.
The provider id is load-bearing: Zed derives the API-key variable from it as UPPER_SNAKE(id) +
_API_KEY, so lunaroute means it reads LUNAROUTE_API_KEY from the environment at launch and
sends it as Authorization: Bearer. That is why no key goes in the file.
1. Merge the provider
Section titled “1. Merge the provider”npx @lunaroute/cli setup zedMerge, do not replace. Your settings.json also holds your theme, keymap and any other language
models; the CLI keeps all of it, backs the file up, and writes only
language_models.openai_compatible.lunaroute:
{ "language_models": { "openai_compatible": { "lunaroute": { "api_url": "https://gw.lunaroute.com/v1", "available_models": [ { "name": "<model-id>", "display_name": "<label>", "max_tokens": 200000, "max_output_tokens": 8192, "capabilities": { "tools": true, "images": false, "parallel_tool_calls": false, "prompt_cache_key": false, "chat_completions": true, "interleaved_reasoning": false, "max_tokens_parameter": false } } ] } } }}Zed requires max_tokens (the context window) on every model, so setup writes only catalog entries that
carry a context window — and refuses outright, rather than write a provider that offers nothing to
pick, when none do. Models are written from the live catalog at setup time, so re-run the command when
you want a newly enabled model to appear.
On Windows the file is %APPDATA%\Zed\settings.json; the CLI resolves the right path for your channel
including the Flatpak location on Linux.
2. Supply the key
Section titled “2. Supply the key”Two ways, and the first one wins when both are set:
- Environment — the
export LUNAROUTE_API_KEY=lr_…line setup printed, in your shell profile. Zed imports your login shell’s variables at startup, so a desktop-launched Zed picks it up too. - Zed’s keychain — Settings → AI → General → LLM Providers → Configure → find
lunaroute→ Configure → paste the key. It is stored in the OS keychain; the environment variable takes precedence over it.
To inject the key for one launch instead, lunaroute setup zed once and then:
npx @lunaroute/cli run zedrun zed only adds LUNAROUTE_API_KEY to Zed’s environment — the provider block still comes from
settings.json, and it says so if it finds none. Quit a running Zed first: the variable reaches a
new process, not the one already open.
3. Pick a model
Section titled “3. Pick a model”Restart Zed and choose a LunaRoute model in the agent panel. Zed initializes LLM providers in the local
app, so remote (SSH) projects use this same settings.json.
4. Undo
Section titled “4. Undo”Delete the lunaroute entry from language_models.openai_compatible in your settings.json (setup
kept your previous file at settings.json.bak), restart Zed, and remove the key from wherever you
supplied it — the LUNAROUTE_API_KEY line in your shell profile, or the keychain entry under
Settings → AI. Zed
has no --remove reverse; deleting the block is the whole undo.
Verify
Section titled “Verify”curl https://gw.lunaroute.com/v1/models \ -H "Authorization: Bearer $LUNAROUTE_API_KEY"Related
Section titled “Related”- CLI — install,
run,setup, and the Windows/WSL notes. - Harness setup — the other harnesses, and the MCP server.
- VS Code — the other IDE.