LLM is a Python package available on PyPI and via Homebrew. Once installed, it exposes theDocumentation 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 command globally, ready to accept prompts, manage API keys, and run plugins. This page walks through installation, upgrading, key management, and common configuration options.
Installation
Choose your package manager and install
Pick the installation method that fits your workflow. All methods install the same
llm binary.Upgrading to the Latest Version
Use the upgrade command that matches your original install method:llm itself:
Using uvx for One-Off Runs
If you have uv installed, you can run LLM without a permanent installation usinguvx. This spins up a temporary virtual environment on the fly:
--with flag. For example, to run an Anthropic model without installing anything permanently:
llm commands work with uvx. You can even store your API key persistently this way:
API Key Management
Most LLM providers require an API key. LLM supports three ways to supply keys, applied in this precedence order: stored keys →--key flag → environment variable.
Saving Keys with llm keys set
The recommended approach is to store keys once using the interactive llm keys set command:
keys.json file. Find its location with:
~/Library/Application Support/io.datasette.llm/keys.json. On Linux it is typically ~/.config/io.datasette.llm/keys.json.
To list the names of all currently stored keys:
Passing Keys Per Command with --key
Pass a key directly on the command line with the --key option. You can provide a raw key value or the alias of a stored key:
Keys via Environment Variables
LLM reads API keys from environment variables when no stored key or--key flag is present. The variable name is determined by each model’s plugin. For the built-in OpenAI support, the variable is OPENAI_API_KEY. For third-party plugins, check the plugin’s documentation for its specific environment variable name.
To use an environment variable explicitly (overriding a stored key):
Configuration
Setting a Default Model
LLM defaults togpt-4o-mini when no -m flag is provided. Change the default with:
llm models to see all available models and their aliases.
Custom Directory Location
LLM stores prompt templates, API keys, preferences, and the SQLite log database in a platform-specific directory:- macOS:
~/Library/Application Support/io.datasette.llm/ - Linux:
~/.config/io.datasette.llm/
LLM_USER_PATH environment variable:
.bashrc, .zshrc, etc.) to make it permanent.
Turning SQLite Logging On and Off
By default, LLM logs every prompt and response to a local SQLite database. Disable logging globally:Even with global logging disabled, you can log a single prompt by passing
--log on the command line. See the Logging documentation for details on viewing and searching your log history.