zed2api exposes the LLM access included with a Zed subscription through OpenAI- and Anthropic-compatible APIs. It ships as a single binary with an embedded web management interface and can run directly or in Docker.
- OpenAI-compatible endpoint:
POST /v1/chat/completions - Anthropic Messages endpoint:
POST /v1/messages - Model listing endpoint:
GET /v1/models - Multiple Zed accounts with automatic failover
- OpenAI- and Anthropic-compatible SSE streaming with correct finish reasons
- System prompt, tool call, and tool result conversion
- Anthropic, OpenAI, Google, and xAI models offered through Zed
- Extended thinking support
- Embedded WebUI for account and credential management
- HTTPS proxy support through environment variables and Windows proxy detection
- GitHub OAuth login with a pasted callback URL for remote Docker servers
- API and admin key rotation from the WebUI
- Usage links for both personal and organization Zed accounts
- Windows and Linux support
The available catalog is returned dynamically by GET /v1/models. Examples include:
| Provider | Models |
|---|---|
| Anthropic | claude-opus-4-6, claude-opus-4-5, claude-sonnet-5, claude-sonnet-4-6, claude-sonnet-4-5, claude-haiku-4-5, and others |
| OpenAI | gpt-5.2, gpt-5.1, gpt-5, gpt-5-mini, gpt-5-nano, and others |
gemini-3-pro-preview, gemini-2.5-pro, gemini-3-flash, and others |
|
| xAI | grok-4, grok-4-fast-reasoning, grok-code-fast-1, and others |
Model availability is controlled by Zed and may vary by account or subscription.
Building requires Zig 0.15.x and Node.js. zig build builds the WebUI and embeds it into the executable automatically.
# Install WebUI dependencies once
cd webui && npm install && cd ..
# Build for the current platform
zig build
# Cross-compile for Linux x86_64
zig build -Dtarget=x86_64-linux -Doptimize=ReleaseSafe# Add a Zed account with OAuth
./zed2api login [account-name]
# Alternatively, create accounts.json using accounts.example.json
# Start the server (default port: 8000)
./zed2api serve [port]
# List configured accounts
./zed2api accountsOpen http://127.0.0.1:8000 to access the WebUI.
The container listens on 0.0.0.0:8000. Inference endpoints require ZED2API_API_KEY; WebUI administration and login endpoints require ZED2API_ADMIN_KEY.
export ZED2API_API_KEY='replace-with-a-long-random-value'
export ZED2API_ADMIN_KEY='replace-with-another-long-random-value'
docker compose up -d --buildIf host port 8000 is unavailable, set another published port in .env:
ZED2API_PUBLISHED_PORT=8002The container continues to listen internally on port 8000. Open http://<docker-host>:<published-port> and unlock the Accounts page with the admin key.
The login workflow is designed to work without a browser inside the container:
- Select Add account in the WebUI and open the generated login page.
- Complete the GitHub/Zed login in your browser.
- The browser lands on an unreachable
http://127.0.0.1:<port>/...URL. - Copy the complete URL, paste it into the WebUI, and select Finish login.
The container processes the pasted callback URL to finish authentication. The callback port does not need to be exposed publicly.
Account data is stored at /data/accounts.json in the Docker volume. Keys can also be read from mounted files by setting ZED2API_API_KEY_FILE and ZED2API_ADMIN_KEY_FILE.
API and admin keys must contain at least seven characters. After unlocking the WebUI with the current admin key, use Update API keys to rotate either credential. Rotated keys are persisted in the Docker volume and take precedence over the original environment values after restart.
zed2api does not provide TLS. Use it only on a trusted network or terminate HTTPS with an external reverse proxy.
curl http://<docker-host>:8000/v1/models \
-H "Authorization: Bearer $ZED2API_API_KEY"/v1/chat/completions accepts OpenAI-compatible requests. Streaming responses use chat.completion.chunk; the final chunk includes finish_reason, followed by [DONE].
curl -N http://<docker-host>:8000/v1/chat/completions \
-H "Authorization: Bearer $ZED2API_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "Hello"}
],
"stream": true
}'OpenAI system messages are converted to Anthropic's top-level system instruction when using a Claude model. Streaming tool calls are exposed through choices[].delta.tool_calls and finish with finish_reason: "tool_calls". Tool results are converted to the format required by Zed. This supports agent clients that read files, load MEMORY.md, or invoke other tools.
OpenAI SDK-compatible environment variables:
export OPENAI_BASE_URL=http://<docker-host>:8000/v1
export OPENAI_API_KEY="$ZED2API_API_KEY"/v1/messages preserves Anthropic's native SSE event format, including message_start, content_block_delta, message_delta, and message_stop.
curl -N http://<docker-host>:8000/v1/messages \
-H "x-api-key: $ZED2API_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'Claude Code environment variables:
export ANTHROPIC_BASE_URL=http://<docker-host>:8000
export ANTHROPIC_AUTH_TOKEN="$ZED2API_API_KEY"
claudeConfigure an OpenAI-compatible provider with a base URL ending in /v1:
Base URL: https://your-zed2api-domain.example/v1
API key: <ZED2API_API_KEY>
Model: claude-sonnet-4-6
When using a reverse proxy, disable response buffering and allow long-lived connections so SSE chunks are delivered immediately. HTTPS in this example must be supplied by that external reverse proxy.
Set HTTPS_PROXY to route Zed upstream requests through a proxy. On Windows, zed2api can also detect the configured system proxy.
export HTTPS_PROXY=http://127.0.0.1:7890
./zed2api servesrc/
main.zig - CLI entry point and commands
server.zig - HTTP server, routing, and account APIs
stream.zig - SSE streaming proxy and protocol conversion
socket.zig - Cross-platform socket I/O (Windows ws2_32 / POSIX)
zed.zig - Token management, billing queries, and proxy orchestration
proxy.zig - HTTPS proxy detection and curl-based HTTP client
providers.zig - Provider request builders and response conversion
accounts.zig - Account management and JSON persistence
auth.zig - RSA keys, OAuth login, and browser launch
models.json - Embedded model catalog
webui/ - Vite + TypeScript WebUI embedded as a single HTML file
- Use separate, randomly generated API and admin keys.
- Do not expose the plain HTTP service directly to the public internet.
- Protect the WebUI and admin key separately from client API access.
- A Zed subscription and account remain subject to Zed's terms, limits, and model availability.