Conceptual image of wiring OpenAI Codex CLI to any LLM with 50 lines of C#

Running OpenAI Codex CLI on Top of Claude, Gemini, or Llama — in 50 Lines of C#

OpenAI’s Codex CLI ships a great editor-agent UX — shell tools, apply_patch, plan tracking, all of it. The catch: as of February 2026, it only speaks the OpenAI Responses API. Chat Completion support was removed (the WireApi enum in codex-rs/model-provider-info/src/lib.rs now has only Responses), which leaves Chat-Completion-only endpoints — Ollama, LM Studio, your favourite Llama runner — locked out. This post walks through how I used .NET 10 file-based programs and the IChatClient abstraction from Microsoft.Extensions.AI to stand up a Responses-compatible server in a single 50-line C# file, with OpenRouter as the backend, so that Codex CLI can run on top of whichever model I feel like that day. ...

May 27, 2026 · 9 min ·  rkttu