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
What is this?LLM is a CLI tool and Python library for running prompts against OpenAI, Anthropic Claude, Google Gemini, Qwen, Gemma, Kimi, DeepSeek, Mistral and dozens of other large language models, either via remote APIs or models running locally on your own machine.
Is this a command-line tool or a Python library?Both: you get an `llm` CLI for running prompts and chats, plus a Python API for prompt execution, embeddings, schemas and conversations from your own code.
How do I install it and start running prompts?Install with pip, Homebrew, pipx or uv, add an API key if needed (e.g. `llm keys set openai`), then run `llm 'your prompt'` or `llm chat` for an interactive session. Local-model plugins like Ollama can also be installed and used the same way.
Do I need an API key for every model I want to use?For hosted providers like OpenAI you need an API key (`--key your-api-key` or stored via `llm keys set`), but local models installed through plugins such as Ollama don't require one.
Do I need to install a plugin for every model provider?Yes — besides built-in OpenAI support, models like Gemini, Claude and local backends each require installing their respective LLM plugin.
Can I use this on macOS, Linux and Windows?Yes, it's a Python package installable via pip/pipx/uv (or Homebrew on macOS), so it runs cross-platform wherever Python/uv is available.
Where do my prompts and responses get stored?By default every prompt and response is logged to a local SQLite database on your machine, which you can query, browse with Datasette, or turn off.
Can it work with tools or function calling?Yes, LLM supports granting models the ability to execute tools, including a set of default tools, and documents how to implement custom ones.
Can I extract structured data instead of plain text?Yes, LLM supports JSON schemas for extracting structured content from unstructured text or images, with a concise schema syntax and reusable templates.
Can it generate and search embeddings?Yes, commands like `llm embed`, `llm embed-multi` and `llm similar` let you generate, store and search embeddings, with results stored in collections in SQLite.
Can I use it against any OpenAI-compatible endpoint, like LM Studio?Yes, you can point LLM at any OpenAI-compatible Chat Completions endpoint (e.g. LM Studio) and run prompts without pre-configuring it, even via `uvx` without installing LLM first.
Creator
simonw
Size
2.4 MB
Stars
12.6K
Age
3y
Commits · 90 Days