Skip to content

An unofficial Python wrapper for OpenAI's ChatGPT API

License

Notifications You must be signed in to change notification settings

fffiloni/pyChatGPT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyChatGPT

PyPi License PyPi

An unofficial Python wrapper for OpenAI's ChatGPT API

Getting Started

Installation

pip install pyChatGPT

Usage

Obtaining session_token

  1. Go to https://chat.openai.com/chat and open the developer tools by F12.
  2. Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com.
  3. Copy the value in the Cookie Value field.

image

Interactive mode

python -m pyChatGPT

Import as a module

from pyChatGPT import ChatGPT

session_token = 'abc123'  # `__Secure-next-auth.session-token` cookie from https://chat.openai.com/chat
api = ChatGPT(session_token)  # auth with session token
api2 = ChatGPT(email='[email protected]', password='password')  # auth with email and password
api3 = ChatGPT(session_token, conversation_id='some-random-uuid', parent_id='another-random-uuid')  # specify a conversation
api4 = ChatGPT(session_token, proxy='http://proxy.example.com:8080')  # specify proxy

resp = api.send_message('Hello, world!')
print(resp['message'])

api.refresh_auth()  # refresh the authorization token
api.reset_conversation()  # reset the conversation

Insipration

This project is inspired by

Disclaimer

This 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 the OpenAI Terms of Service before using this project.

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

About

An unofficial Python wrapper for OpenAI's ChatGPT API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%