# Zed

Use eWest models in Zed's agent panel as an OpenAI- or Anthropic-compatible provider.

Zed's agent panel can use any OpenAI-compatible or Anthropic-compatible endpoint as a language model provider. Add eWest as one, list the `ewest/*` models you want, and they appear in the model dropdown.

> We haven't tested this setup ourselves; it follows the tool's own documentation. If something doesn't work, contact support.

## Setup

Open the agent settings (command palette: `agent: open settings`) and use **Add Provider** under LLM Providers, or edit `settings.json` yourself. The OpenAI-compatible provider below sends chat completions to `https://api.ewest.ai/v1`. Zed only shows the models you list; `max_tokens` is the context window.

settings.json (OpenAI-compatible):

```json
{
  "language_models": {
    "openai_compatible": {
      "ewest": {
        "api_url": "https://api.ewest.ai/v1",
        "available_models": [
          {
            "name": "ewest/claude-sonnet",
            "display_name": "Claude Sonnet (eWest)",
            "max_tokens": 1000000,
            "max_output_tokens": 128000,
            "capabilities": { "tools": true, "images": true }
          },
          {
            "name": "ewest/claude-haiku",
            "display_name": "Claude Haiku (eWest)",
            "max_tokens": 200000,
            "max_output_tokens": 64000,
            "capabilities": { "tools": true, "images": true }
          },
          {
            "name": "ewest/gemini-flash",
            "display_name": "Gemini Flash (eWest)",
            "max_tokens": 1048576,
            "max_output_tokens": 65536,
            "capabilities": { "tools": true, "images": true }
          }
        ]
      }
    }
  }
}
```

The key: enter it in the provider's settings screen and Zed stores it in the system keychain, or set an environment variable named after the provider id in upper snake case plus `_API_KEY`. The provider here is `ewest`, so it is `EWEST_API_KEY`. A non-empty environment variable wins over the keychain. Never put the key in `settings.json`.

[Create an API key](https://ewest.ai/keys) and keep it in the `EWEST_KEY` environment variable (`export EWEST_KEY=sk-…`). Never commit it to a repository.

Shell:

```bash
# The provider id "ewest" becomes EWEST_API_KEY. Start Zed from this shell so it sees the variable.
export EWEST_API_KEY="$EWEST_KEY"
```

Claude models can also use Zed's Anthropic-compatible provider, which speaks the Messages API. Its base URL is `https://api.ewest.ai` without `/v1`. Prompt caching is off in the example; leave it off unless you have tested it.

settings.json (Anthropic-compatible):

```json
{
  "language_models": {
    "anthropic_compatible": {
      "ewest-claude": {
        "api_url": "https://api.ewest.ai",
        "available_models": [
          {
            "name": "ewest/claude-sonnet",
            "display_name": "Claude Sonnet (eWest, Messages)",
            "max_tokens": 1000000,
            "max_output_tokens": 128000,
            "capabilities": { "tools": true, "images": true, "prompt_caching": false }
          }
        ]
      }
    }
  }
}
```

Shell:

```bash
# The provider id "ewest-claude" becomes EWEST_CLAUDE_API_KEY.
export EWEST_CLAUDE_API_KEY="$EWEST_KEY"
```

## Choose a model

Use the full model ID, including the `ewest/` prefix: `ewest/claude-sonnet` for everyday coding, `ewest/claude-haiku` for fast and cheap work, `ewest/gemini-flash` when you need a very long context. [Models](https://ewest.ai/docs/models) lists every model with its context window and limits; `GET /v1/models` returns the models your key may use.

Each entry in `available_models` needs `name` (the full `ewest/` id), a `display_name` and `max_tokens`. Set `images` to `false` for a model without image input, and `tools` to `false` for one without tool calling; Zed's agent needs tools.

## Verify it works

Open the agent panel, pick the eWest model in the dropdown and send a short message. To rule out the key and model, send the same request without Zed:

cURL:

```bash
# The request Zed sends for a message, without Zed:
curl https://api.ewest.ai/v1/chat/completions \
  -H "Authorization: Bearer $EWEST_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "ewest/claude-haiku", "stream": true, "messages": [{"role": "user", "content": "Reply with the single word OK"}]}'
```

The request shows up in the console under **Requests** within a few seconds, with its tokens and cost. Every response carries an `x-request-id` header, its [trace ID](https://ewest.ai/docs/traces).

## Streaming and tools

Zed streams answers and runs the agent's tools (reading and editing files, terminal) through tool calling, which is on by default (`capabilities.tools`). All current `ewest/*` chat models support it.

## Troubleshooting

- **404 `model_not_found`:** the model name needs the `ewest/` prefix (`ewest/claude-sonnet`, not `claude-sonnet`). Check the spelling against [Models](https://ewest.ai/docs/models).
- **401, 402 or 403:** the key is missing or wrong, out of budget, or not allowed to use this model. [Errors](https://ewest.ai/docs/errors) explains each code; a [trace ID](https://ewest.ai/docs/traces) finds the request in the console.
- **Empty answer from `ewest/gemini-flash`:** `ewest/gemini-flash` does not think unless reasoning is on (low, medium or high); then thinking uses output tokens and a small output limit can be used up. Allow at least 256 output tokens in the editor's model settings, or turn reasoning off.
- **Zed says the provider has no key:** the variable must be named after the provider id (`EWEST_API_KEY` for `ewest`, `EWEST_CLAUDE_API_KEY` for `ewest-claude`), and Zed must be started from an environment that has it. Or enter the key in the provider settings.
- **404 on every request with the Anthropic-compatible provider:** its `api_url` must be `https://api.ewest.ai`, without `/v1`. For the OpenAI-compatible provider it must end in `/v1`.
- **A model doesn't appear:** it is not in `available_models`, or `settings.json` has a syntax error.
- **Responses-only setting:** eWest models work on chat completions, so leave `chat_completions` at its default (`true`).

List the models your key may use and copy the ids exactly:

cURL:

```bash
# The models your key may call (use these ids exactly, with the ewest/ prefix):
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/models

# One model, with its context window and whether it supports tools and images:
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/models/ewest/claude-haiku
```

Still stuck? Follow [Troubleshoot a request](https://ewest.ai/docs/troubleshooting).

Source: https://ewest.ai/docs/guides/zed
