LinuxCommandLibrary

chatgpt-cli

TLDR

Start interactive chat

$ chatgpt
copy
Send a single prompt
$ chatgpt "[Your question here]"
copy
Chat with specific model
$ chatgpt -m [gpt-4] "[prompt]"
copy
Set system prompt
$ chatgpt -s "[You are a helpful assistant]" "[prompt]"
copy
Pipe input to ChatGPT
$ cat [file.txt] | chatgpt "[Summarize this]"
copy
Use with specific temperature
$ chatgpt -t [0.7] "[prompt]"
copy
Stream response
$ chatgpt --stream "[prompt]"
copy

SYNOPSIS

chatgpt [options] [prompt]

DESCRIPTION

chatgpt-cli provides command-line access to OpenAI's ChatGPT models. It enables conversational AI interactions from the terminal, supporting both interactive sessions and single-query scripting.
The tool handles conversation context, allowing multi-turn dialogues in interactive mode. Input can come from arguments, stdin (pipes), or interactive prompts. Responses are rendered with markdown formatting by default for better readability.
Integration with shell pipelines enables powerful workflows: analyzing files, transforming text, generating code, and automating content creation. The streaming option shows responses as they're generated.

PARAMETERS

-m, --model name

Model to use (gpt-4, gpt-3.5-turbo, etc.).
-s, --system prompt
System prompt to set context.
-t, --temperature value
Sampling temperature (0-2, default 1).
--max-tokens n
Maximum tokens in response.
--stream
Stream response tokens as generated.
-c, --continue
Continue previous conversation.
--api-key key
OpenAI API key (or set OPENAIAPIKEY).
--no-markdown
Disable markdown rendering.
-o, --output file
Write response to file.
-i, --interactive
Start interactive mode.

CAVEATS

Requires an OpenAI API key with available credits. API usage is billed per token. Large context windows may incur significant costs. Response quality varies by model; GPT-4 is more capable but more expensive than GPT-3.5. Rate limits may apply to API calls.

HISTORY

Various chatgpt-cli implementations emerged after OpenAI released the ChatGPT API in March 2023. These community tools filled the gap for users wanting terminal access to ChatGPT without using the web interface. Multiple implementations exist in different languages (Python, Go, Rust), each with similar goals but varying features.

SEE ALSO

llm(1), ollama(1), sgpt(1)

Copied to clipboard