This is a simple CLI program to use ChatGPT.
- Have an OpenAI API key. Refer to OpenAI website for more info.
- Add balance in your account.
- Store your API key to a safe place, for example,
~/.api_key_openai_1. - Add below line in your
~/.zshrcor~/.bashrc(or other shell's equivalent).
export OPENAI_API_KEY="$(cat $HOME/.api_key_openai_1 2>/dev/null || echo '')"
- Remember to source the API key:
source ~/.zshrcorsource ~/.bashrc
Do below if you use the program for the first time.
git clonethis repo to your computer, thencdinto your local repo.- Create a Python virtual environment for this repo, activate it, and
do
pip install -r requirements.txt - Make file
call_chatgpt_api.pyexecutable:chmod u+x call_chatgpt_api.py - Start the program by:
./call_chatgpt_api.py; you can change model by adding-margument, like:./call_chatgpt_api.py -m "gpt-4.1"; available model names are on OpenAI website. - Type
exitorquitin your prompt turn to stop the program.