关于 LLM
LLM 是一个命令行工具,用于与大模型交互。它管理各种大模型提供商的凭证,从终端执行提示词,并通过插件集成扩展功能。
主要功能
- 01使用不同的大模型提供商从命令行执行提示词
- 02管理多个模型提供商的 API 凭证
- 03通过插件扩展以添加自定义模型和功能
- 04使用文件输入和管道文本组合提示词
适用场景
- 01快速大模型查询集成到 shell 脚本和工作流中
- 02使用不同的模型提供商进行测试和原型设计
- 03在不需要外部 API 的情况下围绕大模型功能构建自动化
安装
选择你的系统或包管理器,复制命令到终端运行。
$
安装完成后运行llm --version确认安装成功。
命令示例
常用命令按使用顺序排列。
01
02
03
详细介绍
LLM
一个用于与 OpenAI、Anthropic’s Claude、Google’s Gemini、Qwen、Gemma、Kimi、DeepSeek、Mistral 以及数十种其他大模型交互的命令行工具和 Python 库,既可通过远程 API 使用,也可使用能够安装并在本机运行的模型。
在 YouTube 上观看 命令行中的语言模型 演示,或阅读配套的详细说明。
使用 LLM,你可以:
快速开始
首先,使用 pip、Homebrew、pipx 或 uv 安装 LLM:
pip install llm
也可以使用 Homebrew(参阅警告说明):
brew install llm
也可以使用 pipx:
pipx install llm
也可以使用 uv
uv tool install llm
使用 LLM,通过任意兼容 OpenAI 的 Chat Completions 端点运行提示词或开始聊天,例如 LM Studio。使用 uvx,无需先安装 LLM 即可执行:
uvx llm openai endpoint http://localhost:1234/v1 \
-m google/gemma-4-12b \
"What is the capital of France?"
uvx llm openai endpoint http://localhost:1234/v1 \
-m google/gemma-4-12b \
--chat
如果端点需要身份验证,请添加 --key your-api-key。更多选项请参阅在不配置端点的情况下使用端点。
如果你有 OpenAI API key,可以运行以下命令:
# Paste your OpenAI API key into this
llm keys set openai
# Run a prompt (with the default gpt-6-luna model)
llm "Ten fun names for a pet pelican"
# Extract text from an image
llm "extract text" -a scanned-document.jpg
# Use a system prompt against a file
cat myfile.py | llm -s "Explain this code"
使用各自的插件,针对 Gemini 或 Anthropic 运行提示词:
llm install llm-gemini
llm keys set gemini
# Paste Gemini API key here
llm -m gemini-3.5-flash 'Tell me fun facts about Mountain View'
llm install llm-anthropic
llm keys set anthropic
# Paste Anthropic API key here
llm -m claude-sonnet-5 'Impress me with wild facts about turnips'
你也可以安装插件,以使用可在本地设备上运行的模型。如果你使用 Ollama:
# Install the plugin
llm install llm-ollama
# Download and run a prompt against the Orca Mini 7B model
ollama pull llama3.2:latest
llm -m llama3.2:latest 'What is the capital of France?'
要与模型开始交互式聊天,请使用 llm chat:
llm chat -m gpt-4.1
Chatting with gpt-4.1
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
Type '!edit' to open your default editor and modify the prompt.
Type '!fragment <my_fragment> [<another_fragment> ...]' to insert one or more fragments
> Tell me a joke about a pelican
Why don't pelicans like to tip waiters?
Because they always have a big bill!
项目动态
- 2026 年 4 月 29 日:LLM 0.32a0 是一次向后兼容的重大重构
- 2025 年 8 月 11 日:LLM 0.27 注释版发布说明:GPT-5 和改进的工具调用
- 2025 年 5 月 27 日:使用 LLM 0.26,大语言模型可以在终端中运行工具
- 2025 年 5 月 5 日:在命令行中将视频作为一系列 JPEG 帧输入视觉大模型(另有 LLM 0.25)
- 2025 年 4 月 7 日:LLM 0.24 通过片段和模板插件支持长上下文
- 2025 年 2 月 28 日:使用 LLM schemas 从非结构化内容中提取结构化数据
- 2025 年 2 月 17 日:LLM 0.22 注释版发布说明
- 2024 年 10 月 29 日:现在可以使用 LLM 在终端中对图像、音频和视频运行提示词
- 2024 年 1 月 26 日:LLM 0.13:注释版发布说明
- 2023 年 9 月 12 日:使用 llm-clip 构建图像搜索引擎,使用 llm chat 与模型聊天
- 2023 年 9 月 4 日:LLM 现在提供了用于处理嵌入的工具
- 2023 年 7 月 12 日:LLM 命令行工具现在可通过插件支持自托管语言模型
- 2023 年 5 月 18 日:llm、ttok 和 strip-tags——用于处理 ChatGPT 和其他大模型的命令行工具
- 2023 年 4 月 4 日:llm 命令行工具的首次公告
其他内容请参阅我博客上的 llm 标签。
目录
- 设置
- 使用方法
- OpenAI 模型
- 其他模型
- 工具
- 架构
- 模板
- 片段
- 模型别名
- 嵌入
- 插件
- Python API
- 记录到 SQLite
- 相关工具
- CLI 参考
- llm –help
- llm prompt –help
- llm chat –help
- llm keys –help
- llm logs –help
- llm models –help
- llm templates –help
- llm schemas –help
- llm tools –help
- llm aliases –help
- llm fragments –help
- llm plugins –help
- llm install –help
- llm uninstall –help
- llm embed –help
- llm embed-multi –help
- llm similar –help
- llm embed-models –help
- llm collections –help
- llm openai –help
- llm –help
- 贡献
- Changelog
评论
支持 Markdown