Error...invalid API key

Traceback (most recent call last):
File “/home/runner/Sample2/main.py”, line 22, in
response = openai.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/runner/Sample2/.pythonlibs/lib/python3.11/site-packages/openai/_utils/_utils.py”, line 303, in wrapper
return func(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/home/runner/Sample2/.pythonlibs/lib/python3.11/site-packages/openai/resources/chat/completions.py”, line 598, in create
return self._post(
^^^^^^^^^^^
File “/home/runner/Sample2/.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/Sample2/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 853, in request
return self._request(
^^^^^^^^^^^^^^
File “/home/runner/Sample2/.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.AuthenticationError: Error code: 401 - {‘error’: {‘message’: 'Incorrect API key provided: oC8I9rhz
******************************NPFc. You can find your API key at https://platform.openai.com/account/api-keys.', ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘invalid_api_key’}}

Hi @mohit11jph

Please follow these steps correctly.

  1. Generate API Key from course.boltiot.com/ApiUsage
  2. Copy and paste the API Key in the “Secrets” tab in Repl.it
  3. Install the Boltiotai library. Got to to Shell tab in repl and paste this command: pip install boltiotai
  4. Import this statement in the first line of your code: from boltiotai install openai
  5. Run the code.

If you have followed all the steps correctly, your code should run and give you the expected output. If you still face any issues, please feel free to get back to us.