# Zed (/docs/guides/zed)

Use cheapaimodel models in the Zed Agent and other Zed AI features through an OpenAI-compatible provider.



Zed adds OpenAI-compatible services as providers under `language_models.openai_compatible` in `settings.json`. The provider then serves the Zed Agent, the Inline Assistant and Zed's other model-backed features.

|          | Zed setting                                                | Value                                                                             |
| -------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------- |
| Base URL | `api_url`                                                  | `https://api.cheapaimodel.ai/v1`                                                  |
| API key  | **LLM Providers** settings page, or `CHEAPAIMODEL_API_KEY` | Your key from the console's [API Keys](https://console.cheapaimodel.ai/keys) page |
| Model ID | `available_models[].name`                                  | `glm-5.3`, or any ID from the [catalog](/models)                                  |

## Set it up [#set-it-up]

<Steps>
  <Step>
    ### Add the provider [#add-the-provider]

    Run **zed: open settings file** from the command palette and add a provider:

    ```json title="~/.config/zed/settings.json"
    {
      "language_models": {
        "openai_compatible": {
          "cheapaimodel": {
            "api_url": "https://api.cheapaimodel.ai/v1",
            "available_models": [
              {
                "name": "glm-5.3",
                "display_name": "GLM-5.3",
                "max_tokens": CONTEXT_LENGTH
              }
            ]
          }
        }
      }
    }
    ```

    `max_tokens` is the model's context window. Replace `CONTEXT_LENGTH` with the context length on the model's page, for example [glm-5.3](/models/glm-5.3). Add one entry to `available_models` per model ID.
  </Step>

  <Step>
    ### Add your key [#add-your-key]

    Run **agent: open settings**, find **cheapaimodel** under **LLM Providers** and paste the key; Zed stores it in your system keychain. Alternatively set `CHEAPAIMODEL_API_KEY` in the environment Zed starts with and restart Zed.
  </Step>

  <Step>
    ### Pick the model [#pick-the-model]

    Open the Agent Panel and choose **GLM-5.3** under **cheapaimodel** in the model selector.
  </Step>
</Steps>

<Callout type="info">
  Edit predictions are configured separately. Zed's OpenAI-compatible edit prediction provider needs a `/v1/completions` endpoint and a fill-in-the-middle model; cheapaimodel's models serve only `/v1/chat/completions` and `/v1/responses`. Keep Zeta or another edit prediction provider.
</Callout>

## Common mistakes [#common-mistakes]

* **Zed says the provider has no API key.** Keys are not read from `settings.json`. Paste the key on the **LLM Providers** page or set the environment variable.
* **The environment variable is ignored, or an old key keeps being used.** Zed derives the variable's name from the provider ID: upper snake case plus `_API_KEY`. The ID `cheapaimodel` reads `CHEAPAIMODEL_API_KEY`; if you rename the provider, rename the variable to match. A non-empty variable takes precedence over the keychain; unset it and restart Zed to use the key you pasted.
* **`404` with the plain-text body `fault filter abort`.** `api_url` is missing `/v1`. Set `https://api.cheapaimodel.ai/v1`.
* **`404` with `Invalid URL (POST /v1/chat/completions/chat/completions)`.** `api_url` includes the endpoint path. Zed adds `/chat/completions` itself; set `https://api.cheapaimodel.ai/v1` only.
* **`503` with `model_not_found`.** `name` must be a model ID from the [catalog](/models), spelled exactly; `display_name` is only a label.
