llm
CLI for interacting with large language models
TLDR
SYNOPSIS
llm [options] [prompt]llm subcommand [options]
DESCRIPTION
llm is a CLI and Python library for interacting with large language models. Out of the box it talks to OpenAI's API; through plugins it also supports Anthropic Claude, Google Gemini, Mistral, local Ollama, llama.cpp / GGUF, and many other providers and self-hosted models.Every prompt and response is logged to a local SQLite database (under ~/.config/io.datasette.llm/ on Linux or ~/Library/Application Support/io.datasette.llm/ on macOS) so previous conversations can be searched, exported, and replayed. The tool also supports prompt templates, system prompts, embeddings, similarity search, and pluggable backends.
PARAMETERS
PROMPT
Text prompt for the model.-m MODEL, --model MODEL
Model to use (e.g. gpt-4o, claude-3-5-sonnet, llama2).-c, --continue
Continue the most recent conversation.--cid ID
Continue a specific conversation by id.-s PROMPT, --system PROMPT
Set a system prompt.-t NAME, --template NAME
Use a named prompt template.-o KEY VALUE, --option KEY VALUE
Pass a model-specific option (e.g. -o temperature 0).-a PATH, --attachment PATH
Attach a file (image, PDF, audio) to the prompt for models that support attachments.--no-stream
Disable token streaming and only print the final answer.--key KEY
Use a specific API key for this call.
SUBCOMMANDS
chat
Open an interactive chat session.models [list | default name]
List available models or set the default model.keys [set key]
Manage API keys.logs
Show or query the persistent log of prompts and responses.templates
Manage reusable prompt templates.install package / uninstall package
Install or remove an llm plugin (e.g. llm-claude-3, llm-ollama).embed, embed-multi, similar
Generate and search text embeddings.
CAVEATS
Cloud models require API keys stored via llm keys set. Conversation logs are stored in plaintext SQLite, so be mindful of secrets in prompts. Provider support beyond OpenAI requires installing additional plugins (e.g. llm install llm-claude-3).
HISTORY
llm was created by Simon Willison to provide unified CLI access to language model APIs and local models, and to make it easy to log and query past prompts.
