Problem Description
When using AI Gateway with OpenAI’s Codex CLI, I am unable to get the requests to consistently succeed. The config looks like it started to work, but then I immediately get hit by 429s. I can see my credits go down slightly, so I know that a few requests definitely worked.
See below what the output of codex looks like
╭────────────────────────────────────────────────────────╮│ >_ OpenAI Codex (v0.39.0) ││ ││ model: openai/gpt-5 /model to change ││ directory: ~/personal/arishi-monorepo │╰────────────────────────────────────────────────────────╯
To get started, describe a task or try one of these commands:
/init - create an AGENTS.md file with instructions for Codex /status - show current session configuration /approvals - choose what Codex can do without approval /model - choose what model and reasoning effort to use
▌ Explain what this repo does?
> I’ll scan the repo structure and README to summarize its purpose.
• Explored └ List ls -la Read README.md
⚠️ stream error: exceeded retry limit, last status: 429 Too Many Requests; retrying 1/5 in 180ms…
⚠️ stream error: exceeded retry limit, last status: 429 Too Many Requests; retrying 2/5 in 425msSteps to reproduce
Create the following config in ~/.codex/config.toml
model = "openai/gpt-5"model_provider = "vercel-ai-gateway"
[model_providers.openai] # this works just finename = "OpenAI"base_url = "https://api.openai.com/v1"env_key = "OPENAI_CODEX_API_KEY"wire_api = "responses"
[model_providers.cloudflare-ai-gateway] # This ALSO works just finename = "Cloudflare AI Gateway"base_url = "CF_AI_GATEWAY_URL (obfuscated for safety)"env_key = "OPENAI_CODEX_API_KEY"wire_api = "responses"
[model_providers.vercel-ai-gateway] # this does not workname = "Vercel AI Gateway"base_url = "https://ai-gateway.vercel.sh/v1"env_key = "VERCEL_AI_GATEWAY_API_KEY"wire_api = "chat"Then use OpenAIs Codex CLI on any project, and watch the 429s roll in.
