Unable to use Vercel AI Gateway with Codex CLI (429 too many requests)

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 425ms

Steps 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 fine
name = "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 fine
name = "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 work
name = "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.

It looks like it’s retrying repeatedly and then gets rate limited with that 429 response. First thing I’d check is that you have VERCEL_AI_GATEWAY_API_KEY configured correctly. You could also try changing wire_api = "chat" to wire_api = "responses" in your AI Gateway config, since that’s what works for your other providers.

Please give that a try and let me know how it goes

Hey @amyegan .

  1. For the wire_api config, Vercel AI Gateway doesn’t actually support the responses API, so I can’t use that config
  2. Yes the API key variable is definitely defined

Again, Vercel gateway is not completely dead, it does respond, but it also returns a lot of 429s, which is very weird.

See this example below, some responses are coming back, but you can see a lot of 429s too.

I found these issues related to the 429 status code you’re seeing with Codex:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.