---
title: Scripting LLMs From the Terminal With the llm CLI
description: Simon Willison's llm CLI turns the terminal into a scriptable LLM pipe. Version 0.34 adds duration logging and 0.35 adds GPT-6, all logged to SQLite.
canonical: https://lukeocodes.dev/llm-cli-terminal
type: article
locale: en_GB
published: 2026-09-07T00:00:00.000Z
modified: 2026-09-07T00:00:00.000Z
authors:
  - Luke Oliff
section: AI
tags:
  - AI
  - Developer Experience
  - llm
  - cli
  - sqlite
  - simon willison
  - shell
feed: https://lukeocodes.dev/rss.xml
search: https://lukeocodes.dev/search.json?q={query}
schema:
  - "@context": https://schema.org
    "@graph":
      - "@type": WebSite
        "@id": https://lukeocodes.dev/#website
        url: https://lukeocodes.dev
        name: Luke Oliff
        alternateName: lukeocodes
        inLanguage: en
        publisher:
          "@id": https://lukeocodes.dev/authors/luke#person
        description: Personal blog and writing by Luke Oliff — developer relations, voice AI, developer experience.
        potentialAction:
          - "@type": SearchAction
            target:
              "@type": EntryPoint
              urlTemplate: https://lukeocodes.dev/blog/search?q={search_term_string}
            query-input: required name=search_term_string
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Engineer and developer relations leader. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Engineer and developer relations leader
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
  - "@context": https://schema.org
    "@graph":
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Engineer and developer relations leader. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Engineer and developer relations leader
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
      - "@type": BlogPosting
        "@id": https://lukeocodes.dev/llm-cli-terminal#article
        headline: Scripting LLMs From the Terminal With the llm CLI
        alternativeHeadline: Scripting LLMs From the Terminal With the llm CLI
        description: Simon Willison's llm CLI turns the terminal into a scriptable LLM pipe. Version 0.34 adds duration logging and 0.35 adds GPT-6, all logged to SQLite.
        datePublished: 2026-09-07T00:00:00.000Z
        dateModified: 2026-09-07T00:00:00.000Z
        url: https://lukeocodes.dev/llm-cli-terminal
        mainEntityOfPage: https://lukeocodes.dev/llm-cli-terminal
        inLanguage: en
        author:
          - "@id": https://lukeocodes.dev/authors/luke#person
        isPartOf:
          "@id": https://lukeocodes.dev/#website
        keywords: AI, Developer Experience, llm, cli, sqlite, simon willison, shell
        articleSection: AI
        about:
          - "@type": SoftwareApplication
            name: llm
          - "@type": Person
            name: Simon Willison
          - "@type": Thing
            name: Developer Experience
        abstract: The llm CLI pipes prompts through any model from the shell, logs every call to SQLite, and runs saved templates. 0.34 added duration logging on 2 September 2026, and 0.35 added GPT-6 support five days later.
        speakable:
          "@type": SpeakableSpecification
          cssSelector:
            - .post-tldr
            - h1
        image: https://lukeocodes.dev/og.png?h=Scripting+LLMs+From+the+Terminal+With+the+llm+CLI&d=Simon+Willison%27s+llm+CLI+turns+the+terminal+into+a+scriptable+LLM+pipe.+Version+0.34+adds+duration+logging+and+0.35+adds+GPT-6%2C+all+logged+to+SQLite.&e=Writing
        wordCount: 450
        timeRequired: PT3M
        publisher:
          "@id": https://lukeocodes.dev/authors/luke#person
      - "@type": BreadcrumbList
        itemListElement:
          - "@type": ListItem
            position: 1
            name: Home
            item: https://lukeocodes.dev
          - "@type": ListItem
            position: 2
            name: Writing
            item: https://lukeocodes.dev/blog
          - "@type": ListItem
            position: 3
            name: Scripting LLMs From the Terminal With the llm CLI
            item: https://lukeocodes.dev/llm-cli-terminal
      - "@type": FAQPage
        "@id": https://lukeocodes.dev/llm-cli-terminal#faq
        mainEntity:
          - "@type": Question
            name: What is the llm CLI?
            acceptedAnswer:
              "@type": Answer
              text: llm is a command-line tool by Simon Willison for running prompts against language models from the terminal. It pipes text in, calls a model, prints the answer, and logs every prompt and response to a local SQLite database.
          - "@type": Question
            name: How do I pick a model with the llm CLI?
            acceptedAnswer:
              "@type": Answer
              text: Use the -m flag, for example llm -m gpt-6-astra 'summarise this'. Run llm models to list what's installed. Plugins add local and third-party models, and llm keys handles API keys per provider.
          - "@type": Question
            name: Where does the llm CLI store its logs?
            acceptedAnswer:
              "@type": Answer
              text: In a local SQLite database. Run llm logs to read recent responses, llm logs -n 0 for all of them, and query the file directly with sqlite-utils or Datasette. Version 0.34 added a duration_ms field to every logged call.
---

[Luke Oliff.](/)

- [Blog](/blog)
- [CV](/cv)
- [Uses](/uses)
- [User manual](/user-manual)
- [Living with ADHD](/living-and-working-with-adhd)
- [RSS](/rss.xml)

[Luke Oliff · Writing](/blog)

# Scripting LLMs From the Terminal With the llm CLI

Sep 2026 · [AI](/blog/category/ai) · 3 min read · [Luke Oliff](/authors/luke)

**TL;DR:** The llm CLI pipes prompts through any model from the shell, logs every call to SQLite, and runs saved templates. 0.34 added duration logging on 2 September 2026, and 0.35 added GPT-6 support five days later.

The llm CLI turns your terminal into a scriptable pipe to any language model, and after two September 2026 releases it's the tool I reach for before opening a chat window. Simon Willison's [llm](https://llm.datasette.io/) takes text on stdin, sends it to a model, prints the answer, and logs the whole exchange to SQLite. Version 0.34, out on 2 September, added response duration logging, and 0.35 followed on 7 September with support for OpenAI's GPT-6 ([release history](https://simonwillison.net/tags/llm/)).

The reason the llm CLI terminal workflow beats a browser tab is composition. It reads stdin and writes stdout, so it drops into a pipeline like any other Unix tool.

## Piping text through a model

The simplest use is a question:

```bash
llm "explain the difference between a mutex and a semaphore"
```

The interesting use is piping something in. Feed it a file, a command's output, anything:

```bash
git diff | llm "write a commit message for this change"
cat error.log | llm "what is the root cause here?"
```

That's the pattern I use most. The model sits in the middle of a pipe instead of in a separate app I have to copy and paste between.

## Choosing models with -m

`-m` picks the model. `llm -m gpt-6-astra "..."` uses OpenAI's GPT-6, added in 0.35. `llm models` lists what you have. Plugins extend the set: there are plugins for local models through Ollama and llama.cpp, and for other hosted providers, so the same command shape works whether the model runs on your laptop or someone's API. Keys live in `llm keys set openai` and stay out of your shell history.

## Templates for prompts you reuse

Once a prompt is worth keeping, save it as a template:

```bash
llm "summarise this in three bullet points: $input" --save summarise
cat report.md | llm -t summarise
```

I have templates for commit messages, changelog entries, and turning a rough paragraph into something I'd actually send. `llm templates` lists them, and they're plain YAML files you can edit and commit alongside a project.

## Everything logged to SQLite

Every call goes into a SQLite database, which is the feature that quietly matters most. `llm logs` shows recent responses, `llm logs -n 0` shows all of them, and because it's a real database you can query it with `sqlite-utils` or browse it in Datasette. Version 0.34's contribution was a `duration_ms` field on every logged call, so you can now see which prompts and models are slow instead of guessing.

That log is the difference between a chat tool and a scriptable one. I can grep months of prompts, find the one that worked, and re-run it. The browser tab forgets. The `llm` database doesn't.

[← Newer: GPT-6 Astra: OpenAI Declares the AGI Era](/gpt-6-astra-agi-era)

[All posts](/blog) →

## Search this site

`GET https://lukeocodes.dev/search.json?q=<words>` returns matching posts as JSON, each with its page URL and its markdown URL. Add `&limit=<1-50>` for more than 10. How it works: [/blog/search](https://lukeocodes.dev/blog/search.md).

```sh
curl "https://lukeocodes.dev/search.json?q=developer+relations"
```

---

© 2026 Luke Oliff. Posts live at the root of this site.

- [GitHub](https://github.com/lukeocodes)
- [LinkedIn](https://www.linkedin.com/in/lukeocodes)
- [X](https://x.com/lukeocodes)
- [Bluesky](https://bsky.app/profile/lukeocodes.dev)
- [Email](mailto:luke@lukeoliff.com)
- [RSS](/rss.xml)

## Cookies

This site sets one analytics cookie, from Google Analytics, and only in a browser that accepts the cookie banner. A client that does not run scripts sets no cookies, so there is nothing to accept or decline here.

[Cookie policy](/cookies)
