The inbuilt code in the 20thvideo of the AI training is giving out an output different when executed from the video output

import openai
import os
import sys

try:
openai.api_key = os.environ[‘OPENAI_API_KEY’]
except KeyError:
sys.stderr.write(“”"
You haven’t set up your API key yet.

If you don’t have an API key yet, visit:

https://platform.openai.com/signup

  1. Make an account or sign in
  2. Click “View API Keys” from the top right menu.
  3. Click “Create new secret key”

Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.
“”")
exit(1)

response = openai.chat.completions.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?”
}])

print(response)

Required output:

My output:
Traceback (most recent call last):
File “/home/runner/AI-coding/main.py”, line 23, in
response = openai.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_utils/_utils.py”, line 303, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/resources/chat/completions.py”, line 598, in create
return self._post(
^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 1088, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 853, in request
return self._request(
^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 916, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 958, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 916, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 958, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File “/home/runner/AI-coding/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 930, in _request
raise self._make_status_error_from_response(err.response) from None
openai.RateLimitError: Error code: 429 - {‘error’: {‘message’: ‘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.’, ‘type’: ‘insufficient_quota’, ‘param’: None, ‘code’: ‘insufficient_quota’}}

Hi @anichatterjee2011

The error message states that your openAI credits are exhausted. You can create a new account using a different email id and phone number to get free credits