Zed Editor Custom API Setup

Add TokenHub as a Zed Editor OpenAI-compatible provider and test it with a safe AI request.

What is Zed Editor?

Zed Editor is a high-performance, collaborative code editor with built-in AI features and configurable language-model providers.

This Zed Editor setup adds a named OpenAI-compatible provider in settings, keeps its API key out of settings.json, and uses model limits that match the selected TokenHub model. Zed separates provider declarations in settings.json from credentials stored in its provider UI or environment. The provider ID determines the generated key variable, and each available model should use its real context limit. Test Inline Assistant first, then validate Agent tools separately because basic generation does not prove tool compatibility.

Zed supports both its Agent Settings UI and settings.json for OpenAI-compatible endpoints. Let Zed store the TokenHub API key in the system keychain, or supply it through the environment variable derived from the provider name. Do not place the key in settings.json.

Add a provider in Agent Settings

  1. Open the command palette and run agent: open settings.
  2. Go to Settings → AI → LLM Providers.
  3. Click Add Provider and choose an OpenAI-compatible provider.
  4. Enter tokenhub as the provider name.
  5. Enter https://us-api.tokenhub.com/v1 as the API URL.
  6. Enter the exact model ID shown in the TokenHub model catalog.
  7. Enter that model's real context window.
  8. Enter your TokenHub API key in the provider settings so Zed stores it in the system keychain.

Edit settings.json when you need multiple models

Zed supports providers under language_models.openai_compatible. In this schema, max_tokens means the context window, not maximum output. Replace both limits with the values documented for your model:

{
  "language_models": {
    "openai_compatible": {
      "tokenhub": {
        "api_url": "__API_BASE_URL__/v1",
        "available_models": [
          {
            "name": "YOUR_TOKENHUB_MODEL_ID",
            "display_name": "TokenHub / YOUR_TOKENHUB_MODEL_ID",
            "max_tokens": 128000,
            "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
            }
          }
        ]
      }
    }
  }
}

If capabilities is omitted, Zed uses the OpenAI-compatible defaults shown above. Set images, parallel_tool_calls, or another capability to true only when both the model and the TokenHub endpoint actually support it.

Follow Zed's API-key lookup rule

Zed converts the provider ID to uppercase snake case and appends _API_KEY. The provider ID tokenhub therefore maps to:

export TOKENHUB_API_KEY="sk-..."

A non-empty environment variable takes precedence over the keychain. If you updated the key in the UI but Zed still sends an old credential, unset this variable and restart Zed.

Do not infer Reasoning or Responses support from a model name

  • When a TokenHub model supports OpenAI-style reasoning_effort, set only a value the endpoint accepts. Zed exposes none, minimal, low, medium, high, xhigh, and max, but a third-party endpoint may support fewer values.
  • TokenHub currently recommends Chat Completions for this connection, so keep capabilities.chat_completions: true.
  • Change it to false only for a model that requires the Responses API. Do not switch APIs merely to enable reasoning.
  • Set max_tokens_parameter: true only when the endpoint requires max_tokens instead of max_completion_tokens.

Verify inside Zed

Select TokenHub / YOUR_TOKENHUB_MODEL_ID in Agent or Inline Assistant and ask it to explain the current file. If the model is absent, check the JSON, provider ID, and available_models. For a 401, check the TOKENHUB_API_KEY visible to the Zed process. If tools or images fail, return to capabilities and make sure the declaration does not exceed the model's real support.

Official reference

Choose a compatible Zed Editor model

WorkloadModel choiceWhy it fits
Complex coding tasksA tool-capable reasoning modelUse a model with reliable tool use, streaming, and the context length your workflow needs.
Daily implementationA balanced coding modelPrioritize reliable edits and useful latency for normal coding loops.
Background and subagent workA fast, lower-cost modelUse this for iterations, summaries, and simpler work only after validating tool use.
Browse TokenHub models and compatibility

Zed Editor AI provider FAQ

Where should the TokenHub API key go in Zed?

Use the LLM Provider settings or the TOKENHUB_API_KEY environment variable. Do not save a plaintext key in settings.json.

Why is the model missing from the selector?

Confirm the provider ID, API URL, and available_models entry, then restart Zed after changing settings or environment variables.

What should max_tokens contain?

Use the actual context window for the selected TokenHub model, not a value copied from a different model.

Does Inline Assistant success prove Zed Agent compatibility?

No. Inline Assistant verifies basic generation; Agent workflows can require structured tool calls and additional permissions. Test those capabilities separately.

How do I verify Zed is using the TokenHub model?

Select the declared model, run a read-only AI request, and confirm the exact model ID in TokenHub request logs.

References

This setup is based on TokenHub and official documentation, last verified on 2026-09-08.