Simple script for chatting with ChatGPT from the command line, using the official API (Released March 1st, 2023). It allows, after providing a valid API Key, to use ChatGPT at the maximum speed, at a fraction of the cost of a full ChatGPT Plus subscription (at least for the average user).
Go to platform.openai.com and log-in with your OpenAI account (register if you don't have one). Click on your name initial in the top-right corner, then select "View API keys". Finally click on "Create new secret key". That's it.
You may also need to add a payment method, clicking on Billing --> Payment methods. New accounts should have some free credits, but adding a payment method may still be mandatory. For pricing, check this page.
You need Python installed on your system.
Clone the repository:
git clone https://github.com/marcolardera/chatgpt-cli.git
Install the dependencies:
pip install -r requirements.txt
After that, edit the config.yaml file, putting your API Key as the value of the api-key
parameter. Save the file.
Launch the chatgpt.py script (depending on your environment you may need to use the python3
command instead of python
):
python chatgpt.py
Then just chat! The number next to the prompt is the tokens used in the conversation at that point.
Use the /q
command to quit and show the number of total tokens used and an estimate of the expense for that session.