** This feature is ONLY enabled when it is used for the first time. **

LiteCLI v1.14.2 now has an LLM feature to help you write SQL.

Getting Started:

  1. Upgrade litecli to the latest version (at least v1.14.2 or higher).
uv tool install litecli@latest

Open a SQLite database with litecli.

$ litecli your_database_file.db
  1. Run the special command \llm in the LiteCLI prompt. This will install the necessary dependency to interact with LLMs. The default model is gpt-4o-mini which is a remote model. You need an API key from OpenAI. You can switch the default to a local model such as Ollama or Llamafile. Docs on that are available in part 2.

  2. Run \llm keys set openai which will prompt you to paste your API key.

  3. Ask a question:

SQLite> \llm "Your Question Here"

For eg, I’m exploring my Chrome history database.

SQLite> \llm "Top 5 most visited URLs"

This question is sent to the LLM along with the metadata that describes the database tables and a sample row from each table. The SQL query in the LLMs response is extracted and pre-filled in your litecli prompt.

A lot of folks are skeptical of LLMs and especially wary of sending data from your database to an external service. That’s why this feature is not builtin to the default installation. When you install LiteCLI it does NOT enable this feature or install any libraries to interact with an LLM. Instead the libraries are installed when you use it for the first time. Even then you need to add an API key in order to send your queries to an external LLM service.

To use this feature with a locally hosted LLM please check out part 2 of this blog post.