llm README

The project's README from github.com/simonw/llm. As one markdown file: README.md.

LLM

GitHub repo PyPI Changelog Tests License Discord Homebrew

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:

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-5.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

For everything else, see the llm tag on my blog.

Contents

llm (simonw/llm)

Searching Database…

12.6K ·GitHub
Что это такое?LLM — это CLI-инструмент и библиотека для Python, которые позволяют отправлять промпты в OpenAI, Anthropic Claude, Google Gemini, Qwen, Gemma, Kimi, DeepSeek, Mistral и десятки других больших языковых моделей — либо через удалённые API, либо через модели, работающие локально на вашем компьютере.
Это инструмент командной строки или библиотека для Python?И то, и другое: вы получаете CLI `llm` для запуска промптов и чатов, а также Python API для выполнения промптов, эмбеддингов, схем и диалогов из собственного кода.
Как установить и начать запускать промпты?Установите через pip, Homebrew, pipx или uv, при необходимости добавьте API-ключ (например, `llm keys set openai`), затем выполните `llm 'your prompt'` или `llm chat` для интерактивной сессии. Плагины для локальных моделей, например Ollama, тоже устанавливаются и используются таким же образом.
Нужен ли API-ключ для каждой модели, которую я хочу использовать?Для облачных провайдеров, например OpenAI, нужен API-ключ (`--key your-api-key` или сохранённый через `llm keys set`), а локальные модели, подключённые через плагины вроде Ollama, ключ не требуют.
Нужно ли устанавливать отдельный плагин для каждого провайдера моделей?Да — помимо встроенной поддержки OpenAI, для моделей вроде Gemini, Claude и локальных бэкендов нужно установить соответствующий плагин LLM.
Можно ли использовать это на macOS, Linux и Windows?Да, это пакет Python, который устанавливается через pip, pipx или uv (а на macOS также через Homebrew), поэтому работает на любой платформе, где доступны Python или uv.
Где сохраняются мои промпты и ответы?По умолчанию каждый промпт и ответ записываются в локальную базу данных SQLite на вашем компьютере. Её можно запрашивать, просматривать с помощью Datasette или отключить.
Может ли он работать с инструментами или вызовом функций?Да, LLM позволяет моделям выполнять инструменты, включая набор инструментов по умолчанию, и описывает, как создавать собственные.
Можно ли получать структурированные данные вместо обычного текста?Да, LLM поддерживает JSON-схемы для извлечения структурированных данных из неструктурированного текста или изображений, с краткой схемой записи и многоразовыми шаблонами.
Можно ли генерировать эмбеддинги и искать по ним?Да, команды `llm embed`, `llm embed-multi` и `llm similar` позволяют генерировать, сохранять и искать эмбеддинги, а результаты хранятся в коллекциях в SQLite.
Можно ли использовать это с любым OpenAI-совместимым эндпоинтом, например LM Studio?Да, можно указать LLM любой совместимый с OpenAI эндпоинт Chat Completions (например, LM Studio) и запускать промпты без предварительной настройки, даже через `uvx` без предварительной установки LLM.
Creator
simonw
Size
2.4 MB
Stars
12.6K
Age
3y
Commits · 90 Days