I recently registered my account in chatgpt, and when I want to use the api

I receive these messages:

Traceback (most recent call last):
  File "<stdin>", line 8, in <module>
  File "/data/MisDocumentos/programas/rag/langchain/lib/python3.12/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/MisDocumentos/programas/rag/langchain/lib/python3.12/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "/data/MisDocumentos/programas/rag/langchain/lib/python3.12/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/MisDocumentos/programas/rag/langchain/lib/python3.12/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/data/MisDocumentos/programas/rag/langchain/lib/python3.12/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.

The code:

import openai # v1.35.7
import os, sys
openai.api_key=os.getenv("OPENAI_API_KEY")
messages = [
    {"role": "system", "content": "Eres un asistente Ăştil."},
    {"role": "user", "content": "Give me two reasons to learn Open AI API with Python"}
]
response = openai.ChatCompletion.create(
    model='gpt-3.5-turbo',
    messages=messages,
    max_tokens=300
)
print(response.choices[0].message['content'])

I’m trying to do the practices of a langchain course, in udemy.

1 Like

I’m getting the same issue. Not sure what’s going on. I’m not using ChatGPT Plus like you aren’t as well.

Strange. Since last week I’ve been getting this error. I put the project down, come back to it a day later, same issue. I literally haven’t exceeded any quota due to LACK of usage which makes this even more ridiculous.

You have to pay extra for the API tokens you use. This is the pricing page for it: https://openai.com/api/pricing/. Even when using ChatGPT Plus, to use the API you have to add some money to your account through this site: https://platform.openai.com/settings/organization/billing/overview. You can’t use any model for free, not even gpt-3.5. If you didn’t pay for it before you used it, you get the “You exceeded your current quota” error.

Come on, OpenAI, give us at least the gpt-3.5 API so we can experiment without worrying about the cost.