Reverse engineering Codex CLI to get GPT-5-Codex-Mini to draw me a pelican

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

The undocumented Codex backend endpoint and its auth mechanism are now exposed, letting anyone with a ChatGPT account prompt restricted OpenAI models directly before public API access opens.

Read this as

OpenAI quietly launched a smaller, cheaper AI model called GPT-5-Codex-Mini, but only inside its own coding tool, Codex CLI, rather than letting anyone call it directly. Simon Willison, a well-known programmer, used the tool itself to write code that adds a new command to Codex CLI, letting him send his own prompts straight to the hidden model. He wrote none of the Rust programming language himself, instead instructing an AI agent to do it. The hack works, and he tested it by having the models draw pictures of pelicans.

OpenAI's new cost-efficient GPT-5-Codex-Mini is currently gated behind its Codex CLI coding agent, which uses an undocumented chatgpt.com backend API billed to ChatGPT accounts. Willison demonstrated that the open-source Apache 2.0 Codex CLI can be modified to expose this restricted endpoint directly, bypassing the intended access path ahead of the promised public API. The takeaway: 'exclusive' tool-gated model launches are only as secure as the open-source client that ships with them.

Willison forked openai/codex (rewritten in Rust a few months ago) and had Codex itself, running with --dangerously-bypass-approvals-and-sandbox, build the repo and add a 'codex prompt' subcommand modelled on his llm tool. It posts to https://chatgpt.com/backend-api/codex/responses using Codex's own auth; calls without Codex's expected instructions fail with 400 'Instructions are not valid', so the subcommand keeps workspace defaults but disables tools and apply_patch via config overrides. A --debug flag dumps the full JSON request/response. Qualitatively, gpt-5 produced the best SVG pelican; gpt-5-codex-mini produced a worse one than gpt-5-codex.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

GPT-5-Codex-Mini Codex CLI OpenAI Rust Simon Willison chatgpt.com backend API

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading