Error while making API call

Hello I am getting error: raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details." while running below Python code calling OpenAI through API.
As I haven’t used any api calls till now, do I need to have a subscription plan to access Open AI API?

import openai

def llm_generate_text(prompt,service,model):
if service == ‘OpenAI’:
generated_text = openai_generate(prompt,model)

return generated_text

openai.api_key = “■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■XD6dFtLM”
def openai_generate(user_prompt,selected_model):
completion = openai.ChatCompletion.create(
{“role”: “user”, “content”: user_prompt}
return completion.choices[0].message.content

Welcome to the forum.

Yes, you need a subscription to the API…

1 Like