Sir when I write my API KEY CODE then it is telling that the key is invalid

Air so pls can you check the code pls.

Hi @st8074

Can you please share a screenshot of the code and error you are getting?. This will help us to give you a better solution

Regenerate another key and use it.

Hi,

  1. I have had some similar trouble with my API key. Make sure the key is active. While using my OPENAI api key I realized later on they werent now giving the free trail. I had to make a purchase of $5 in order to use it.

  2. Make sure its maximum limit is not reached. there is a fixed number of requests you can make per day.

  3. Make sure of typo errors also.

Hi @evansmathew25 @anandshaji04 @st8074

We at Bolt IoT have created a new platform to solve the issue of Open AI credits. Bolt IoT will be providing you free credits/tokens from our side to ensure that you are able to proceed with your learning.Refer to the following topics in module 1:

  1. “Getting access to the API Key” to get the API access
  2. "Install the boltiotai library"Then you can continue with the topics to build the Artificial Intelligence projects taught in the training.Since this is a newly launched library. You might get some errors. You can share a screenshot of the error here on forum.boltiot.com and we will help you out. I hope you have a great learning experience.

sir my api key i have pastedbut still it show wrong what should i do?

Hi @geethathiyaghu

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.

Try disabling and then enable the API Key. Regenerate the API Key again and try to check if its working.

Regenerate the API key , or check if the variable name given by you in secrets tab is correct or not…

@geethathiyaghu @st8074 Is your issue resolved after following the above steps? Please click the invite button in the Repl and share it with support@boltiot.com if you are still facing the issue.

You could have used boltiotai library if your free trial has expired.

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: y2zNnH3o
******************************8KBg. You can find your API key at https://platform.openai.com/account/api-keys.', ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘invalid_api_key’}}
why?

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.

Hi @mohit11jph,

As discussed during the call with the team, you needed to share your Repl with support@boltiot.com so we could check the issue. However, we haven’t received your Repl yet. Are you encountering any problems while sharing it? Please let us know so we can assist you.
Here are the steps to share your code:

  1. Open the Repl code.
  2. Click on the “Invite” button.
  3. Enter the email ID support@boltiot.com and then click on the “Invite” button. This will share the Repl with us so we can check the error and provide feedback.

Please follow these steps and let us know if you need further help.