Linux command
llm 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Chat with default model
llm "[prompt]"
Use specific model
llm -m [gpt-4o] "[prompt]"
Interactive chat session
llm chat
Continue most recent conversation
llm -c "[follow up]"
List models
llm models
Pipe input
cat [file.txt] | llm "[summarize this]"
Use a system prompt
llm -s "[Reply as a pirate]" "[Hi there]"
Set an API key
llm keys set [openai]
Install a plugin
llm install [llm-claude-3]
说明
llm is a CLI and Python library for interacting with large language models. Out of the box it talks to OpenAI's API; through plugins it also supports Anthropic Claude, Google Gemini, Mistral, local Ollama, llama.cpp / GGUF, and many other providers and self-hosted models. Every prompt and response is logged to a local SQLite database (under ~/.config/io.datasette.llm/ on Linux or ~/Library/Application Support/io.datasette.llm/ on macOS) so previous conversations can be searched, exported, and replayed. The tool also supports prompt templates, system prompts, embeddings, similarity search, and pluggable backends.
参数
- -m _MODEL_, --model _MODEL_
- Model to use (e.g. gpt-4o, claude-3-5-sonnet, llama2).
- -c, --continue
- Continue the most recent conversation.
- --cid _ID_
- Continue a specific conversation by id.
- -s _PROMPT_, --system _PROMPT_
- Set a system prompt.
- -t _NAME_, --template _NAME_
- Use a named prompt template.
- -o _KEY_ _VALUE_, --option _KEY_ _VALUE_
- Pass a model-specific option (e.g. -o temperature 0).
- -a _PATH_, --attachment _PATH_
- Attach a file (image, PDF, audio) to the prompt for models that support attachments.
- --no-stream
- Disable token streaming and only print the final answer.
- --key _KEY_
- Use a specific API key for this call.
FAQ
What is the llm command used for?
llm is a CLI and Python library for interacting with large language models. Out of the box it talks to OpenAI's API; through plugins it also supports Anthropic Claude, Google Gemini, Mistral, local Ollama, llama.cpp / GGUF, and many other providers and self-hosted models. Every prompt and response is logged to a local SQLite database (under ~/.config/io.datasette.llm/ on Linux or ~/Library/Application Support/io.datasette.llm/ on macOS) so previous conversations can be searched, exported, and replayed. The tool also supports prompt templates, system prompts, embeddings, similarity search, and pluggable backends.
How do I run a basic llm example?
Run `llm "[prompt]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -m _MODEL_, --model _MODEL_ do in llm?
Model to use (e.g. gpt-4o, claude-3-5-sonnet, llama2).