Skip to main content

DuckDB AI extension

Call LLMs and embedding models from DuckDB SQL

What it covers

duckdb-ai is a DuckDB extension that calls LLMs from SQL. Classify, summarize and filter rows, extract typed fields with a JSON Schema, generate embeddings for semantic search, and turn questions into read-only SQL. Use local models through Ollama or llama.cpp, or hosted providers such as OpenAI, Claude, Gemini, Bedrock, Databricks and Snowflake Cortex.

INSTALL ai FROM community;
LOAD ai;

SET duckdb_ai_provider = 'ollama';
SET duckdb_ai_model = 'qwen3.8:27b';

SELECT ticket,
ai_classify(ticket, ['billing', 'performance', 'other']) AS category
FROM (VALUES ('I was charged twice.'), ('My query got slow.')) AS t(ticket);
ai_completeai_classifyai_filterai_summarizeai_extract_recordai_embedai_similarityai_query_dataai_usage