Package: pyChatGPTH
pyChatGPTHAn unofficial Python wrapper for OpenAI's ChatGPT APIFeaturesCloudflare's anti-bot protection bypass usingundetected_chromedriverOpenAI / Google / Microsoft login support (experimental)Captcha solvers support (2Captcha, PyPasser)Headless machines supportProxy support (only without basic auth)Getting StartedSince version 0.3.0, this library is using only theundetected_chromedriverto bypass Cloudflare's anti-bot protection.requestsmodule is no longer used due to the complexity of the protection.Please make sure you haveGoogle Chrome/Chromiumbefore using this wrapper.Installationpipinstall-UpyChatGPTHUsageObtaining session_tokenGo tohttps://chat.openai.com/chatand open the developer tools byF12.Find the__Secure-next-auth.session-tokencookie inApplication>Storage>Cookies>https://chat.openai.com.Copy the value in theCookie Valuefield.Interactive modepython3-mpyChatGPTImport as a modulefrompyChatGPTimportChatGPTsession_token='abc123'# `__Secure-next-auth.session-token` cookie from https://chat.openai.com/chatapi=ChatGPT(session_token)# auth with session tokenapi=ChatGPT(session_token,conversation_id='some-random-uuid')# specify conversation idapi=ChatGPT(session_token,proxy='https://proxy.example.com:8080')# specify proxyapi=ChatGPT(session_token,chrome_args=['--window-size=1920,768'])# specify chrome argsapi=ChatGPT(session_token,moderation=False)# disable moderationapi=ChatGPT(session_token,verbose=True)# verbose mode (print debug messages)# auth with google loginapi=ChatGPT(auth_type='google',email='example@gmail.com',password='password')# auth with microsoft loginapi=ChatGPT(auth_type='microsoft',email='example@gmail.com',password='password')# auth with openai login (captcha solving using speech-to-text engine)api=ChatGPT(auth_type='openai',email='example@gmail.com',password='password')# auth with openai login (manual captcha solving)api=ChatGPT(auth_type='openai',captcha_solver=None,email='example@gmail.com',password='password')# auth with openai login (2captcha for captcha solving)api=ChatGPT(auth_type='openai',captcha_solver='2captcha',solver_apikey='abc',email='example@gmail.com',password='password')# reuse cookies generated by successful login before login,# if `login_cookies_path` does not exist, it will process logining  with `auth_type`, and save cookies to `login_cookies_path`# only works when `auth_type` is `openai` or `google`api=ChatGPT(auth_type='openai',email='example@xxx.com',password='password',login_cookies_path='your_cookies_path',)resp=api.send_message('Hello, world!')print(resp['message'])api.reset_conversation()# reset the conversationapi.clear_conversations()# clear all conversationsapi.refresh_chat_page()# refresh the chat pageFrequently Asked QuestionsHow do I get it to work on headless linux server?# install chromium & X virtual framebuffersudoaptinstallchromium-browserxvfb# start your scriptpython3your_script.pyHow do I get it to work on Google Colab?It is normal for the seession to be crashed when installing dependencies. Just ignore the error and run your script.# install dependencies!aptinstallchromium-browserxvfb!pipinstall-Uselenium_profilespyChatGPT# install chromedriverfromselenium_profiles.utils.installerimportinstall_chromedriverinstall_chromedriver()# start your script as normal!python3-mpyChatGPTInsiprationThis project is inspired byChatGPTchatgpt-apiDisclaimerThis project is not affiliated with OpenAI in any way. Use at your own risk. I am not responsible for any damage caused by this project. Please read theOpenAI Terms of Servicebefore using this project.LicenseThis project is licensed under the GPLv3 License - see theLICENSEfile for details.