This is unofficial ChatGPT API using selenium for prompt testing and flow testing purposes
Link - https://youtu.be/cMCn2cljlls
This is an unofficial API for ChatGPT using Selenium. it is not recommended to use this API for production. This API is only for testing purposes.
This API is for projects that just need to use the ChatGPT API for testing purposes. And don't want to pay for the official API just for testing.
#### Note: This API is extremely slow than the official API. So, it is not recommended to use this API for production. This API is only for testing purposes.
python3 -m venv venv
source venv/bin/activate
#### For Windows
python -m venv venv
venv\Scripts\activate
pip install -r req.txt
python chrome_d_download.py
python chrome_handler.py s
Now you can see a chrome browser window opened. You can use this browser to login to chatgpt. And accept the promepts which are asking for your permission on chatapt page.
#### https://chat.openai.com/chat paste this link to the remote chrome browser and login to chatgpt.
python chrome_handler.py k
python api_backend.py
This will open in a terminal where you can type your message and get the response from chatgpt.To exit the program, in terminal type !quit
and press enter.
import api_backend
To Start start remote chrome browser and go to chatgpt site. (Only once)
api_backend.start_chat_gpt()
To get response from chatgpt and store it in a variable. (You can use this function as many times as you want)
variable = api_backend.make_gpt_request("what is gpt model?")
To close the remote chrome browser. (Only once)
api_backend.stop_chat_gpt()
#### Note: You can run testing_api.py
file to see how to use the API in your project.gmail_xpath
in start_chat_gpt
function in api_backend.py
file is the xpath of which search by email holder's name this can be changed to the users name. this will enable auto login to chatgpt if the user is already logged in to google
in the remote chrome browser.make_gpt_request()
should fuction should be improved to handle errors.make_gpt_request()
should return good formatted response in json format.time.sleep()
we should use implicit wait
and explicit wait
in selenium.threading
if we want to use the API in multiple projects at the same time.asyncio
to improve the speed of the API.This project is licensed under the MIT License - see the LICENSE file for details.
You can contribute to this project by making a pull request. If you want to contribute to this project, you can fork this project and make a pull request.
Any type of contribution is welcome. You can contribute to this project by improving the code, adding new features, fixing bugs, etc.
Thank you.