I am getting following about rate limit and check billing error

I went through chat gpt’s intro ai code but got into following:

Traceback (most recent call last):
  File "/home/guyen/gg/git/codelab/gpu/ml/chatpgt/chat-1.py", line 4, in <module>
    openai.ChatCompletion.create(model="gpt-3.5-turbo",
  File "/home/guyen/.local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/home/guyen/.local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/home/guyen/.local/lib/python3.9/site-packages/openai/api_requestor.py", line 230, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/home/guyen/.local/lib/python3.9/site-packages/openai/api_requestor.py", line 624, in _interpret_response
    self._interpret_response_line(
  File "/home/guyen/.local/lib/python3.9/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line
    raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.
[guyen@localhost chatpgt]$ cat
chat-1.py  run.sh
[guyen@localhost chatpgt]$ cat
chat-1.py  run.sh
[guyen@localhost chatpgt]$ cat chat-1.py
import openai

openai.api_key='■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■NSIZcq1w'
openai.ChatCompletion.create(model="gpt-3.5-turbo",
    message=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
)

I signed up for CHATgpt 20$ but that appears just usage. Do i have to sign for any add’l services for the above code to work?

I believe ChatGPT only covers https://chat.openai.com/ usage. API is separate.

It’s possible you’re exceeding the quota here: OpenAI API

OpenAI set my cap at $120. Maybe you could request more if it’s going higher than that.

Welcome to the OpenAI dev community @juryduty000

Here’s the python boilerplate code for chat completion endpoint:

# Note: you need to be using OpenAI Python v0.27.0 for the code below to work
import openai

openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
)

Note, how the code you shared uses message instead of messages param in the api call. That is where the error is.