May 13, 20264 min readSetupGPT-5.1 CodexZed

How to use GPT-5.1 Codex in Zed

Zed is a fast, collaborative code editor with a built-in AI assistant and inline edits. It speaks the OpenAI Chat Completions format, which means you can point it at any compatible endpoint — including GPT-5.1 Codex through AnyModel. This guide walks through the full setup so you can run Codex-grade completions and agentic edits without juggling separate provider accounts.

Why route Zed through AnyModel

Zed lets you add custom OpenAI-compatible providers, but you still need an endpoint and a key. AnyModel gives you a single OpenAI-compatible endpoint — https://anymodel.org/v1 — where one API key reaches every model: GPT, Claude, Gemini, DeepSeek, GLM, Kimi, Qwen, and Grok. Switching models is just changing the model id; nothing else in your config moves.

That matters in Zed because you'll often want to A/B a refactor between GPT-5.1 Codex and, say, Claude or Gemini. With one base URL and one key, you flip the model name and keep working. Want a side-by-side on strengths and pricing first? See the model comparison.

You also start free: 1,000,000 tokens on signup, and a total of 6,000,000 tokens if you link Telegram — no credit card. After that it's pay-per-token: no subscription, no minimums.

Step 1: Get your API key

Create an account and copy your key from the dashboard. Keep it handy — Zed stores it locally in your settings.

Step 2: Add AnyModel as a provider in Zed

Zed configures AI through its settings.json. Open the command palette (Cmd-Shift-P / Ctrl-Shift-P), run zed: open settings, and add an OpenAI-compatible provider block:

{
  "language_models": {
    "openai_compatible": {
      "AnyModel": {
        "api_url": "https://anymodel.org/v1",
        "available_models": [
          {
            "name": "gpt-5.1-codex",
            "display_name": "GPT-5.1 Codex",
            "max_tokens": 256000
          }
        ]
      }
    }
  }
}

Then set the key. Zed will prompt for it in the Agent panel, or you can run agent: reset credentials and paste it when asked. The variable Zed expects for this provider is your AnyModel API key — the same one that reaches every other model.

Note: Zed's settings schema evolves between releases. If the key names differ in your version, search the in-app settings for "openai_compatible" or "custom" providers — the two values you always need are the base URL (https://anymodel.org/v1) and your API key.

Step 3: Select GPT-5.1 Codex and test

Open the Agent panel (the assistant sidebar), click the model picker, and choose GPT-5.1 Codex under the AnyModel provider. Ask it to explain a file or generate a function. To confirm the endpoint works outside the editor, you can hit it directly:

curl https://anymodel.org/v1/chat/completions \
  -H "Authorization: Bearer $ANYMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.1-codex","messages":[{"role":"user","content":"Write a Python function that reverses a linked list."}]}'

If that returns a completion, Zed will too.

Using it day to day

A few things that make Codex pull its weight in Zed:

  • Inline transformations. Select code, trigger an inline edit, and describe the change. Codex is strong at targeted refactors and adding tests.
  • Agent panel for multi-file work. Use the assistant for "explain this module" or "find where this state is set" across the project.
  • Model switching. If a task stalls, change gpt-5.1-codex to another id in your provider list and retry — same key, same endpoint.
Need Suggested approach
Quick rename/refactor Inline edit with Codex
Architecture questions Agent panel chat
Comparing two models Duplicate the model entry, swap the name

A note on privacy

By default, providers process your prompts. If you want zero-retention on AnyModel's side, enable Ghost Mode — opt-in keys where prompts and responses aren't stored by us (only a token counter runs). To be honest: the underlying model provider still receives your prompt, so this isn't "100% privacy" — it just removes our copy.

One-line installs for CLI tools

Zed needs the manual setup above, but if you also use a terminal coding agent like Codex CLI or Claude Code, AnyModel has a one-liner:

bash <(curl -fsSL "https://anymodel.org/i?tool=codex") <YOUR_API_KEY>

Swap tool=codex for tool=claude, opencode, or hermes. Other editors (Cursor, Windsurf, Cline, Aider, Continue) use the same manual base-URL-plus-key pattern as Zed. More walkthroughs live on the blog.

Ready to code with GPT-5.1 Codex in Zed? Create your free account and get a million tokens to start — no card required.

Read next