j178/chatgpt

An elegant interactive CLI for ChatGPT

chatgpt — A command‑line interface for OpenAI’s ChatGPT

What it is – A small, self‑contained CLI written in Go that lets you talk to OpenAI’s GPT‑3.5‑turbo or GPT‑4 models directly from the terminal. It works by sending your prompts to the OpenAI API (or Azure OpenAI) and streaming the response back to the console.

How you use it

  1. Export your OpenAI API key:
    export OPENAI_API_KEY=sk‑your‑key
    
  2. Run the program:
    • chatgpt – start an interactive chat session.
    • chatgpt -p translator – start a session with a predefined prompt (e.g., a translation assistant).
    • Pipe data through it, e.g.:
    cat config.yaml | chatgpt -p 'convert this yaml to json'
    

Installation options

  • Download a binary from the GitHub releases page.
  • macOS/Linux via Homebrew: brew install j178/tap/chatgpt.
  • Windows via Scoop: scoop bucket add j178 https://github.com/j178/scoop-bucket.git && scoop install j178/chatgpt.
  • Nix: add pkgs.chatgpt-cli to environment.systemPackages.
  • Build from source with Go: go install github.com/j178/chatgpt/cmd/chatgpt@latest.

Key features

  • Interactive mode with rich key bindings (switch between single‑line and multi‑line input, history navigation, copy answer, quit, etc.).
  • Prompt library – define reusable prompts in ~/.config/chatgpt/config.json and select them with -p.
  • Conversation management – multiple conversations are stored in conversations.json; you can start new chats, forget context, or delete a conversation.
  • Configurable model & parameters – choose model (gpt-3.5-turbo or gpt-4), temperature, max tokens, streaming, and context length.
  • Azure OpenAI support – set api_type: "AZURE" and map model names to your Azure deployments.
  • Pipeline‑friendly – can be used in shell pipelines, making it easy to integrate with other CLI tools.

Configuration – The tool reads ~/.config/chatgpt/config.json for defaults (API key, endpoint, prompts, model settings) and writes conversation history to ~/.config/chatgpt/conversations.json. You can also override key bindings by adding a key_map section.

License – MIT.


All details above are taken directly from the repository’s README.

Related

  • Project
  • Project
  • Project
  • Project