An unofficial Python wrapper for OpenAI's ChatGPT API
Project description
pyChatGPT
An unofficial Python wrapper for OpenAI's ChatGPT API
Getting Started
Installation
pip install pyChatGPT
Usage
Obtaining session_token
- Go to https://chat.openai.com/chat and open the developer tools by
F12
. - Find the
__Secure-next-auth.session-token
cookie inApplication
>Storage
>Cookies
>https://chat.openai.com
. - Copy the value in the
Cookie Value
field.
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='example@domain.com', password='password') # auth with email and password
api3 = ChatGPT(session_token, conversation_id='some-random-uuid') # specify a conversation id
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyChatGPT-0.1.1.tar.gz
(16.7 kB
view hashes)
Built Distribution
pyChatGPT-0.1.1-py3-none-any.whl
(17.4 kB
view hashes)
Close
Hashes for pyChatGPT-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 667f53a620c259798f4b37be97697d2a5724332803e7d7c40c7102cf7f0df4fb |
|
MD5 | 604a18cb9638b1b54fce533f5ccb425d |
|
BLAKE2b-256 | 2d678f77cbf70c8904ebe1f48a5ac5146cc9cb073e3607fdb083ff8fdc4372fe |