llm-keys
Manage stored API keys for the llm CLI
TLDR
SYNOPSIS
llm keys [options] [command]llm keys listllm keys set [--value secret] namellm keys get namellm keys path
DESCRIPTION
llm keys stores provider API keys for llm in a JSON file in the LLM user directory. After llm keys set openai, prompts such as llm "Five names for a pet pelican" use that key automatically.Resolution order for a prompt: --key on llm / llm prompt (raw secret or a stored alias), then keys.json, then the provider environment variable (OPENAI_API_KEY for OpenAI). --key personal uses a stored alias named personal.
PARAMETERS
list
Print the names of keys in keys.json. Default subcommand if none is given (llm keys).set name
Store a key under name. Prompts on stdin unless --value is given. Common names include openai; plugins document their own (for example anthropic).--value secret
Pass the secret on the command line instead of prompting. Visible in process listings.get name
Print the stored secret. Typical use: export OPENAI_API_KEY=$(llm keys get openai).path
Print the absolute path of keys.json.-h, --help
Help for llm keys or a subcommand.
CONFIGURATION
keys.json
Default locations: ~/.config/io.datasette.llm/keys.json on Linux, ~/Library/Application Support/io.datasette.llm/keys.json on macOS. llm keys path prints the resolved file.LLM_USER_PATH
Override the whole LLM user directory (keys, logs, templates).
INSTALL
CAVEATS
Subcommand of llm. keys.json holds secrets in plaintext. llm keys get and --value expose secrets to the terminal and process table. Homebrew llm may lag PyPI; llm install -U llm upgrades the tool inside that environment.
SEE ALSO
llm(1), llm-models(1), llm-logs(1), ollama(1)
