Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/simonw/LLM/llms.txt

Use this file to discover all available pages before exploring further.

LLM exposes every capability through a single llm entry-point. The default sub-command is llm prompt (so running llm 'some question' is identical to llm prompt 'some question'). This page documents every command, sub-command, and flag drawn directly from the CLI source.
Run llm --help or append -h to any command to see its help text in your terminal.

Prompting

llm prompt is the core command. It is also the default, so llm 'question' is equivalent.
llm [OPTIONS] [PROMPT]
llm prompt [OPTIONS] [PROMPT]
Examples
# Basic prompt
llm 'Capital of France?'

# Choose a model
llm 'Capital of France?' -m gpt-4o

# Add a system prompt
llm 'Capital of France?' -s 'answer in Spanish'

# Multi-modal with an image attachment
llm 'Extract text from this image' -a image.jpg
llm 'Describe' -a https://static.simonwillison.net/static/2024/pelicans.jpg

# Pipe an image via stdin with an explicit MIME type
cat image | llm 'describe image' --at - image/jpeg

# Extract the first fenced code block from the response
llm 'JavaScript function for reversing a string' -x
Flags
FlagDescription
PROMPTPositional prompt text (optional — can be piped via stdin)
-s, --system TEXTSystem prompt to use
-m, --model TEXTModel to use (env: LLM_MODEL)
-d, --database FILEPath to log database
-q, --query TEXTUse first model matching these strings (repeatable)
-a, --attachment ATTACHMENTAttachment path, URL, or - for stdin (repeatable)
--at, --attachment-type TEXT TEXTAttachment with explicit MIME type, e.g. --at image.jpg image/jpeg
-T, --tool TEXTName of a tool to make available to the model (repeatable)
--functions TEXTPython code block or file path defining functions to register as tools
--td, --tools-debugShow full details of tool executions
--ta, --tools-approveManually approve every tool execution
--cl, --chain-limit INTEGERHow many chained tool responses to allow (default 5, set 0 for unlimited)
-o, --option NAME VALUEkey/value options for the model (repeatable)
--optionsShow options for the selected model
--schema TEXTJSON schema, filepath or ID for structured output
--schema-multi TEXTJSON schema to use for multiple results
-f, --fragment TEXTFragment (alias, URL, hash or file path) to add to the prompt (repeatable)
--sf, --system-fragment TEXTFragment to add to the system prompt
-t, --template TEXTTemplate to use
-p, --param KEY VALUEParameters for template (repeatable)
--no-streamDo not stream output
-n, --no-logDon’t log to database
--logLog prompt and response to the database
-R, --hide-reasoningHide reasoning output
-c, --continueContinue the most recent conversation
--cid, --conversation TEXTContinue the conversation with the given ID
--key TEXTAPI key to use
--save TEXTSave prompt with this template name
--asyncRun prompt asynchronously
-u, --usageShow token usage
-x, --extractExtract first fenced code block from the response
--xl, --extract-lastExtract last fenced code block from the response
Reasoning tokens (from models like o3) are displayed to stderr in a dim style while the response streams. Use -R/--hide-reasoning to suppress them.
llm chat starts an interactive session with a model. Your conversation history is maintained for the duration of the session.
llm chat [OPTIONS]
Examples
# Chat with the default model
llm chat

# Chat with a specific model and system prompt
llm chat -m gpt-4o -s 'You are a helpful assistant'

# Continue a previous conversation
llm chat --cid <conversation-id>

# Chat with a tool available
llm chat -T llm_time
Flags
FlagDescription
-s, --system TEXTSystem prompt to use
-m, --model TEXTModel to use
-c, --continueContinue the most recent conversation
--cid, --conversation TEXTContinue the conversation with the given ID
-f, --fragment TEXTFragment to add to the prompt (repeatable)
--sf, --system-fragment TEXTFragment to add to the system prompt
-t, --template TEXTTemplate to use
-p, --param KEY VALUEParameters for template (repeatable)
-o, --option NAME VALUEkey/value options for the model (repeatable)
-d, --database FILEPath to log database
--no-streamDo not stream output
-R, --hide-reasoningHide reasoning output
--key TEXTAPI key to use
-T, --tool TEXTName of a tool to make available to the model (repeatable)
--functions TEXTPython code block or file path defining functions to register as tools
--td, --tools-debugShow full details of tool executions
--ta, --tools-approveManually approve every tool execution
--cl, --chain-limit INTEGERHow many chained tool responses to allow (default 5, set 0 for unlimited)
In-session commandsWhile in a chat session, type these special commands:
CommandDescription
!multiEnter multi-line input mode
!endEnd multi-line input and send
!editEdit the current prompt in your $EDITOR
!fragment <id>Insert content from a fragment into the current prompt
exit or quitEnd the chat session

API Keys

llm keys manages API keys stored in keys.json. Running llm keys without a sub-command is equivalent to llm keys list.
llm keys [COMMAND]
Sub-commands
# List names of all stored keys
llm keys list
llm keys set flags
FlagDescription
NAMEThe key name (e.g. openai, anthropic)
--value TEXTValue to set (prompted interactively if omitted)

Logs

llm logs gives you access to the SQLite database where every prompt and response is stored. Running llm logs without a sub-command is equivalent to llm logs list.
llm logs [COMMAND] [OPTIONS]
Sub-commands overview
Sub-commandDescription
listShow logged prompts and responses (default)
onTurn on logging for all prompts
offTurn off logging for all prompts
statusShow current logging status
pathPrint path to logs.db
backup PATHBackup your logs database to a file
llm logs list flags
llm logs list [OPTIONS]
FlagDescription
-n, --count INTEGERNumber of entries to show (default 3, use 0 for all)
-d, --database FILEPath to log database
-m, --model TEXTFilter by model or model alias
-q, --query TEXTSearch for logs matching this string
-f, --fragment TEXTFilter for prompts using these fragments
-T, --tool TEXTFilter for prompts with results from these tools
--toolsFilter for prompts that used any tool
--schema TEXTJSON schema, filepath or ID
--schema-multi TEXTJSON schema used for multiple results
-l, --latestReturn latest results matching search query (most recent first)
--dataOutput newline-delimited JSON data for schema
--data-arrayOutput JSON array of data for schema
--data-key TEXTReturn JSON objects from array in this key
--data-idsAttach corresponding IDs to JSON objects
-t, --truncateTruncate long strings in output
-s, --shortShorter YAML output with truncated prompts
-u, --usageInclude token usage
-r, --responseJust output the last response
-x, --extractExtract first fenced code block
--xl, --extract-lastExtract last fenced code block
-c, --currentShow logs from the current conversation
--cid, --conversation TEXTShow logs for this conversation ID
--id-gt TEXTReturn responses with ID greater than this value
--id-gte TEXTReturn responses with ID greater than or equal to this value
--jsonOutput logs as JSON
-e, --expandExpand fragments to show their full content
Examples
# Show the last 3 logs (default)
llm logs

# Show all logs for a specific model
llm logs -m gpt-4o -n 0

# Full-text search
llm logs -q "pelican"

# Show the most recent conversation
llm logs --cid $(llm logs list -n 1 --json | jq -r '.[0].conversation_id')

# Filter by tool usage
llm logs --tool llm_time

# Extract schema data as JSON
llm logs --data

# Toggle logging
llm logs off
llm logs on
llm logs status

Models

llm models lists and configures models. Running llm models without a sub-command is equivalent to llm models list.
llm models [COMMAND] [OPTIONS]
Sub-commands
Sub-commandDescription
listList available models (default)
default [MODEL]Show or set the default model
optionsManage default options for models
llm models list flags
llm models list [OPTIONS]
FlagDescription
--optionsShow options for each model, if available
--asyncList async models
--schemasList models that support schemas
--toolsList models that support tools
-q, --query TEXTSearch for models matching these strings (repeatable)
-m, --model TEXTSpecific model IDs to display (repeatable)
llm models options sub-commands
# List all default options set for any model
llm models options list

# Show defaults for a specific model
llm models options show gpt-4o

# Set a default option
llm models options set gpt-4o temperature 0.5

# Clear one option
llm models options clear gpt-4o temperature

# Clear all options for a model
llm models options clear gpt-4o
Examples
# List all available models
llm models list

# Show which model is the default
llm models default

# Set a new default model
llm models default gpt-4o

# Search for models supporting tools
llm models list --tools

# List models matching a search string
llm models list -q claude

Templates

Templates are reusable YAML files that can capture a system prompt, a prompt pattern, model choice, options, attachments, and tools. Running llm templates without a sub-command is equivalent to llm templates list.
llm templates [COMMAND]
Sub-commands
Sub-commandDescription
listList available prompt templates (default)
show NAMEShow the specified template
edit NAMEEdit a template in $EDITOR
pathPrint the templates directory path
loadersShow template loaders registered by plugins
Examples
# List all saved templates
llm templates list

# Create or edit a template
llm templates edit summarize

# Inspect a template
llm templates show summarize

# Use a template
cat file.txt | llm -t summarize

# Use a template with parameters
llm -t summarize -p voice GlaDOS

# Use a template from a URL
llm -t https://example.com/my-template.yaml

# Use a template from a file path
llm -t /path/to/template.yaml
Templates are YAML files. A minimal template looks like:
system: Summarize this text
Use $input as a variable for piped content and $varname for other parameters passed via -p.

Schemas

Schemas define the structured JSON output format expected from a model. Running llm schemas without a sub-command is equivalent to llm schemas list.
llm schemas [COMMAND]
Sub-commands
Sub-commandDescription
listList stored schemas (default)
show SCHEMA_IDShow a stored schema
dsl INPUTConvert LLM’s concise schema DSL to a full JSON schema
llm schemas list flags
FlagDescription
-d, --database FILEPath to log database
-q, --query TEXTSearch for schemas matching this string
--fullOutput full schema contents
--jsonOutput as JSON
--nlOutput as newline-delimited JSON
llm schemas dsl flags
FlagDescription
INPUTConcise schema definition string
--multiWrap schema in an array
Examples
# List stored schemas
llm schemas list

# Show a specific schema by ID
llm schemas show abc123

# Convert a DSL definition to JSON schema
llm schemas dsl 'name, age int, bio: their bio'

# Use a schema in a prompt
llm 'Extract data' --schema 'name, age int, bio'

# Use a schema expecting multiple results
llm 'Extract all people' --schema-multi 'name, age int'

Tools

Tools are Python functions that a model can call as part of responding to a prompt. They are provided by plugins or defined inline with --functions.
llm tools [COMMAND]
Sub-commands
Sub-commandDescription
listList available tools provided by plugins (default)
llm tools list flags
FlagDescription
[TOOL_DEFS]...Optional tool definition arguments
--jsonOutput as JSON
--functions TEXTPython code block or file path defining functions to register as tools
Examples
# List all available tools from plugins
llm tools list

# Use a built-in tool
llm -T llm_time 'What time is it?'

# Define and use an inline tool
llm --functions '
def multiply(x: int, y: int) -> int:
    """Multiply two numbers."""
    return x * y
' 'what is 34234 * 213345'

# Use a named plugin tool
llm -T my_tool 'Do something with this tool'
Tools execute code on your machine. Be cautious about prompt injection attacks where malicious content in tool inputs could cause unintended actions. Always review tool results when using --ta/--tools-approve mode.

Aliases

Aliases let you refer to a model by a short name. Running llm aliases without a sub-command is equivalent to llm aliases list.
llm aliases [COMMAND]
Sub-commands
Sub-commandDescription
listList current aliases (default)
set ALIAS [MODEL_ID]Set an alias for a model
remove ALIASRemove an alias
pathPrint the path to aliases.json
llm aliases list flags
FlagDescription
--jsonOutput as JSON
llm aliases set flags
FlagDescription
ALIASThe alias name to create
[MODEL_ID]Model ID to assign to the alias
-q, --query TEXTSet alias for first model matching these strings (repeatable, used instead of MODEL_ID)
Examples
# Create an alias
llm aliases set mini gpt-4o-mini

# Create alias using query strings
llm aliases set mini -q 4o -q mini

# List all aliases
llm aliases list

# Remove an alias
llm aliases remove mini

# Use an alias
llm -m mini 'Hello!'

Fragments

Fragments are reusable snippets of text (URLs, file paths, or arbitrary content) that can be inserted into prompts. They are stored de-duplicated in the database. Running llm fragments without a sub-command is equivalent to llm fragments list.
llm fragments [COMMAND]
Sub-commands
Sub-commandDescription
listList stored fragments (default)
set ALIAS FRAGMENTSet an alias for a fragment
show ALIAS_OR_HASHDisplay a stored fragment
remove ALIASRemove a fragment alias
loadersShow fragment loaders registered by plugins
llm fragments list flags
FlagDescription
-q, --query TEXTSearch for fragments matching these strings
--aliasesShow only fragments that have aliases
--jsonOutput as JSON
Examples
# Use a URL as a fragment in a prompt
llm -f https://llm.datasette.io/robots.txt 'explain this file'

# Set an alias for a fragment
llm fragments set mydocs ./docs.md

# Use an aliased fragment
llm -f mydocs 'summarize the documentation'

# Show the content of a fragment
llm fragments show mydocs

# List all fragments
llm fragments list

# Remove a fragment alias
llm fragments remove mydocs

# List available fragment loader prefixes (from plugins)
llm fragments loaders

Plugins

llm plugins [OPTIONS]
Flags
FlagDescription
--allInclude built-in default plugins
--hook TEXTFilter for plugins that implement this hook
Examples
# List installed third-party plugins
llm plugins

# Include built-in plugins
llm plugins --all

# Filter by hook implementation
llm plugins --hook register_tools

Installing Packages

Installs Python packages from PyPI into the same Python environment as LLM, making new plugins available immediately.
llm install [OPTIONS] [PACKAGES]...
Flags
FlagDescription
PACKAGESOne or more package names to install
-U, --upgradeUpgrade packages to the latest version
-e, --editable TEXTInstall a project in editable mode from this path
--force-reinstallReinstall all packages even if they are already up-to-date
--no-cache-dirDisable the cache
--preInclude pre-release and development versions
Examples
# Install a plugin
llm install llm-anthropic

# Upgrade a plugin
llm install -U llm-anthropic

# Install a plugin in editable mode for development
llm install -e /path/to/my-plugin

# Install a pre-release version
llm install --pre llm-some-plugin
llm uninstall [OPTIONS] PACKAGES...
Flags
FlagDescription
PACKAGESOne or more package names to uninstall
-y, --yesDon’t ask for confirmation
Examples
# Uninstall a plugin (with confirmation prompt)
llm uninstall llm-anthropic

# Uninstall without confirmation
llm uninstall -y llm-anthropic

Embeddings

Generates an embedding vector for a piece of text and optionally stores it in a named collection.
llm embed [OPTIONS] [COLLECTION] [ID]
Flags
FlagDescription
COLLECTIONCollection name to store the embedding in
IDID for this embedding within the collection
-i, --input PATHFile to embed
-m, --model TEXTEmbedding model to use
--storeStore the original text in the database alongside the vector
-d, --database FILEPath to embeddings database
-c, --content TEXTContent to embed (inline)
--binaryTreat input as binary data
--metadata TEXTJSON object metadata to store
-f, --format [json|blob|base64|hex]Output format for the embedding vector
Examples
# Embed text and print the vector as JSON
llm embed -c "Hello world" -f json

# Embed a file and store in a collection
llm embed my-docs doc1 -i document.txt --store

# Use a specific embedding model
llm embed -m ada-002 -c "Hello world"
Stores embeddings for multiple strings at once in a named collection. Input can come from CSV/TSV/JSON/JSONL files, a SQL query, or directory file globs.
llm embed-multi [OPTIONS] COLLECTION [INPUT_PATH]
Flags
FlagDescription
COLLECTIONCollection name to store embeddings in
[INPUT_PATH]Path to input file (or - for stdin)
--format [json|csv|tsv|nl]Input file format (defaults to auto-detect)
--files DIRECTORY TEXTEmbed files in a directory matching a glob pattern
--encoding TEXTEncodings to try when reading --files
--binaryTreat --files as binary data
--sql TEXTRead input using this SQL query
--attach ALIAS FILEAdditional SQLite databases to attach
--batch-size INTEGERBatch size to use when running embeddings
--prefix TEXTPrefix to add to all IDs
--prepend TEXTPrepend this string to all content before embedding
-m, --model TEXTEmbedding model to use
--storeStore the original text alongside the vector
-d, --database FILEPath to embeddings database
Examples
# Embed from a CSV file
llm embed-multi docs input.csv

# Embed from JSON via stdin
cat data.json | llm embed-multi docs -

# Embed all Markdown files in a directory
llm embed-multi docs --files docs '**/*.md' --store

# Embed from a SQL query
llm embed-multi docs --sql "SELECT id, title, body FROM posts" \
  --attach blog blog.db
Returns the top N most similar items from a collection using cosine similarity against a query string or stored embedding.
llm similar [OPTIONS] COLLECTION [ID]
Flags
FlagDescription
COLLECTIONCollection to search
[ID]ID of a stored item to find similar items for
-i, --input PATHFile to embed for comparison
-c, --content TEXTContent to embed for comparison
--binaryTreat input as binary data
-n, --number INTEGERNumber of results to return
-p, --plainOutput in plain text format (instead of JSON)
-d, --database FILEPath to embeddings database
--prefix TEXTOnly return IDs with this prefix
Examples
# Find items similar to a string
llm similar my-collection -c "I like cats"

# Find items similar to a stored embedding
llm similar my-collection 1234

# Return top 10 results in plain text
llm similar my-collection -c "machine learning" -n 10 -p

# Restrict to IDs with a specific prefix
llm similar my-collection -c "query" --prefix "docs/"
llm embed-models lists and configures embedding models. Running it without a sub-command is equivalent to llm embed-models list.
llm embed-models [COMMAND]
Sub-commands
Sub-commandDescription
listList available embedding models (default)
default [MODEL]Show or set the default embedding model
llm embed-models list flags
FlagDescription
-q, --query TEXTSearch for embedding models matching these strings
llm embed-models default flags
FlagDescription
[MODEL]Model ID to set as default (omit to show current default)
--remove-defaultReset to specifying no default model
llm collections manages named collections of embedding vectors. Running it without a sub-command is equivalent to llm collections list.
llm collections [COMMAND]
Sub-commands
Sub-commandDescription
listView a list of collections (default)
delete COLLECTIONDelete the specified collection
pathPrint the path to the embeddings database
llm collections list flags
FlagDescription
-d, --database FILEPath to embeddings database
--jsonOutput as JSON
llm collections delete flags
FlagDescription
COLLECTIONName of the collection to delete
-d, --database FILEPath to embeddings database
Examples
# List all collections
llm collections list

# Delete a collection
llm collections delete my-collection

# Print the path to the embeddings database
llm collections path

OpenAI-specific Commands

Direct access to OpenAI API endpoints beyond normal prompting.
llm openai [COMMAND]
Sub-commands
Sub-commandDescription
modelsList models available to you from the OpenAI API
llm openai models flags
FlagDescription
--jsonOutput as JSON
--key TEXTOpenAI API key to use
Examples
# List available OpenAI models
llm openai models

# Output as JSON
llm openai models --json

Build docs developers (and LLMs) love