GreyDGL / PentestGPT

A GPT-empowered penetration testing tool
MIT License
7.05k stars 847 forks source link

Issue during installation #178

Closed howdid1gethere closed 9 months ago

howdid1gethere commented 10 months ago

During installation, when i do pentestgpt-connection, i end up with this error.

#### Test connection for OpenAI api (GPT-4)
Traceback (most recent call last):
  File "/home/reed/venv/lib/python3.11/site-packages/pentestgpt/utils/APIs/chatgpt_api.py", line 81, in _chat_completion
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: The model `gpt-4` does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/reed/venv/bin/pentestgpt-connection", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/pentestgpt/test_connection.py", line 47, in main
    result, conversation_id = chatgpt.send_new_message("Hi how are you?")
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/pentestgpt/utils/llm_api.py", line 225, in send_new_message
    response = self._chat_completion(history)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/pentestgpt/utils/APIs/chatgpt_api.py", line 119, in _chat_completion
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/home/reed/venv/lib/python3.11/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: The model `gpt-4` does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.

Everything i've seen shows that this program worked with 3.5 API keys, why is it complaining that i don't have access to four? is there an option to only use CGPT3.5?

GreyDGL commented 10 months ago

May you provide the complete input for running the tool? You can use gpt-3.5 only by specifying that in the flag.

rubentimbal commented 10 months ago

I am having the same exact issue after installation. Whenever I try to test the connection I receive the same error message.

howdid1gethere commented 10 months ago

My issue was resolved. It turns out, even though you are using the GPT3.5API, you still have to enroll a payment method on the site. It does ultimately cost $5 (minimum tipup). After supplying a payment method, the program works as it should.

rubentimbal commented 10 months ago

Thank you for you answer. I setup a pyment method and added some credits, I created a brand new API key but I keep getting an error mesage that I exceeded my quota, but the openAI website shows no usage so far. I guess I am getting closer.

howdid1gethere commented 10 months ago

Are you setting the key as an environment variable using export OPENAI_KEY=XXXXXX?

On Fri, Dec 1, 2023, 12:32 PM rubentimbal @.***> wrote:

Thank you for you answer. I setup a pyment method and added some credits, I created a brand new API key but I keep getting an error mesage that I exceeded my quota, but the openAI website shows no usage so far. I guess I am getting closer.

— Reply to this email directly, view it on GitHub https://github.com/GreyDGL/PentestGPT/issues/178#issuecomment-1836509515, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDYL4VC2EG5UPVGIDFD7RKTYHIICNAVCNFSM6AAAAAA73FDCAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZWGUYDSNJRGU . You are receiving this because you authored the thread.Message ID: @.***>

rubentimbal commented 10 months ago

Yes, my error message is related to my account it seems. I exceeded my quota, which is false. I read in a forum that sometimes it could take up to 48 hours for the new payment method to appear. I will try again tomorrow. Thanks for your help. I will let you know if it works.