generative-ai-python icon indicating copy to clipboard operation
generative-ai-python copied to clipboard

429 Quota exceeded for quota metric 'Generate Content API requests per minute' and limit 'GenerateContent request limit per minute for a region' of service 'generativelanguage.googleapis.com' for consumer 'project_number:************'. [reason: "RATE_LIMIT_EXCEEDED"

Open Yusuf80216 opened this issue 11 months ago • 1 comments

Description of the bug:

I am facing this error since last 2 weeks It says the rate limit has exceeded, but I did not request to GEMINI API more than 60 times per minute

ERROR:

429 Quota exceeded for quota metric 'Generate Content API requests per minute' and limit 'GenerateContent request limit per minute for a region' of service 'generativelanguage.googleapis.com' for consumer 'project_number:**********'. [reason: "RATE_LIMIT_EXCEEDED"
domain: "googleapis.com"
metadata {
  key: "service"
  value: "generativelanguage.googleapis.com"
}
metadata {
  key: "quota_metric"
  value: "generativelanguage.googleapis.com/generate_content_requests"
}
metadata {
  key: "quota_location"
  value: "us-west4"
}
metadata {
  key: "quota_limit"
  value: "GenerateContentRequestsPerMinutePerProjectPerRegion"
}
metadata {
  key: "quota_limit_value"
  value: "0"
}
metadata {
  key: "consumer"
  value: "projects/***********"
}
, links {
  description: "Request a higher quota limit."
  url: "https://cloud.google.com/docs/quota#requesting_higher_quota"
}
]

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

Yusuf80216 avatar Mar 21 '24 07:03 Yusuf80216

My solution is to reapply for a new key at https://aistudio.google.com/app/apikey. Please note to select a new Google Cloud project. The new key will then have normal access.

svcvit avatar Mar 22 '24 09:03 svcvit

metadata {
  key: "quota_limit_value"
  value: "0"
}

Some reason the quota is zero in that log.

It's possible that key, or project was disabled. I believe google disables any key that it finds on github, for example.

MarkDaoust avatar May 17 '24 21:05 MarkDaoust

I'm getting that error when I attempt to call count_tokens() with a large string.

stri8ed avatar May 17 '24 23:05 stri8ed

!

How large? How many times did you call it?

MarkDaoust avatar May 17 '24 23:05 MarkDaoust

Hi dears, My code worked properly till last week and now I am facing the same issue. I also created a new GCP project and generate a new Google API key for the project but still the issue exists. Gemini Pro is free as I know and the number or requests should be less than 60 as I know (Mine is 30!), do you have any other suggestion please?

saramirabi avatar May 25 '24 04:05 saramirabi

Is your prompt over 32k tokens? Gemini-Pro-1.5 seems to be limited to 32k tokens per minute... (seems like a mistake compared to other models) Screenshot 2024-06-01 152914

Benniepie avatar Jun 01 '24 14:06 Benniepie

Are solve about questions? I have same problems, i tried in different account but nothing fix the program

sultanzio avatar Jun 17 '24 08:06 sultanzio

Are solve about questions? I have same problems, i tried in different account but nothing fix the program

aoyoucxc avatar Jun 23 '24 08:06 aoyoucxc

metadata {
  key: "quota_limit_value"
  value: "0"
}

Some reason the quota is zero in that log.

It's possible that key, or project was disabled. I believe google disables any key that it finds on github, for example.

How then do I enable the API Key again. I have tried regenerating it and they all do not work.

Ahmadu-Suleiman avatar Sep 05 '24 16:09 Ahmadu-Suleiman

Prompts over 32k definitely work.

Can you give enough details that I can replicate this? A link to a Colab would be great.

MarkDaoust avatar Sep 05 '24 17:09 MarkDaoust

Solved, I used a lot of API keys, with multi thread combined. How to do it? Here instead of having to buy a Google Console, I bought a lot of daily Gmail accounts (in my case, I bought 50 Gmail accounts for $0.33 or $0.0066 per account).

It's very, very cheap and able to analyze and rate my code even to 300k lines of code and 31 million characters without limitations.

Example code:

# API keys and configuration
api_keys = [
    # Add API keys here
]

current_api_key_index = 0
api_key_lock = Lock()
key_usage_semaphore = Semaphore(len(api_keys) * 15)  # 15 RPM per key
request_lock = Lock()
api_limit_reached = []

# Configure Generative AI with the first API key
genai.configure(api_key=api_keys[current_api_key_index])

# Initialize model
model = genai.GenerativeModel('gemini-1.5-flash-latest')

Prompts over 32k definitely work.

Can you give enough details that I can replicate this? A link to a Colab would be great.

sultanzio avatar Sep 19 '24 08:09 sultanzio

@sultanzio, be careful not to post your API keys (I deleted them for you).

MarkDaoust avatar Sep 19 '24 18:09 MarkDaoust