zed icon indicating copy to clipboard operation
zed copied to clipboard

Agent Panel: OpenAI GPT 4.1 Rate Limit on Generation

Open zerowhybr opened this issue 7 months ago • 3 comments

Summary

OpenAI's GPT 4.1 errors out because of a rate-limit in Agent Mode.

Description

Steps to trigger the problem:

  1. Create a new empty folder and open it in Zed
  2. Make a prompt for the GPT 4.1 to write a lot of code
  3. Wait until you get rate limited (usually in 5 seconds or so)

For an example prompt, this one errors out:

Start a go project in the current directory and write a full implementation of a web service using a golang web framework of your choice to manage users, sales, items on a menu, deliveries and more that you find necessary to accomplish the management of a complex business selling food items on a mass scale.
Also make API endpoints for every resource.

Create all the code, do not ask me for any input on it. Write the frontend with Material UI in mind.
Do not create the go.mod file for now, just write the code

When trying to use OpenAI's gpt-4.1 model to make edits in agent mode, I receive the following error after some seconds:

Failed to connect to OpenAI API: Rate limit reached for gpt4.1 in organization org-<myorg> on tokens per min (TPM): Limit 30000, Used 25292, Requested 10584. Please try again in 11.75s. Visit https://platform.openai.com/account/rate-limits to learn more

Actual Behavior: API calls to OpenAI fails after some time Expected Behavior: API calls to OpenAI work successfully and continue to generate code until task completion

Zed Version and System Specs

Zed: v0.183.3 (Zed Preview) OS: Linux Wayland arch unknown Memory: 62.5 GiB Architecture: x86_64 GPU: Intel(R) Iris(R) Xe Graphics (TGL GT2) || Intel open-source Mesa driver || Mesa 25.0.3-arch1.1

zerowhybr avatar Apr 17 '25 10:04 zerowhybr

I encountered the same issue with Claude 3.7.

fvdsn avatar May 08 '25 09:05 fvdsn

I also get this error after about 3 messages, very very annoying.

sayertindall avatar May 11 '25 15:05 sayertindall

Same for me using github copilot, but only after somehwat long agent thread.

The rate limit on the AI API is expected. But ZED should handle that and be able to retry / continue automatically without me waiting for a bit and sending "continue" prompt to the agent.

DocX avatar May 15 '25 10:05 DocX

Also getting this error with Claude. I hope it's being prioritized, I run into this regularly

AVGVSTVS96 avatar May 21 '25 23:05 AVGVSTVS96

If you are using bring your own key with Anthropic, you will likely want to up your "Account Tier" to unlock better rate limits. For example,

Image

Per minute input token rate-limits per minute:

  • Tier 1: 20k
  • Tier 2: 40k
  • Tier 3: 80k
  • Tier 4: 200k

These tiers effectively become your context limit. Even if Claude/Opus can support a 200k token context window, if you purchase <$40 worth of credits you will only ever get a 20k token context. These limits does not apply to Zed Pro plans using Anthropic models, only when bringing your own key.

The rate limit structure for OpenAI is similar

Image

They are in the OpenAI model docs if you scroll down on the model detail page, but similarly if you haven't yet paid $50 to OpenAI, you're going to be capped at 30k tokens per minute -- which means your context will be severely limited.

Image

@fvdsn Your error says this explicitly:

Failed to connect to OpenAI API: Rate limit reached for gpt4.1 in organization org- on tokens per min (TPM): Limit 30000, Used 25292, Requested 10584. Please try again in 11.75s. Visit https://platform.openai.com/account/rate-limits to learn more

Closing in favor of this:

  • https://github.com/zed-industries/zed/issues/31531

Please 👍 upvote and subscribe to track its progress.

notpeter avatar May 27 '25 16:05 notpeter