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.
python3 -m venv venv
source venv/bin/activate
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.
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 i quit!
(sorry for being weird) 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()
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.