← 返回命令列表

Linux command

chatgpt 命令

文本

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

常用示例

Start an interactive chat

chatgpt

Send a single prompt

chatgpt "[What is the capital of France?]"

Pipe input

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

Use a specific model

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

Continue a previous conversation

chatgpt --continue "[follow-up question]"

Set system prompt

chatgpt --system "[You are a helpful coding assistant]" "[prompt]"

Output response to a file

chatgpt "[prompt]" > [response.txt]

Set temperature

chatgpt --temperature [0.7] "[prompt]"

说明

chatgpt is a command-line interface for interacting with OpenAI's ChatGPT models. It provides terminal-based access to the GPT language models for text generation, coding assistance, analysis, and general conversation. The tool supports both interactive mode for back-and-forth conversation and single-prompt mode for quick queries. Input can be piped from other commands or files, making it useful in shell pipelines for text processing tasks. Configuration can be set via command-line flags, environment variables, or a config file. The OPENAI_API_KEY environment variable is the standard way to provide credentials. Different models offer varying capabilities, speed, and pricing. System prompts allow customizing the assistant's behavior and expertise area. Temperature controls response creativity — lower values produce more focused responses while higher values increase variety. The streaming option displays responses token-by-token as they're generated.

参数

--model, -m _model_
Specify the model to use (gpt-4, gpt-3.5-turbo, etc.).
--system, -s _prompt_
Set a system prompt to define assistant behavior.
--continue, -c
Continue the previous conversation.
--temperature, -t _value_
Control randomness (0.0-2.0, default: 1.0).
--max-tokens _n_
Maximum tokens in the response.
--top-p _value_
Nucleus sampling parameter.
--stream
Stream the response as it's generated.
--no-stream
Wait for complete response before displaying.
--api-key _key_
OpenAI API key (or set OPENAI_API_KEY environment variable).
--config _file_
Path to configuration file.
--list-models
List available models.
--help
Display help information.
--version
Display version information.

FAQ

What is the chatgpt command used for?

chatgpt is a command-line interface for interacting with OpenAI's ChatGPT models. It provides terminal-based access to the GPT language models for text generation, coding assistance, analysis, and general conversation. The tool supports both interactive mode for back-and-forth conversation and single-prompt mode for quick queries. Input can be piped from other commands or files, making it useful in shell pipelines for text processing tasks. Configuration can be set via command-line flags, environment variables, or a config file. The OPENAI_API_KEY environment variable is the standard way to provide credentials. Different models offer varying capabilities, speed, and pricing. System prompts allow customizing the assistant's behavior and expertise area. Temperature controls response creativity — lower values produce more focused responses while higher values increase variety. The streaming option displays responses token-by-token as they're generated.

How do I run a basic chatgpt example?

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

What does --model, -m _model_ do in chatgpt?

Specify the model to use (gpt-4, gpt-3.5-turbo, etc.).