Code in python return openai.error.RateLimitError

My code in python return openai.error.RateLimitError but i have never use the api.

import openai

openai.api_key = "###"
openai.organization = "###"
openai.project = "###"
...
openai.Completion.create(engine="davinci-002", prompt=que)["choices"][0]["text"] # que -> str

Your code in Python likely returned an error because not only have you never used the API previously, but you also have never purchased credits to pay for API services. Making pre-payments is under “settings” of your account.


The code also uses old API library methods. You would have to pip install openai=="0.28.1" for your Python environment to have a corresponding older library.

Furthermore, davinci-002 is an untrained base model that provides completions. It finishes the prompt you input - never ending the language generation without special techniques.

If you really want to continue this code for a particular reason (that an old AI might have offered), it would look like:

import openai

if openai.__version__ != '0.28.1':
    raise ValueError("This old-style code only supports openai 0.28.1.")

#openai.api_key = "sk-123"  # automatic if you have OPENAI_API_KEY env variable
openai.organization = "myorg"  # only if you want non-default organization

que="I am an avid"  # non-instruct AI continues writing what comes after this

output = openai.Completion.create(
    model="davinci-002",  # other completion model "gpt-3.5-turbo-instruct"
    prompt=que,
    max_tokens=25,
    stop=["\n"])

print(output["choices"][0]["text"])

And then how is my prompt “I am an avid”… completed by davinci-002? Randomly:

forever user of GOATYELLOWS and am never disappointed by their service and quality of product

fan of CE ESL, CSS Online. I will often cite Web Page if I use material from CE ESL, CSS Online.

Consult the API reference section for chat completions if you want to interact with a chatty AI model that can answer questions.

1 Like