Search Shortcut cmd + k | ctrl + k

Ask typed questions about each row in SQL: yes/no probabilities, labels and scores from Nace's Drex decision models

Maintainer(s): mkaratayev

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.4.4 1.4.5 1.5.5 1.5.6 2.0.0
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL drex FROM community;
LOAD drex;

Example

INSTALL drex FROM community;
LOAD drex;
-- A Drex API key from https://console.nace.ai
CREATE SECRET (TYPE nace, API_KEY 'nace_sk_...');
-- The probability that the answer is yes
SELECT prompt_drex('I was charged twice for my order', 'Is this a refund request?') AS refund;
-- One label, with every label's probability
SELECT prompt_drex('I was charged twice for my order', 'Which team should handle it?',
                   choice := ['billing', 'shipping', 'tech']) AS team;

About drex

drex connects DuckDB to Drex, Nace's decision models, to classify text, score rows and return probabilities as native SQL values. prompt_drex asks a typed question about each row:

  • Yes/no (noul, the default) returns a DOUBLE, the probability that the answer is true.
  • One label of a set (choice := [...]) returns a STRUCT with the label, every label's probability and a confidence.
  • A score on ordered levels (score := [...]) returns a STRUCT with the score, every level's probability and a confidence.
  • Several questions at once (questions := {...}) asks up to 512 in one request per row and returns one struct field per question.

The arguments and result types follow MotherDuck's prompt_jev, plus model := (the default is drex-v2.0). Inputs can be VARCHAR, JSON, or a BLOB or BLOB[] of PNG, JPEG or WebP images on an image-capable model such as drex-max. drex_decide sends JSON state and questions and returns the API's answer as JSON.

Credentials. CREATE SECRET (TYPE nace, PROVIDER env) reads NACE_API_KEY (and an optional NACE_BASE_URL) from the environment, which keeps the key out of SQL history.

Requests. Each evaluated non-NULL row normally makes one request. Requests run concurrently (drex_max_concurrency, 8 by default, or concurrency := N per call), with an optional requests-per-minute cap (drex_max_rpm). Transient failures and rate limits are retried within a bounded budget, honoring the server's retry headers. A row the API refuses (an oversized input, an invalid image) returns NULL with a warning; authentication, billing and unknown models fail the query.

  • README: https://github.com/nace-ai/drex-duckdb
  • SQL API reference: https://github.com/nace-ai/drex-duckdb/blob/v0.1.0/docs/API.md
  • Issues: https://github.com/nace-ai/drex-duckdb/issues

Added Functions

function_name function_type description comment examples
drex_decide scalar NULL NULL  
prompt_drex scalar NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases typed_value
drex_max_concurrency Most Drex requests in flight at once across the database, unless a call passes concurrency := UBIGINT GLOBAL [] 8
drex_max_rpm Most Drex requests sent per minute across the database: 0 (the default) for no limit; Drex's 429s pace each account UBIGINT GLOBAL [] 0
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp
© 2026 DuckDB Foundation, Amsterdam NL
DuckDB Home Code of Conduct Trademark Use Blog