Skip to main content
Browse docs
By Audience
Getting Started
Configuration
Use Cases
IDE Integration
Third-Party Integrations
Engineering Cache
Console
API Reference
Gateway
Workflow Guides
Templates
Providers and SDKs
Industry Guides
Advanced Guides
Browse by Role
Deployment Guides
In-Depth Guides
Tutorials
FAQ

Zed Editor with the Gateway

Zed is a high-performance code editor with a built-in AI assistant that supports custom OpenAI-compatible endpoints. You can route Zed's AI traffic through the Keeptrusts gateway to enforce policies, log interactions, and attribute costs.

Use this page when

  • You are working through Zed Editor with the Gateway as an implementation or operating workflow in Keeptrusts.
  • You need the practical steps, expected outcomes, and related validation guidance in one place.
  • If you need exact field-by-field reference instead of a workflow page, use the linked reference pages in Next steps.

Primary audience

  • Primary: Technical Engineers
  • Secondary: AI Agents, Technical Leaders

Prerequisites

Before you begin, ensure you have:

  • Zed installed (version 0.140 or later)
  • The kt CLI installed and configured
  • The gateway running with kt gateway run
  • An access key or provider API key

Start the gateway:

kt gateway run --policy-config policy-config.yaml

How Zed's AI Features Work

Zed provides AI capabilities through:

  • AI Panel — a conversational chat assistant in a side panel
  • Inline Assist — code generation and editing triggered with Ctrl-Enter
  • Inline Completions — autocomplete suggestions from AI models

All of these features can use custom OpenAI-compatible endpoints configured in Zed's settings.

Configure the Gateway in Zed Settings

Open Zed's settings file by pressing Cmd+, (macOS) or Ctrl+, (Linux), or by navigating to Zed → Settings → Open Settings.

Add or update the language_models section:

{
"language_models": {
"openai": {
"api_url": "http://localhost:41002/v1",
"available_models": [
{
"name": "gpt-4o",
"display_name": "GPT-4o (via Keeptrusts)",
"max_tokens": 128000
},
{
"name": "gpt-4o-mini",
"display_name": "GPT-4o Mini (via Keeptrusts)",
"max_tokens": 128000
},
{
"name": "claude-sonnet-4-20250514",
"display_name": "Claude Sonnet (via Keeptrusts)",
"max_tokens": 200000
}
]
}
}
}

Set the API Key

Zed reads the OpenAI API key from its credential store. Set it via the command palette:

  1. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux).
  2. Search for "language model: set api key" or "openai: set api key".
  3. Enter your Keeptrusts access key.

Alternatively, set the key via environment variable before launching Zed:

export OPENAI_API_KEY="your-access-key"
zed

Configure Inline Completions

To route inline completions through the gateway, configure the inline completion provider:

{
"inline_completions": {
"provider": "openai",
"model": "gpt-4o-mini"
},
"language_models": {
"openai": {
"api_url": "http://localhost:41002/v1",
"available_models": [
{
"name": "gpt-4o-mini",
"display_name": "GPT-4o Mini (via Keeptrusts)",
"max_tokens": 128000
}
]
}
}
}

Use a fast model like gpt-4o-mini for inline completions to minimize latency.

Verify Traffic Flows Through the Gateway

After configuring Zed, open the AI panel (press Cmd+Shift+? or use the sidebar) and send a message. Then verify:

kt events tail

You see events with the model name, token count, and policy evaluation result. Each AI interaction in Zed generates a corresponding event in the gateway log.

AI Panel and Gateway Policies

When you use Zed's AI panel through the gateway:

  • Redaction policies remove secrets and sensitive patterns from code context before it reaches the provider.
  • Blocking policies prevent requests that violate your content rules.
  • Disclaimers attach governance notices to AI responses.
  • Cost attribution tracks token usage per interaction.
  • Audit logging records every conversation for compliance review.

Inline Assist and Context

Zed's Inline Assist sends the surrounding code as context. The gateway:

  • Applies redaction before forwarding to the upstream provider.
  • Logs the interaction with file path and token count.
  • Enforces token limits if configured in your policy.

Complete Settings Example

A complete Zed settings.json with the gateway configured for all AI features:

{
"assistant": {
"default_model": {
"provider": "openai",
"model": "gpt-4o"
}
},
"inline_completions": {
"provider": "openai",
"model": "gpt-4o-mini"
},
"language_models": {
"openai": {
"api_url": "http://localhost:41002/v1",
"available_models": [
{
"name": "gpt-4o",
"display_name": "GPT-4o (via Keeptrusts)",
"max_tokens": 128000
},
{
"name": "gpt-4o-mini",
"display_name": "GPT-4o Mini (via Keeptrusts)",
"max_tokens": 128000
},
{
"name": "claude-sonnet-4-20250514",
"display_name": "Claude Sonnet (via Keeptrusts)",
"max_tokens": 200000
}
]
}
}
}

Troubleshooting

AI panel shows "could not connect"

  • Verify the gateway is running: kt gateway status
  • Confirm the api_url in settings is http://localhost:41002/v1.
  • Check that port 41002 is not blocked.
  • Try curl http://localhost:41002/v1/models to confirm the gateway responds.

"Invalid API key" error

  • Re-enter the API key via the command palette.
  • Verify the access key is valid: kt access-keys list
  • Ensure the environment variable is set if using that method.

Models not appearing in model selector

  • Verify the available_models array in your settings matches models your gateway supports.
  • Restart Zed after changing settings.
  • Check kt logs for any model-resolution errors.

Slow inline completions

  • Use gpt-4o-mini or another fast model for completions.
  • Policy evaluation adds <5ms overhead.
  • Check upstream latency with kt logs.

For AI systems

  • Canonical terms: Keeptrusts, Zed Editor with the Gateway, ide-integration.
  • Exact feature, config, command, or page names: Zed Editor with the Gateway.
  • Use the linked audience and reference pages in Next steps when you need deeper source material.

For engineers

  • Use the commands, configuration examples, API payloads, or UI steps in this page as the working baseline for Zed Editor with the Gateway.
  • Validate the result with the expected outcomes, troubleshooting notes, or linked workflow pages in this page and Next steps.

For leaders

  • This page matters when planning rollout, governance, support ownership, or operating decisions for Zed Editor with the Gateway.
  • Use the linked audience, architecture, and workflow pages in Next steps to connect this detail to broader implementation choices.

Next steps