gptsam
v1.4.0
Published
CLI Client for the OpenAI ChatGPT API
Downloads
9
Maintainers
Readme
GPTSAM
A CLI Wrapper on top of the ChatGPT API.
This CLI Package is based off the Node.js client for the official ChatGPT API.
Learn more about the
- OpenAI ChatGPT.
- ChatGPT API chatgpt-api
Intro
This package is a Node.js wrapper around ChatGPT by OpenAI. TS batteries included. ✨
Usage
Sign up for an OpenAI API key and setup the CLI:
gptsam setup --token <your-openai-token>
You can also use your command line export
functionality to store it in your environment.
export OPENAI_API_KEY="sk-TODO"
npx gptsam "your prompt here"
By default, the response is streamed to stdout, the results are stored in a local config file, and every invocation starts a new conversation. You can use -c
to continue the previous conversation and --no-stream
to disable streaming.
Usage:
$ gptsam <prompt>
Commands:
<prompt> Ask ChatGPT a question
rm-cache Clears the local message cache
ls-cache Prints the local message cache path
For more info, run any command with the `--help` flag:
$ gptsam --help
$ gptsam setup --help
$ gptsam rm-cache --help
$ gptsam ls-cache --help
Options:
-c, --continue Continue last conversation (default: false)
-d, --debug Enables debug logging (default: false)
-s, --stream Streams the response (default: true)
-s, --store Enables the local message cache (default: true)
-t, --timeout Timeout in milliseconds
-k, --apiKey OpenAI API key
-n, --conversationName Unique name for the conversation
-h, --help Display this message
-v, --version Display version number
Install
npm i -g gptsam
Make sure you're using node >= 18
so fetch
is available (or node >= 14
if you install a fetch polyfill).
Caveats
This project uses the ChatGPTAPI
class which relies on the gpt-3.5-turbo-0301
model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.
Compatibility
- This package is ESM-only.
- This package supports
node >= 14
. - This module assumes that
fetch
is installed. - If you want to build a website using
chatgpt
, we recommend using it only from your backend API
Credits
- Huge thanks to Travis Fischer for creating the Nodejs ChatGPT API @waylaidwanderer, @abacaj, @wong2, @simon300000, @RomanHotsiy, @ElijahPepe, and all the other contributors 💪
- The original browser version was inspired by this Go module by Daniel Gross
- OpenAI for creating ChatGPT 🔥
License
MIT © Andrew Miracle