How to use GPT-5.1 Codex in Windsurf
Windsurf is a fast, agentic IDE — but its built-in model menu does not always expose the exact model you want, and provider quotas can box you in. The good news: Windsurf speaks the OpenAI-compatible protocol, so you can point it at GPT-5.1 Codex (and a dozen other models) through a single gateway. This guide shows you how.
Why route Windsurf through a gateway
GPT-5.1 Codex is tuned for code: long-horizon refactors, multi-file edits, and agentic tool use. Instead of juggling separate provider accounts, you can reach it through AnyModel, one OpenAI-compatible endpoint where a single API key unlocks GPT, Claude, Gemini, DeepSeek, GLM, Kimi, Qwen, and Grok. Switching models means changing one string — the model id — and nothing else.
That matters in Windsurf specifically. Once the endpoint is configured, you can A/B a tricky bug fix across GPT-5.1 Codex and, say, Claude or DeepSeek without re-authenticating. If you are unsure which to use, the model comparison page lays out the trade-offs.
Step 1: Get an API key
Create an account and grab a key. You start with 1,000,000 free tokens — no credit card — and reach a total of 6,000,000 if you link Telegram. After that it is pay-per-token: no subscription, no minimums.
You can register here and copy your key from the dashboard.
Step 2: Configure Windsurf
Windsurf does not use AnyModel's one-line installer (that shortcut is reserved for codex, claude, opencode, and hermes). Instead, use Windsurf's manual OpenAI-compatible provider settings:
- Open Windsurf → Settings → Cascade / Model Providers.
- Add a custom OpenAI-compatible provider.
- Set the fields:
| Field | Value |
|---|---|
| Base URL | https://anymodel.org/v1 |
| API Key | your AnyModel key |
| Model | gpt-5.1-codex |
- Save, then select the new model in Cascade's model picker.
That is the whole setup. Because the base URL ends in /v1, Windsurf appends the standard /chat/completions path automatically.
Step 3: Verify it works
Before trusting the IDE, confirm the endpoint and key respond. Run this from a terminal — it is the same protocol Windsurf uses under the hood:
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 one-liner to reverse a string."}]
}'
A clean JSON response with a choices array means your key and base URL are correct. If you get a 401, re-check the key; a 404 usually means a stray path was added after /v1.
Using GPT-5.1 Codex effectively in Cascade
A few habits get the most out of it:
- Let it read context. Codex models reason better with the relevant files open or referenced. Use Cascade's @-mentions to pin files rather than pasting snippets.
- Be explicit about scope. "Refactor
auth.tsto use the new token helper, keep the public API identical" beats "clean up auth." - Switch models per task. Keep GPT-5.1 Codex for heavy code generation, then flip the
modelid to a cheaper option for quick edits or commit messages. No re-config needed. - Watch your tokens. Large repos burn context fast. The dashboard shows usage so you can pace your free allowance.
A note on privacy
By default, requests pass through AnyModel and on to the model provider. If you do not want prompts and responses retained on our side, enable Ghost Mode — opt-in, zero-retention keys where we keep only a token counter. To be clear, the model provider still receives your prompt, so this is not "100% privacy" — it removes our copy, not theirs. For proprietary code, that distinction is worth understanding before you send a whole repo.
Wrapping up
Pointing Windsurf at GPT-5.1 Codex takes three things: a base URL, a key, and a model id. From there you have one account that reaches every major model, with model-switching reduced to editing a single field. For more setup walkthroughs across other editors, browse the blog.
Ready to try it? Create your free account, claim your starter tokens, and have GPT-5.1 Codex running in Windsurf in under five minutes.
AnyModel