Simple OpenAI ChatGPT CLI in Node.js for Debian, Windows, and WSL.
This README was generated by GPT-5 and may be inaccurate.
- Core script: gpt.js
- CLI shims: cli/gpt (bash), cli/gpt.cmd (Windows)
- Installers: installer/install.sh, installer/install.cmd
- One-shot prompts or interactive REPL
- File input (
--in) and file output (--out) - Session history persisted to JSON (
--session), auto-detected.gptpfiles in CWD - Optional system role (
--role) and dev-mode output (--dev) - Streaming tokens by default (disable with
--no-stream) - Model/temperature/max-tokens controls
Backed by the official OpenAI SDK via the chat completions API in gpt.js.
- Node.js 18+ and npm
- An OpenAI API key available as the
OPENAI_API_KEYenvironment variable
Auto-install prerequisites and this CLI in one step using either command:
wget -qO- https://raw.githubusercontent.com/TheCyaniteProject/debian-automations/main/full-install.sh | bash
or
curl -fsSL https://raw.githubusercontent.com/TheCyaniteProject/debian-automations/main/full-install.sh | bash
- Install Node.js
- Debian/Ubuntu:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
or
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
nvm install --lts
nvm use --lts
- Run the installer from the project directory
cd node-gpt-cli-debian
chmod +x installer/install.sh
./installer/install.sh
What the installer does:
- Runs
npm installin the project root - Adds the
clidirectory to your PATH (system-wide via/etc/profile.dif run with sudo; otherwise in your shell profile) - Optionally saves
OPENAI_API_KEYto your profile
- Reload your shell
exec "$SHELL"
Now gpt should be available in your PATH.
Requirements:
- NVM for Windows (recommended). Install from https://github.com/coreybutler/nvm-windows/releases, then run:
nvm install --lts
nvm use --lts
Steps:
cd node-gpt-cli-debian
installer\install.cmd
What the installer does:
- Runs npm install in the project root
- Adds the
clidirectory to your user PATH viasetx(no admin needed) - Optionally saves
OPENAI_API_KEYto your user environment
Notes:
- Open a NEW terminal window after installation so the updated PATH and variables apply.
- Test with:
gpt --interactive
To skip the API key prompt:
installer\install.cmd -y
If you prefer manual PATH setup, add the absolute path to the cli folder to your user PATH.
Run the Linux installer inside WSL. This makes gpt available in your WSL shell.
cd node-gpt-cli-debian
chmod +x installer/install.sh
./installer/install.sh
exec "$SHELL"
API key in WSL:
- Set it in WSL just like Linux:
export OPENAI_API_KEY="sk-..."and persist in~/.profile. - Windows environment variables are not automatically imported into WSL shells. If your key is set in Windows, copy it into WSL and export it there.
You can set it during installation, or later:
export OPENAI_API_KEY="sk-..."
To persist it:
- Add the export line to
~/.profile(or~/.bash_profile), or rerun the installer to append it for you.
One-shot prompt:
gpt "Write a haiku about Debian"
Interactive REPL:
gpt --interactive
With a system role and session file:
gpt --role "You are a helpful CLI assistant." --session myproj "Summarize src"
All options are implemented in gpt.js:
gpt [prompt]
Options:
-i, --in <filepath> Input file to prepend to the prompt
-o, --out <filepath> Write the assistant reply to a file (also prints unless --quiet)
-r, --role <message> Add a system message before the first user prompt
-d, --dev Developer mode: ask for code-only output; strips code fences
-m, --model <id> Model ID (default: gpt-4.1-mini)
-t, --temperature <number> Sampling temperature (0–2)
--max-tokens <number> Maximum output tokens
-q, --quiet Do not print response to stdout
-s, --session <project> Persist chat history to <project>.gptp (JSON). Auto-detects a single .gptp in CWD
-I, --interactive Start interactive chat REPL
--no-stream Disable streaming (non-streaming by default when --dev)
Notes:
- Streaming is on by default, except when
--devis used (to keep outputs clean for scripting). - If
--sessionis omitted, the CLI will auto-load the most recent.gptpfile in the current directory if exactly one exists.
- Pipe a file into the prompt context and save the answer:
gpt -i README.md -o answer.txt "Extract the key points"
- Non-streaming with specific model and temperature:
gpt --no-stream -m gpt-4.1-mini -t 0.2 "Write a release note"
- Interactive session with persistent history:
gpt -I -s demo
The CLI wraps the OpenAI SDK (see package.json) and calls the Chat Completions API, building messages from your inputs and any prior session history. See the main logic in gpt.js.
Entry points:
- POSIX shell shim: cli/gpt
- Windows shim: cli/gpt.cmd
Installers:
- Debian/Linux: installer/install.sh (adds
clito PATH and optionally configuresOPENAI_API_KEY) - Windows: installer/install.cmd
- Command not found: ensure your shell has reloaded after installation (
exec "$SHELL"), and confirmwhich gptpoints to the repo'scli/gpt. - Auth errors: confirm
OPENAI_API_KEYis exported in the current shell:env | grep OPENAI_API_KEY. - Old Node.js: ensure Node 18+ (
node -v). - Windows PATH not updated: open a NEW Command Prompt/PowerShell window after running
installer\\install.cmd. Verify withwhere gpt. - WSL cannot see Windows variables: export
OPENAI_API_KEYinside WSL and persist in~/.profile.
ISC (see package.json).