LLM API Guide

Fix "exceeded retry limit" 429 in sub2api, New API, and Cherry Studio

Fix "exceeded retry limit, last status: 429 Too Many Requests" in Codex, Cherry Studio, sub2api, and New API by tuning pool cooldowns, RPM/TPM caps, and concurrency.

Summary

  1. Why Codex throws "exceeded retry limit, last status: 429 Too Many Requests" even when 85%+ of your plan quota remains.
  2. How to stop 429 cascade storms in sub2api by enabling short backoff for frequency-type 429s and setting fallback cooldown minutes.
  3. How to prevent multi-key retry loops in New API and cut TPM/RPM spikes in Cherry Studio and Codex CLI.

When a coding session or chat stops with exceeded retry limit, last status: 429 Too Many Requests, your account has usually not run out of its monthly or weekly allowance. Instead, your client—or the relay gateway sitting in front of it—hit a short-window rate limit (RPM, TPM, or concurrent stream cap), and every retry attempt collided with that same HTTP 429 barrier.

If you route requests through sub2api or New API, or if you run heavy multi-turn tool calls in Codex and Cherry Studio, a single transient 429 can trigger a retry storm that locks up an entire account pool. Below is how I isolate which layer is generating the 429 and how to fix the configuration across your gateway and client.


On this page

What "exceeded retry limit, last status: 429 Too Many Requests" Really Means

When I first ran into this error in Codex while /status still showed 90% of my weekly allowance left, I checked how the client parses 429 responses in codex-api/src/api_bridge.rs and protocol/src/error.rs. The client does not treat every HTTP 429 the same way. It reads the response body first and branches into different messages depending on what the server returned.

Error Message Shown in Client What Triggered the 429 Where the Fix Lives
You've hit your usage limit... Your 5-hour or weekly subscription quota is exhausted. Wait for the reset timestamp or switch accounts.
Quota exceeded. Check your plan and billing details. Prepaid API credit balance hit $0 or an organization spend cap was reached. Top up the API billing balance or raise the monthly spend cap.
Selected model is at capacity. Please try a different model. Upstream compute cluster for that specific model (gpt-6.1-sol, etc.) is saturated. Switch models or check whether the capacity lock is server load or your account.
exceeded retry limit, last status: 429 Too Many Requests Short-window RPM/TPM burst limit, parallel subagent cap, or a relay gateway returning a generic 429. Lower client concurrency, fix sub2api pool cooldowns, or cap New API channel retries.

There is also a catch in the words "exceeded retry limit." In the Codex client, standard HTTP transport retries ignore 429 responses (retry_429: false). The client only waits and retries a 429 turn when the server includes a Retry-After header in the HTTP response.

When a Retry-After header is present, the client prints Reconnecting... 1/5 through 5/5, waiting the exact number of seconds requested by the server up to stream_max_retries times. When an upstream server or third-party gateway returns a bare 429 without a Retry-After header, the client does not retry at all—it aborts on the very first 429 in under half a second and still prints exceeded retry limit, last status: 429 Too Many Requests. Raising retry counters in your config file will not make a bare 429 retry even once.

Before changing any gateway or client settings, check the OpenAI Status page if you connect directly to OpenAI. During cluster degradations on models like gpt-6.1-sol, the upstream API frequently alternates between Selected model is at capacity and 429 responses with shared cooldown windows even when your account is idle. If upstream status is green—or if you route through your own relay—the bottleneck is in your gateway scheduling or client concurrency.


Fix 1: Stop Pool Freezes and 429 Cascade Storms in sub2api

If you run sub2api to pool subscriptions or Coding Plan accounts (such as OpenAI Plus/Pro, Zhipu GLM, Kimi, or DeepSeek), a single burst of requests from a coding agent can knock your entire account pool offline at once.

Why sub2api Pools Freeze on Frequency 429s

Upstream providers enforce two very different kinds of 429 errors: window quota exhaustion (you used 100% of your 5-hour or weekly quota) and momentary frequency throttling (you sent too many requests within a 10-second window, such as GLM returning error code 1302).

In older builds of sub2api, the rate-limit handler (ratelimit_cn_providers.go) did not distinguish between those two states on Coding Plan accounts. Whenever an account returned a 429, sub2api called SetRateLimited and froze that account until the next 5-hour or weekly reset window. I have seen accounts with only 7% of their quota used get locked out of rotation for 48 minutes because of a 3-second burst of parallel requests.

Once the first account is mistakenly frozen for nearly an hour, a 429 cascade storm starts. The sub2api scheduler shifts all incoming requests to the remaining accounts in the pool. Because the downstream client is still firing concurrent requests, the second and third accounts immediately hit their short-window frequency limits and get frozen until the window reset as well. Within half a minute, every account in the pool is either locked or sitting on the edge of a cooldown, and every client request terminates with exceeded retry limit, last status: 429 Too Many Requests.

How to Configure sub2api Cooldowns Properly

First, update your sub2api instance to a build that includes the short-backoff rate-limit logic (PR #7105 or later). With this update, sub2api checks the account's actual usage snapshot before deciding how long to cool it down. Only accounts with used_percent >= 95% are parked until the 5-hour or weekly reset window; accounts that hit a frequency-type 429 with plenty of quota left are given a short backoff measured in seconds to a couple of minutes so they return to the active pool almost immediately.

Second, open your sub2api Gateway Settings UI (or update it through the Admin Settings API) and configure the 429 cooldown controls (PR #1917):

json
{
  "enable_429_cooldown": true,
  "fallback_cooldown_minutes": 2
}

Enabling 429 cooldown tells sub2api to temporarily pull an account out of rotation the moment it returns a 429. Setting fallback_cooldown_minutes to 1 or 2 gives the gateway a sensible default pause when an upstream provider returns a 429 without a Retry-After header. Instead of forwarding the raw 429 to your client or locking the account for an hour, sub2api sidelines the throttled account for two minutes and dispatches the next request to a fresh account in the group.

Also verify that your sub2api groups aren't failing due to cross-protocol routing mistakes—if you mix Claude Code and Codex clients on the same relay, make sure you aren't hitting This group does not allow /v1/messages dispatch alongside your rate-limit errors.


Fix 2: Prevent Multi-Key Retry Storms and Set RPM/TPM Caps in New API

When New API sits between your clients and upstream API keys, 429 errors usually come from how New API selects keys inside a multi-key channel and how its internal retry loop interacts with client retries.

The Multi-Key Concurrency Blind Spot

When a request enters New API, SetupContextForSelectedChannel() in middleware/distributor.go calls channel.GetNextEnabledKey() to pick an API key from the chosen channel. That selector rotates keys by round-robin or random order, but it does not track how many active concurrent streams a specific key is handling right now.

If one key in a multi-key channel hits its upstream RPM, TPM, or concurrency ceiling and returns HTTP 429, controller/relay.go catches the error and triggers an internal retry. Because New API lacks a per-key concurrency circuit breaker (max_concurrency_per_key), those internal retries frequently land right back on the overloaded key—or slam the remaining keys in the same channel without any backoff delay.

When all internal retries fail, New API returns the 429 to Codex or Cherry Studio. The client then fires its own retry loop, multiplying the traffic hitting New API's endpoints until you trip New API's internal CriticalRateLimit middleware, which blocks requests at the gateway entrance and can even drop active web dashboard sessions.

Three Changes to Make in New API

Start by lowering the Channel Retry Count in your New API system settings to between 1 and 3. Many operators set channel retries to 10 thinking it will mask upstream instability. In reality, 10 internal retries multiplied by 5 client retries turns a single failed turn into 50 upstream hits, draining your RPM quota instantly. Keeping channel retries at 1 or 2 is enough to step over a single throttled channel without starting an internal loop. (If you leave retries high and the upstream stalls instead of returning a fast 429, your reverse proxy will time out first and throw stream disconnected before completion: Upstream request failed or stream closed before response.completed.)

Next, split multi-key channels into separate single-key channels within the same group. When you put ten API keys inside one channel, New API cannot isolate cooldowns per key smoothly under heavy concurrency. When each key lives in its own channel under the same group and priority weight, a 429 response temporarily cools down only the specific channel that threw the error, guaranteeing the next retry lands on a different key.

Finally, configure explicit RPM (Requests Per Minute) and TPM (Tokens Per Minute) limits in New API's Group Management or per-token settings. If your upstream tier allows 500 RPM and 800,000 TPM, setting a token-level cap at the gateway entrance shapes bursts before a single runaway script can exhaust the upstream quota for everyone else sharing that relay.


Fix 3: Lower Concurrency and TPM Spikes in Codex and Cherry Studio

Even a well-tuned gateway will return exceeded retry limit, last status: 429 Too Many Requests if your client fires parallel agent threads or sends massive context payloads every few seconds.

Capping Subagents and Retries in Codex (config.toml)

In Codex CLI and the IDE extension, every open chat tab, background code review, and spawned subagent counts toward your concurrent request limit. Opening three parallel sessions—or running a single prompt that spawns four subagents at once—routinely triggers 429s even when your account usage meter is barely touched.

You can cap how many subagents a single Codex session is allowed to run in parallel by editing your user-level ~/.codex/config.toml file (note that provider and agent settings must go in ~/.codex/config.toml; placing model_providers inside a project-local .codex/config.toml is ignored by the client):

toml
[agents]
max_concurrent_threads_per_session = 1

[model_providers.custom_gateway]
name = "My Relay Gateway"
base_url = "https://api.your-gateway.example.com/v1"
env_key = "OPENAI_API_KEY"
request_max_retries = 4
stream_max_retries = 5

Setting max_concurrent_threads_per_session = 1 forces subagents to execute sequentially instead of firing simultaneous requests that trip upstream burst limits. Keep request_max_retries at its default of 4 and stream_max_retries at 5 (even though the schema allows up to 100). When your gateway returns a proper Retry-After header via sub2api's cooldown settings, 5 retries is plenty to bridge a brief pause; raising it to 50 only leaves your terminal hanging when an upstream pool is genuinely full.

Taming MCP Loops and Context Bloat in Cherry Studio

In Cherry Studio, 429 errors spike most often during long coding conversations or when MCP (Model Context Protocol) tools are enabled. Unlike a normal chat where you send one message a minute, an MCP workflow might execute six sequential tool calls in fifteen seconds. Because every tool result is appended to the chat history and re-sent to the model immediately, a conversation with a 60,000-token context window will burn through 360,000 input tokens in fifteen seconds—blowing past upstream TPM limits even though you only clicked "Send" once.

To stop Cherry Studio from hitting 429 limits:

  1. Limit the Context Message Count: Open the Assistant Settings for your active workspace in Cherry Studio and set a strict Context Message Count cap (for example, keeping the last 10 to 15 messages instead of unlimited history), or use the Clear Context button as soon as you finish a subtask. Keeping per-request input tokens low prevents MCP tool chains from breaching TPM ceilings.
  2. Disable Unused MCP Servers: Each active MCP server adds tool definitions to your system prompt and encourages multi-step tool chaining. Keep only the MCP tools required for your current task enabled, and avoid running parallel deep-thinking chats in background tabs.
  3. Use Separate API Keys per Client: Never paste the exact same relay token into Cherry Studio, Codex CLI, and automated background scripts at the same time. Issue a dedicated API key in New API or sub2api for each client so a heavy MCP turn in Cherry Studio does not cause your terminal sessions to fail with 429s.

Quickly Testing 429 Status Codes and Switching Base URLs

When exceeded retry limit, last status: 429 Too Many Requests brings a session to a halt, manually editing ~/.codex/config.toml or environment variables just to test whether your backup relay is healthy takes too much time.

I use our open-source LLM API Config GUI (available for Windows and macOS) to diagnose gateway errors and swap endpoints without touching config files by hand. You can run a one-click connection test against your current Base URL to see immediately whether the gateway is returning HTTP 429 (rate limit), 401/403 (auth failure), 404, or a network timeout, and switch Codex or Claude Code over to a standby Base URL and API key in seconds while your primary pool cools down.

Sources and checks

  1. OpenAI Status page