Find answers from the community

Updated 2 months ago

How to Prevent Multiple Requests Due to Insufficient Quota When Calling OpenAI API

At a glance

The community member is facing an issue where their code to predict using OpenAI is hitting the API multiple times, causing a 429 "too many requests" error, when there is insufficient quota. They are asking how to prevent this and instead get a single exception about the insufficient funds. The comments suggest using the max_retries=0 parameter in the llm constructor to prevent the retries, which the community member confirms they were able to find and use.

Hi, when calling a simple code to predict, if there is unsufficient quota on the OpenAI, the code tries to hit the point multiple times what causes 429 error too many requests. How can I prevent these hittings and just get one exception about non-suffitient funds? Thanks
Plain Text
llm = OpenAI(temperature=0, model=model_name, api_key=ai_key, 
                callback_manager=callback_manager)
response = llm.predict(Prompt(prompt))
L
Z
5 comments
max_retries=0 ?
Let me check this parameter, thanks!
I can't figure out where I should use this parameter?
In the llm constructor
Yeah, found it. Thanks!
Add a reply
Sign up and join the conversation on Discord