simonw’s llm cheatsheet

LLM is an intuitive CLI tool and Python library for interacting with LLMs. It supports both remote APIs and models run locally on your machine. It’s developed by Simon Willison (co-founder of Django), who tends to make complicated things easy to understand.

Installation with pipx

I prefer installing llm with pipx because it creates isolated environments for Python-based tools, avoiding dependency conflicts.

To install llm:

pipx install llm
Bash

To upgrade llm:

pipx upgrade llm
Bash

Managing Plugins

llm relies on plugins for different models and functionalities. You can find a directory of available plugins here.

To install a plugin:

llm install some_plugin
Bash

API Key Management

You’ll need to store API keys for LLM providers. More details can be found in the LLM Setup documentation.

To set an API key (e.g., for OpenAI):

llm keys set openai
Bash

This will prompt you to enter the key:

% llm keys set openai
Enter key:
Bash

To view your stored keys:

llm keys
Bash

Example output:

gemini
openai
openrouter
perplexity
Bash

To find where the keys are stored:

llm keys path
Bash

Example path on Windows:

C:\Users\testycool\AppData\Roaming\io.datasette.llm\keys.json
Bash

Configuring Default Models

To view your current default model:

llm models default
Bash

Example default:

gemini/gemini-2.5-flash-preview-05-20
Bash

To set your default model:

llm models default model_name
Bash

Listing Available Models

To see all available models configured with your installed plugins and keys:

llm models list
Bash

Example output (your list may vary based on installed plugins and configured keys):

OpenAI Chat: gpt-4o (aliases: 4o)
OpenAI Chat: chatgpt-4o-latest (aliases: chatgpt-4o)
OpenAI Chat: gpt-4o-mini (aliases: 4o-mini)
...
GeminiPro: gemini/gemini-2.0-pro-exp-02-05 (aliases: gemini-2.0-pro-exp-02-05)
GeminiPro: gemini/gemini-2.0-flash-lite (aliases: gemini-2.0-flash-lite)
GeminiPro: gemini/gemini-2.5-pro-exp-03-25 (aliases: gemini-2.5-pro-exp-03-25)
GeminiPro: gemini/gemini-2.5-pro-preview-03-25 (aliases: gemini-2.5-pro-preview-03-25)
GeminiPro: gemini/gemini-2.5-flash-preview-04-17 (aliases: gemini-2.5-flash-preview-04-17)
GeminiPro: gemini/gemini-2.5-pro-preview-05-06 (aliases: gemini-2.5-pro-preview-05-06)
GeminiPro: gemini/gemini-2.5-flash-preview-05-20 (aliases: gemini-2.5-flash-preview-05-20)
Default: gemini/gemini-2.5-flash-preview-05-20
Bash

Daily Use with Gemini

For day-to-day usage, I prefer Gemini because it’s free. First, you need to install the llm-gemini plugin:

llm install llm-gemini
Bash

Leave a Reply

Your email address will not be published. Required fields are marked *