TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published


NPM version build status Test coverage npm download

npx completion-cli --help

Answers questions. This tool was done for personal use, but feel free to use it.


  • NodeJS v19+


  • Define OPENAI_API_KEY environment variable with your OpenAI key.
Usage Examples
  • Simplest one. Request creative reply of 2000 tokens long.
npx completion-cli -t 2000 -T 1 -p "Explain me the world:"
  • Send the text from blogpost.txt using supported option in the config file.

I tend to use this option almost exclusively.

npx completion-cli -j ./path/to/config.json -f ./path/to/blogpost.txt

Example of a json config here


Pass either cli flags or a JSON-config path. The CLI and JSON options are combined, CLI overwrites JSON. But only one of --prompt or --filePath or json.prompt is allowed.

Cli Supported Options
  • --help
  • --filePath or -f, the relative path to the text file. Example: completion-cli -f ./path/to/blogpost.txt
  • --jsonConfig or -j, path to a json file with any of the [Open AI Supported Options](#supported-onot both, and any of these overwrites ptions). Example: completion-cli -j ./path/to/config.json

The CLI only supports a small subset of OpenAI options

  • --prompt or -p: one way to pass text. Example: completion-cli -p Explain me the world: . The length limit is 15000 bytes (ascii characters.)
  • --model or -m, the default model used is text-davinci-003. Other flavours are: text-curie-001, text-babbage-001. Default text-davinci-003
  • --tokens or -t the expected response length in tokens (max is 4096, about 1700 english words.)`
  • --temperature or -T (capital T). How creative the model is. Float between 0 and 1. Default 0.
  • --echo or -e. Explicit boolean. Indicates whether to concatenate the response to the prompt or not. You need to specify --echo [true, false]

All the values in the object are optional. For explanations and default values check the schema file.

JSON Options
  "model": string;
  "prompt": string;
  "suffix": string;
  "max_tokens": number;
  "temperature": number;
  "top_p": number;
  "echo": boolean;
  "stop": string | string[];
  "presence_penalty": number;
  "frequency_penalty": number;
  "prePromptString": string;
  "postPromptString": string;


  • [ ] Support different text encoding for filePath (streams have option for this)
  • [ ] Improve boolean flags (atm you have to specify --flagName true/false).
  • [ ] Support multiple completions from json configuration using the option n.
  • [ ] Support for stream option.
  • [ ] Support pdf.
  • [ ] Support both from urls as well.

The code is being thought such that it is not too difficult to adapt it to the browser.



There are no restrictions and you can do with the code what you prefer.

Package Sidebar


npm i completion-cli

Weekly Downloads






Unpacked Size

45.2 kB

Total Files


Last publish


  • santimir