I am getting RateLimitError

for below code:

import openai
openai.api_key =‘My_Key’

df[‘embeddings’] = df.text.apply(lambda x: openai.Embedding.create(input=x, engine=‘text-embedding-ada-002’)[‘data’][0][‘embedding’])

getting below Error:

RateLimitError: Rate limit reached for default-global-with-image-limits in organization org-Seca4aBhCj3ho4ezrOQpCiTy on requests per min. Limit: 60 / min. Please try again in 1s. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit OpenAI API to add a payment method.

How can I setup Rate Limit for my account? Is it necessary for me to opt for premium?

Hi @sanketsunilsathe

Welcome to the community.

Most likely it’s because .apply() function is used on the df.text column, which applies the lambda function to each element of the column.

Therefore, for each row in the DataFrame, the openai.Embedding.create() function will be called with the corresponding value of x (i.e. the text in that row), and a new embedding will be created. This is what is leading to hitting the rate limit on the number of CPM(calls per minute)

Hi @sps
thank you very much but how can I work around this ?
FYI, I am trying to execute open AI Web crowler script
Documentation [here](https://platform.openai.com/docs/tutorials/web-qa-embeddings)
Code from [here](https://github.com/openai/openai-cookbook/tree/main/apps/web-crawl-q-and-a)

There are two ways:

  • Get your rate limit increased.
  • Make calls using the time module to add delay between calls to make a max of 60 CPM
1 Like

As you mentioned above, how to increase the rate limit? I can not find the configuration for it.

Here OpenAI API

1 Like

Thanks very much for your information.!

WARNING:langchain.embeddings.openai:Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised RateLimitError: You exceeded your current quota, please check your plan and billing details..

I am getting this error. Not sure why because have anew account i opened on april 1. I dont see my fre $5.00 credit though. I only see 18$ expire on the same date.

Is this a bug?

1 Like

Here is the same issue to me. There is no problem with rate limit for me. But that error message appears in my Python result.

I have the same error too, has anyone found a solution?

I encountered the same error using Python API and there is no problem with the rate limit allocated to my account.

There are two solutions:

  1. Sending batch request if it’s completions request
  2. Implement backoff OpenAI Platform