Skip to main content

Command-line interface tool for interacting with ChatGPT using terminal

Project description

ChatGPT - Command-Line Interface

CLI tool for interacting with ChatGPT using terminal

Requirements

  • Python >= 3.8.0
  • OpenAI account and valid API key

Installation

Tool can be installed using python3 pip command:

pip install chatgpt-cli-tool

Or you can install it directly form this project after building it:

python build.py

pip install dist/chatgpt-cli-tool-{version}.tar.gz

Configuration

In order to use ChatGPT cli you will first need to register and create an API key on the official OpenAI website.

Then you can configure the tool with your API key using any of the following options:

  1. Create an ~/.chatgpt-cli/.env file with variable OPENAI_API_KEY
  2. Create an .env file in the working directory with variable OPENAI_API_KEY
  3. Set it through environment variable OPENAI_API_KEY
  4. Pass it as the first argument when executing this tool (e.g. chatgpt-cli my_api_key)

To see other configurable options for ChatGPT check out .env.example file.

Running the CLI

If you installed the tool using pip, then simply start the cli using any of the following commands:

chatgpt-cli [api_key]

# with api key
chatgpt-cli my_api_key

# without api key
chatgpt-cli

gpt-ai [api_key] [query]

# with api key and query argument
gpt-ai my_api_key "What is ChatGPT?"

# with query argument
gpt-ai "What is ChatGPT?"

# with api key and piped input
cat file.txt | gpt-ai my_api_key

# with query from stdin
cat question.txt | gpt-ai

# with both query as argument and piped input
cat long-story.txt | gpt-ai "sumarize this text in 5 bullet points"

# with both query as argument and input directly from file
gpt-ai "explain this code" < main.py

gpt-img [api_key] [prompt] [img_out]

# with api key, prompt and output image path
gpt-img my_api_key "Robot walking a dog" ./my-images/image.png

# without api key
gpt-img "Robot walking a dog" ./my-images/image.png

# without output image path, the binary image data will be outputed to stdout
gpt-img "Robot walking a dog" > image.png

# with both piped input and argument prompts
cat description.txt | gpt-img "with cartoon graphics" ./image.png

# with only piped input and output image file
cat description.txt | gpt-img ./image.png

# with only input directly from file, binary image data will be outputed to stdout
gpt-img < idea.txt

API key argument is optional, but if provided it will override API key defined using environment variables.

License

ChatGPT-cli is MIT licensed.

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

chatgpt-cli-tool-1.3.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatgpt_cli_tool-1.3.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file chatgpt-cli-tool-1.3.2.tar.gz.

File metadata

  • Download URL: chatgpt-cli-tool-1.3.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.2

File hashes

Hashes for chatgpt-cli-tool-1.3.2.tar.gz
Algorithm Hash digest
SHA256 be99a4ebc909b3800269cd0ee2d1ea79de8ca5053e78fa27522c166a54280b76
MD5 5c9900bf0aba016935b25144b180615c
BLAKE2b-256 2cce9885e7a0452d5d1de29794c7d59de152863e3f3ca902e37d31c59231a384

See more details on using hashes here.

File details

Details for the file chatgpt_cli_tool-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: chatgpt_cli_tool-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.2

File hashes

Hashes for chatgpt_cli_tool-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d927f910e9f26ef271eb9aaca11a2b503da73bec009c1928c73f12eb2a696ac
MD5 8f390be8349236cbb5e07c81a4c15904
BLAKE2b-256 ad6c8fbe5af889602befea333b8840c3af60df749cf60265a061ee88d6733ede

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page