
LLM
CLISimon Willison 开发的大模型命令行与 Python 库:在终端调用 OpenAI、Claude、Gemini 及本地模型,对话自动记入 SQLite,支持嵌入、结构化抽取与工具调用,可用插件扩展。
LLM
A CLI tool and Python library for interacting with OpenAI, Anthropic’s Claude, Google’s Gemini, Qwen, Gemma, Kimi, DeepSeek, Mistral, and dozens of other Large Language Models, both via remote APIs and with models that can be installed and run on your own machine.
Watch Language models on the command-line on YouTube for a demo or read the accompanying detailed notes.
With LLM you can:
- Run prompts from the command-line
- Store prompts and responses in SQLite
- Generate and store embeddings
- Extract structured content from text and images
- Grant models the ability to execute tools
- … and much, much more
Quick start
First, install LLM using pip or Homebrew or pipx or uv:
pip install llm
Or with Homebrew (see warning note):
brew install llm
Or with pipx:
pipx install llm
Or with uv
uv tool install llm
Use LLM to run prompts or start chats against an arbitrary OpenAI-compatible Chat Completions endpoint, such as LM Studio. With uvx, you can do this without installing LLM first:
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
Add --key your-api-key if the endpoint requires authentication. See Run against an endpoint without configuring it for more options.
If you have an OpenAI API key key you can run this:
# 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"
Run prompts against Gemini or Anthropic with their respective plugins:
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'
You can also install a plugin to access models that can run on your local device. If you use 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?'
To start an interactive chat with a model, use 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!
Project news
- 29th April 2026: LLM 0.32a0 is a major backwards-compatible refactor
- 11th August 2025: LLM 0.27, the annotated release notes: GPT-5 and improved tool calling
- 27th May 2025: Large Language Models can run tools in your terminal with LLM 0.26
- 5th May 2025: Feed a video to a vision LLM as a sequence of JPEG frames on the CLI (also LLM 0.25)
- 7th April 2025: Long context support in LLM 0.24 using fragments and template plugins
- 28th February 2025: Structured data extraction from unstructured content using LLM schemas
- 17th February 2025: LLM 0.22, the annotated release notes
- 29th October 2024: You can now run prompts against images, audio and video in your terminal using LLM
- 26th January 2024: LLM 0.13: The annotated release notes
- 12th September 2023: Build an image search engine with llm-clip, chat with models with llm chat
- 4th September 2023: LLM now provides tools for working with embeddings
- 12th July 2023: The LLM CLI tool now supports self-hosted language models via plugins
- 18th May 2023: llm, ttok and strip-tags—CLI tools for working with ChatGPT and other LLMs
- 4th April 2023: The original announcement of the llm CLI tool
For everything else, see the llm tag on my blog.
Contents
-
- Installing plugins
- Plugin directory
- Plugin hooks
- Developing a model plugin
- The initial structure of the plugin
- Installing your plugin to try it out
- Building the Markov chain
- Executing the Markov chain
- Adding that to the plugin
- Understanding execute()
- Prompts and responses are logged to the database
- Adding options
- Distributing your plugin
- GitHub repositories
- Publishing plugins to PyPI
- Adding metadata
- What to do if it breaks
- Advanced model plugins
- Tip: lazily load expensive dependencies
- Models that accept API keys
- Async models
- Models that do not support conversations
- Supporting schemas
- Supporting tools
- Supporting server-side tools
- Attachments for multi-modal models
- Structured messages and streaming events
- Condensing logged payloads with json_replacements
- Consuming prompt.messages in build_messages
- Restoring opaque metadata on subsequent requests
- Tracking token usage
- Tracking resolved model names
- LLM_RAISE_ERRORS
- Utility functions for plugins
-
- 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
相关资源

Aider
CLI终端里的 AI 结对编程工具:为整个代码库建立仓库地图,改动自动提交 git,可接入 Claude、DeepSeek、OpenAI 等几乎所有模型及本地模型,改完可自动跑 lint 与测试。
Aider-AI/aider49.6k
Mistral Vibe
CLIMistral 官方开源的终端编码助手:用 Mistral 模型读写代码、执行命令与搜索代码库,内置多种 agent 配置与子代理,支持 Skills、MCP 与 --prompt 脚本模式。需要 Mistral API Key。
mistralai/mistral-vibe5.1k
vLLM
CLI高吞吐的大模型推理与服务引擎:vllm serve 一条命令启动兼容 OpenAI 与 Anthropic 接口的服务,支持 Hugging Face 上 200 多种模型架构、量化与分布式推理。主要面向 NVIDIA、AMD 等 GPU 环境。
vllm-project/vllm93.9k
mycli
CLI带智能补全与语法高亮的 MySQL 终端客户端,兼容 MariaDB、TiDB 等;支持 --execute 与批处理模式,可按 CSV 或表格格式输出查询结果,便于 agent 直接执行 SQL。
dbcli/mycli12k
Datasette
CLI把 SQLite 数据库发布成可以浏览、可以查询的网页和 JSON API,支持 SQL 查询、元数据和插件扩展,也能用 datasette publish 部署到 Cloud Run 等平台。适合数据探索和数据新闻,需要 Python 3.10 及以上版本。
simonw/datasette11.5k
LM Studio CLI (lms)
CLILM Studio 官方命令行:列出、加载与卸载本地模型,启停本地 API 服务,查看运行状态与日志,ls、ps 等命令支持 --json 输出,便于脚本与 agent 调用。需先安装 LM Studio 桌面应用。
lmstudio-ai/lms5.4k