Search Shortcut cmd + k | ctrl + k

Filter, classify, and score text with OpenAI Decisions, TypeSafe Jev, or Cloudflare Clef

Maintainer(s): gzheng92

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 decide FROM community;
LOAD decide;

Example

-- OpenAI example; use your own API key.
SET decisions_provider = 'openai';
CREATE OR REPLACE SECRET openai_key (TYPE decisions, API_KEY 'your-key', SCOPE 'decisions://openai');
SELECT decision_prob('The parcel arrived crushed.',
                     'Does this report physical damage?') AS probability;

About decide

decide asks decision models yes/no, multiple-choice, and rubric questions from SQL. It supports OpenAI Decisions (the default, gpt-6-luna), TypeSafe Jev, and Cloudflare Clef (Workers AI) with the same functions: boolean predicates, probabilities, categorical choices, rubric scores, and explicit multi-question JSON answers. SELECT * FROM decision_providers() lists the providers, models, and credential names. Typed functions batch 20 rows per request by default; set decisions_batch_size = 1 for independent row evaluation. Non-NULL inputs and instructions are sent to the selected provider and can incur API charges.

Credentials

Keep one decisions secret per provider, scoped to it, so each key is sent only to its own provider. Each provider also reads an environment variable.

CREATE OR REPLACE SECRET openai_key (TYPE decisions, API_KEY 'sk-...', SCOPE 'decisions://openai');
CREATE OR REPLACE SECRET jev_key (TYPE decisions, API_KEY 'your-typesafe-key', SCOPE 'decisions://jev');
CREATE OR REPLACE SECRET cf_key (TYPE decisions, API_KEY 'workers-ai-token',
                      ACCOUNT_ID 'your-account-id', SCOPE 'decisions://cloudflare');

The environment variables are OPENAI_API_KEY, TYPESAFE_API_KEY, and CLOUDFLARE_API_TOKEN with CLOUDFLARE_ACCOUNT_ID.

TypeSafe Jev and Cloudflare Clef

SET decisions_provider = 'jev';        -- default model jev-latest
SET decisions_provider = 'cloudflare'; -- default model clef; also 'clef-flash'
SET decisions_model = 'jev-1.14.0';    -- optional override; RESET when switching
SELECT decision_prob('The parcel arrived crushed.',
                     'Does this report physical damage?') AS probability;

Clef caps requests at 64 questions. Neither Jev nor Clef returns refusal answers. All providers accept text only.

No API key is required to build or run the offline tests. This is an independent integration, not an official extension of OpenAI, TypeSafe, or Cloudflare. See the README for function signatures, limits, refusal handling, and batching semantics.

Added Functions

function_name function_type description comment examples
decision scalar NULL NULL  
decision_answers scalar NULL NULL  
decision_choice scalar NULL NULL  
decision_prob scalar NULL NULL  
decision_providers table NULL NULL  
decision_score 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
decisions_batch_size Rows per request for typed functions (1 to 128) UBIGINT GLOBAL [] 20
decisions_endpoint Empty for the provider's URL; a loopback http://127.0.0.1 URL for mock tests VARCHAR GLOBAL []  
decisions_model Model id; empty for the provider's default_model VARCHAR GLOBAL []  
decisions_provider Decision provider: cloudflare, jev, openai; see decision_providers() VARCHAR GLOBAL [] openai
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