A simple, lightweight CLI to use OpenAI's ChatGPT and DALL-E from the terminal
Project description
original work
https://github.com/0xacx/chatGPT-shell-cli
chatGPT-shell-cli
A simple, lightweight CLI to use OpenAI's ChatGPT and DALL-E from the terminal.
This project now uses a Python installer (install.py) for setup and a Python uninstaller (remove.py) for clean removal.
The main shell script is chatgpt.sh, which is installed to your system path for easy access.
Getting Started
Prerequisites
This script relies on curl for API requests and jq to parse JSON responses.
-
sudo apt install curl # Debian/Ubuntu sudo dnf install curl # Fedora/Redhat linux # or brew install curl # macOS
-
sudo apt install jq # Debian/Ubuntu sudo dnf install jq # Fedora/Redhat Linux # or brew install jq # macOS
-
An OpenAI API key. Create an account and get a free API Key at OpenAI
-
Optionally, you can install glow to render responses in markdown
Installation
For a quick install without cloning:
curl -O https://raw.githubusercontent.com/wkdkavishka/GPT-shell-4o-mini/origin/install.py
sudo python3 install.py
To install, clone this repository and run the Python installer as root
git clone https://github.com/wkdkavishka/chatGPT-shell-cli.git
cd chatGPT-shell-cli
sudo python3 install.py
You will be prompted for your OpenAI API key.
Alternatively, you can provide your key directly:
sudo python3 install.py --key <YOUR_OPENAI_API_KEY>
This will:
- Download and install
chatgpt.shto/usr/local/bin/gpt - Optionally create a symlink
/usr/local/bin/chatgpt - Add your API key and
/usr/local/binto your shell profile
Uninstallation
For a quick uninstall without cloning:
curl -O https://raw.githubusercontent.com/wkdkavishka/GPT-shell-4o-mini/origin/remove.py
sudo python3 remove.py
This will:
- Remove
OPENAI_KEYand/usr/local/binmodifications from your shell profiles - Remove the installed
gptandchatgptcommands
Manual Installation
If you want to install manually:
- Download the
chatgpt.shfile to a directory in your$PATH - Add your OpenAI API key to your shell profile:
export OPENAI_KEY=your_key_here - Make sure
/usr/local/binis in your$PATH - (Optional) Install imgcat for iTerm2 image support
Usage
Start
Chat Mode
- Run the script by using the
gptorchatgptcommand anywhere. By default the script uses thegpt-4o-minimodel.
Pipe Mode
- You can also use it in pipe mode:
echo "What is the command to get all pdf files created yesterday?" | gpt
Script Parameters
- You can also pass the prompt as a command line argument:
gpt -p "What is the regex to match an email address?"
Commands
image:To generate images, start a prompt withimage:historyTo view your chat history, typehistorymodelsTo get a list of the models available at OpenAI API, typemodelsmodel:To view all the information on a specific model, start a prompt withmodel:and the modelidcommand:To get a command with the specified functionality and run it, just typecommand:and explain what you want to achieve
Chat context
- Enable chat context mode for the model to remember your previous chat questions and answers. Start the script with
-cor--chat-context.
Set chat initial prompt
- Set your own initial chat prompt with
-ior--init-prompt
Example:gpt -i "You are Rick from Rick and Morty, reply with references to episodes."
Use the official ChatGPT model
- The default model used is
gpt-4o-mini.
Use GPT-4
- If you have access to the GPT-4 model you can use it by setting the model to
gpt-4, i.e.gpt --model gpt-4
Set request parameters
- To set request parameters:
gpt --temperature 0.9 --model text-babbage:001 --max-tokens 100 --size 1024x1024- temperature,
-tor--temperature - model,
-mor--model - max number of tokens,
--max-tokens - image size,
-sor--size - prompt,
-por--prompt - prompt from a file,
--prompt-from-file
- temperature,
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpt_shell_4o_mini-1.0.0.tar.gz.
File metadata
- Download URL: gpt_shell_4o_mini-1.0.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dc61a9e1e2a130b1eabaa732f44471a07190083f3d6a70b2e0b6c604fd9d020
|
|
| MD5 |
02116b43a175f5060246c54d55a0f580
|
|
| BLAKE2b-256 |
2d010822dc7b66c5981a25b81a366ec4e987c6688900d6f7f56b689a2594b93c
|
File details
Details for the file gpt_shell_4o_mini-1.0.0-py3-none-any.whl.
File metadata
- Download URL: gpt_shell_4o_mini-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b016a4724a874957def57cfec89767f301affc96f01f62e0ce5a21661a0baaf9
|
|
| MD5 |
4439915de447a71c454f862b5293df44
|
|
| BLAKE2b-256 |
bdb9358358e96e118aa7181807e6728aecc7f466117ebe2911fb4b6ecd2a0110
|