Exploring the vsql-ai extension

Exploring the vsql-ai extension

The vsql-ai extension adds AI prompt capabilities and text embeddings directly in SQL queries, with support for Anthropic Claude , Google Gemini , OpenAI ChatGPT , or a local LLM such as Ollama . VillageSQL is a fully compatible drop-in replacement for MySQL 8.4 with extensions for the AI era. VillageSQL can be easily added to an existing MySQL 8.0 or MySQL 8.4 replication topology for testing an evaluation, something I will demonstrate in a following post.

VillageSQL Installation

You can test this quickly with the pre-built binaries. On a clean MacOS M* series machine, it’s as easy as.

$ brew install rancher      # I am demonstrating with Docker
$ curl https://villagesql.com/shell | bash
...
How would you like to install VillageSQL?

  1) Prebuilt Binary (Fast, no compilation needed)
  2) Build from Source (Slower, compiles everything locally)

Select [1-2]: 1
...

To connect to VillageSQL, run:
  /Users/demo/.villagesql/prebuilt/bin/mysql -u root -p --socket=/Users/demo/.villagesql/mysql.sock

Root password: <redacted>
...

Validation

Connecting via the mysql client that is installed, and with the provided syntax from the installation:

$  /Users/demo/.villagesql/prebuilt/bin/mysql -u root -p --socket=/Users/demo/.villagesql/mysql.sock

mysql> SELECT VERSION();
+------------------------+
| version()              |
+------------------------+
| 8.4.9-villagesql-0.0.4 |
+------------------------+
1 row in set (0.00 sec)

~/.my.cnf Setup

I prefer to simplify my setup, using ~/.my.cnf, a custom prompt and an updated PATH which simplifies usage.

$ export PATH=~/.villagesql/prebuilt/bin:$PATH
$ cat ~/.my.cnf
[mysql]
user=root
password=<redacted>
socket=/Users/demo/.villagesql/mysql.sock
prompt="villagesql> "
$ mysql

Installing the Extension

villagesql> INSTALL EXTENSION vsql_ai;
Query OK, 0 rows affected (0.38 sec)

This is one query, that’s it, you are ready to use AI prompts.

Using the Extension

As I mentioned this can run with online models, or local models. This is how to use it with Claude.

villagesql> SET @api_key='<redacted>';
villagesql> SELECT ai_prompt('anthropic','claude-opus-4-8', @api_key, 'What happened on June 15 in history')\G
*************************** 1. row ***************************
ai_prompt('anthropic','claude-opus-4-8', @ANTHROPIC_API_KEY, 'What happened on June 15 in history'): Quite a few notable events have occurred on June 15 throughout history. Here are some of the more significant ones:

- **1215** – King John of England put his seal on the **Magna Carta** at Runnymede, a foundational document in the development of constitutional law and individual rights.

- **1300s–1389** – The **Battle of Kosovo** (June 15, 1389, by some calendars) was fought between Serbian-led forces and the Ottoman Empire, a pivotal event in Balkan history.

- **1752** – **Benjamin Franklin** is traditionally said to have conducted his famous kite experiment, demonstrating the connection between lightning and electricity (the exact date is uncertain).

- **1836** – **Arkansas** was admitted as the 25th U.S. state.

- **1844** – **Charles Goodyear** received a patent for the process of vulcanizing rubber.

- **1864** – During the U.S. Civil War, **Arlington National Cemetery** was established on the grounds of Robert E. Lee's former estate.

- **1944** – During World War II, U.S. forces began the **Battle of Saipan** in the Pacific.

- **1985** – Marked the early days of the **TWA Flight 847 hijacking** crisis (which began June 14).

These are just a selection. If you're looking for something specific—like a particular country, field (science, sports, politics), or year—let me know and I can narrow it down!
1 row in set (6.70 sec)

Running with local models

With Ollama you can run free LLM models on your own infrastructure, and you do not require a API_KEY. For example:

$ brew install ollama
$ ollama start
$ ollama run llama3.2
$ ollama list
$ mysql
villagesql> SELECT ai_prompt('local','llama3.2','','Give me a Haiku for Fall') AS poetry\G
*************************** 1. row ***************************
poetry: Golden leaves descend
Crisp autumn air on my skin
Nature's final dance

Installing from Source

If your working with VillageSQL source, the extension is easy to install and adapt. I have for example proposed Fable Support PR22 , Ollama Speed Improvements and also support for LMStudio and custom local ports .

cd ~/.villagesql
git clone https://github.com/villagesql/vsql-ai.git
cd vsql-ai/build
rm -f CMakeCache.txt
cmake .. -DVillageSQL_BUILD_DIR=/Users/rbradfor/.villagesql
make
make install
Tagged with: MySQL VillageSQL Extensions AI

Producing Chi-Squared statistics with SQL

The Chi-Squared test is one of the most widely used statistical tests for categorical data. It comes in two flavors: the goodness-of-fit test asks whether an observed frequency distribution matches an expected one, while the test of independence asks whether two categorical variables are associated with each other.

Producing Two Sample T-Test statistics with SQL

The two sample t-test for equal variance is a statistical test to determine if the means of two groups are different enough that the difference is likely caused by some underlying difference, rather than random chance.

Building your first VillageSQL Extension with AI skills

This is a technical walkthrough of the vsql-extension-builder recently released May 28 at Percona Live Bay Area 2026 and found at https://github.com/villagesql/villagesql-skills . Highlights Install VillageSQL pre-built binary first Install SDK with pre-built binary second Install the skill Run it with your AI tool The output can be found at https://github.