← 返回命令列表

Linux command

chatgpt-cli 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start interactive chat

chatgpt

Send a single prompt

chatgpt "[Your question here]"

Chat with specific model

chatgpt -m [gpt-4] "[prompt]"

Set system prompt

chatgpt -s "[You are a helpful assistant]" "[prompt]"

Pipe input to ChatGPT

cat [file.txt] | chatgpt "[Summarize this]"

Use with specific temperature

chatgpt -t [0.7] "[prompt]"

Stream response

chatgpt --stream "[prompt]"

说明

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.

参数

-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 OPENAI_API_KEY).
--no-markdown
Disable markdown rendering.
-o, --output _file_
Write response to file.
-i, --interactive
Start interactive mode.

FAQ

What is the chatgpt-cli command used for?

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.

How do I run a basic chatgpt-cli example?

Run `chatgpt` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -m, --model _name_ do in chatgpt-cli?

Model to use (gpt-4, gpt-3.5-turbo, etc.).