Search code examples
pythonopenai-apichatgpt-api

Problems implementing ChatGPT in my code?


I`ve tried creating a simple chat-bot which involves ChatGPT API, but every time I try to send it a message I face an error:

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

I understand why it should occur, but I am supposed to have $18 limit which for some reason does not work.

Here is my code:

import openai

openai.api_key = ""

def get_completion(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0,
    )
    return response.choices[0].message["content"]

get_completion("Hi")

I've tried switching to different versions of the opeanai module, but problem doesn't go away. Is there something that I am doing wrong or don't understand?


Solution

  • If this error occurs, you will no longer have enough credit. It is correct that you will receive 18$ from OpenAI at the start which you can use. However, these expire after some time and can no longer be used. Check the OpenAI dashboard, your credit has probably expired.

    Link: https://platform.openai.com/usage