Package: chatgpt-cli-tool
ChatGPT - Command-Line InterfaceCLI tool for interacting with ChatGPT using terminalRequirementsPython >= 3.8.0OpenAI account and valid API keyInstallationTool can be installed using python3pipcommand:pipinstallchatgpt-cli-toolOr you can install it directly form this project after building it:pythonbuild.py

pipinstalldist/chatgpt-cli-tool-{version}.tar.gzConfigurationIn order to use ChatGPT cli you will first need to register and create an API key on
theofficial OpenAI website.Then you can configure the tool with your API key using any of the following options:Create an~/.chatgpt-cli/.envfile with variableOPENAI_API_KEYCreate an.envfile in the working directory with variableOPENAI_API_KEYSet it through environment variableOPENAI_API_KEYPass it as the first argument when executing this tool (e.g.chatgpt-cli my_api_key [out_file])All configurable environment variables for ChatGPT can be found in.env.examplefile:Variable nameDescriptionDefault valueOPENAI_API_KEYOpenAI API key used to send request-GPT_MODELGPT model used for chat completiongpt-3.5-turboGPT_TEMPERATUREGPT temperature value (between 0 and 2), lower values provide more focused and deterministic output1GPT_STREAM_RESPONSEEnable OpenAI client to use Server Sent Events for streaming tokens from the APItrueGPT_SYSTEM_DESCThe description for the system on how to best tailor answers (disable with "None")You are a very direct and straight-to-the-point assistant.GPT_IMAGE_SIZEThe generated image size (256x256, 512x512 or 1024x1024)512x512HISTORY_SIZENumber of last messages to keep in history as a context for the next question3CHAT_TEXT_WIDTHMaximum number of characters to display per line in interactive chat mode (0 - as much as possible)0CHAT_COLOREDEnable this to use colors in interactive chat modetrueCHAT_COLOR_YOUThe color used for your inputsgreenCHAT_COLOR_AIThe colore of AI responseswhiteSupported ANSI colors are: black, red, green, yellow, blue, magenta, cyan, and whiteRunning the CLIIf you installed the tool using pip, then simply start the cli using any of the following commands:chatgpt-cli [api_key] [file_out]This command starts interactive ChatGPT where you can chat with AI in form of a dialog.# with api key and conversation output file pathchatgpt-climy_api_key./path/to/chat.txt# with api key onlychatgpt-climy_api_key# with conversation output filechatgpt-clichat.txt# without any arguments, api key is used from env variable and conversation is not saved to filechatgpt-cliIf file does not exist it will be created together with all parent directories. Otherwise, if the file already exists
the user is prompted with 3 options on how to handle the existing file content:Continue conversationKeep previous content and start new conversationDelete previous content and start new conversationgpt-ai [api_key] [query]This comand sends single chat completion prompt for given query or content, and prints the result on stdout.# with api key and query argumentgpt-aimy_api_key"What is ChatGPT?"# with query argumentgpt-ai"What is ChatGPT?"# with api key and piped inputcatfile.txt|gpt-aimy_api_key# with query from stdincatquestion.txt|gpt-ai# with both query as argument and piped inputcatlong-story.txt|gpt-ai"sumarize this text in 5 bullet points"# with both query as argument and input directly from filegpt-ai"explain this code"<main.pygpt-img [api_key] [prompt] [img_out]This comand generates image for given prompt or content, and stores the image in provided output path or if not
specified, prints the binary result on stdout. Some terminals like PowerShell might malform the binary content when
outputing to file.# with api key, prompt and output image pathgpt-imgmy_api_key"Robot walking a dog"./my-images/image.png# without api keygpt-img"Robot walking a dog"./my-images/image.png# without output image path, the binary image data will be outputed to stdoutgpt-img"Robot walking a dog">image.png# with both piped input and argument promptscatdescription.txt|gpt-img"with cartoon graphics"./image.png# with only piped input and output image filecatdescription.txt|gpt-img./image.png# with only piped input and output image directed to filecatdescription.txt|gpt-img>./image.png# with only input directly from file, binary image data will be outputed to stdoutgpt-img<idea.txtAPI key argument is optional for all commands, but if provided it will override API key defined using environment
variables.ExamplesInteractive modeSingle query modeRecommendationsChatGPT-SlackbotIf you are a regular Slack user, check out my other project which provides seamless ChatGPT and Slack
integration:https://github.com/lmatosevic/chatgpt-slackbotLicenseChatGPT-Cli isMIT licensed.