Snowflake AI SQL

Snowflake Cortex AI Functions in SQL: AI_COMPLETE, AI_FILTER, AI_AGG and More

Celestinfo Software Solutions Pvt. Ltd. • Oct 31, 2024

Last updated: October 2026

Quick answer: Snowflake's AI functions, introduced as Cortex AISQL and now documented as Cortex AI Functions, let you call language models from SQL. The core functions became generally available between November 2025 and January 2026: AI_COMPLETE for generation, AI_CLASSIFY and AI_FILTER for labelling and filtering rows, AI_AGG and AI_SUMMARIZE_AGG for aggregating text across many rows, and AI_SIMILARITY for comparing text or images. Model lineups change, so check regional availability before choosing a model for AI_COMPLETE.

Introduction

Snowflake announced Cortex AISQL in June 2025 as a way to use language models inside ordinary SQL: filtering rows by meaning, classifying text and images, and summarising whole groups of records. The functions have since become generally available, the documentation now calls them Cortex AI Functions, and several of the models used in early examples, including the screenshots in the first version of this article, have been retired. This version covers the functions as they stand in October 2026, with examples you can run today.

From preview to general availability

The core functions moved out of preview in three steps:


FunctionWhat it doesGenerally available
AI_CLASSIFYAssigns text or images to categories you supply4 November 2025
AI_SIMILARITYScores how similar two texts or two images are4 November 2025
AI_EMBEDCreates embedding vectors4 November 2025
AI_TRANSCRIBETranscribes audio files4 November 2025
AI_COMPLETEGenerates a response from a prompt, optionally with files21 November 2025
AI_FILTERReturns TRUE or FALSE for a natural-language condition22 January 2026
AI_AGG and AI_SUMMARIZE_AGGAggregate or summarise text across many rows22 January 2026

The family also includes AI_EXTRACT, AI_SENTIMENT, AI_TRANSLATE, AI_SUMMARIZE (still in preview), AI_PARSE_DOCUMENT, AI_REDACT and AI_MULTI_EMBED, plus helper functions such as TO_FILE, PROMPT and AI_COUNT_TOKENS. Our article on translation, summarisation, sentiment and classification covers the text-analysis functions in more detail.


AI_COMPLETE and choosing a model

AI_COMPLETE sends a prompt to a model you name and returns its response. It accepts positional or named arguments: the model and prompt are required, and model parameters, a response format and a show_details flag are optional. In the model parameters, temperature and top_p range from 0 to 1 and default to 0, and max_tokens defaults to 4096. For a single image or file, the form is AI_COMPLETE(model, predicate, file [, model_parameters]), with three required arguments.


AI_COMPLETE with model parameters and structured output
SELECT AI_COMPLETE(
    model => 'llama3.3-70b',
    prompt => 'Summarise the main complaint in this review in one sentence: ' || review_text,
    model_parameters => {'temperature': 0, 'max_tokens': 120}
) AS complaint
FROM product_reviews
LIMIT 20;

-- Structured output: the response follows a JSON schema
SELECT AI_COMPLETE(
    model => 'llama3.3-70b',
    prompt => 'Extract the product and the complaint from this review: ' || review_text,
    response_format => {
        'type': 'json',
        'schema': {
            'type': 'object',
            'properties': {
                'product':   {'type': 'string'},
                'complaint': {'type': 'string'}
            },
            'required': ['product', 'complaint']
        }
    }
) AS extracted
FROM product_reviews
LIMIT 20;

Model choice is where older examples break. Snowflake retires models on a schedule, and a query that names a retired model fails. Since the first version of this article, llama2-70b-chat was deprecated in the 2025_05 behavior change bundle, Claude 3.5 Sonnet was deprecated on 31 March 2026, and mistral-7b and llama4-maverick became legacy models on 12 August 2026, which means accounts that had not used them before that date cannot call them. The models listed for AI_COMPLETE now include current Claude, Llama, Mistral and DeepSeek models, and availability depends on your region. We recommend keeping the model name in one configuration table or variable, so that moving to a newer model is a one-line change.


AI_CLASSIFY

AI_CLASSIFY needs at least two distinct categories, and Snowflake notes that more than about twenty can reduce accuracy. An optional configuration object accepts a task description of up to 50 words, 'output_mode': 'multi' for multi-label results, and few-shot examples. The result is an object with a labels array.


Classify support tickets
SELECT ticket_id,
       AI_CLASSIFY(
           ticket_body,
           ['technical issue', 'billing', 'account access', 'general inquiry'],
           {'task_description': 'Classify the main reason the customer contacted support'}
       ):labels[0]::STRING AS ticket_type
FROM support_tickets;

AI_FILTER

AI_FILTER returns TRUE or FALSE for a condition written in natural language, which makes it usable directly in a WHERE clause or a join condition. It has three forms: a single input string, a predicate plus a file, and a PROMPT() template that combines several columns.


AI_FILTER in its three forms
-- 1. A single input string
SELECT AI_FILTER('Is Canada in North America?');

-- 2. A predicate and a file: find cat pictures on a stage
WITH pictures AS (
    SELECT TO_FILE(file_url) AS img FROM DIRECTORY(@file_stage)
)
SELECT FL_GET_RELATIVE_PATH(img) AS file_path
FROM pictures
WHERE AI_FILTER('Is this a picture of a cat?', img);

-- 3. A PROMPT() template over columns
SELECT review_id, review_text
FROM product_reviews
WHERE AI_FILTER(PROMPT('This review mentions a delivery problem: {0}', review_text));

Trying to get this past a proof of concept? Enterprise AI work rarely stalls on the model. It stalls on what sits underneath: retrieval that returns the wrong chunk, permissions that leak across tenants, and no agreed way to tell a good answer from a bad one. We build the pipeline, the access rules and the evaluation harness so the thing can actually go live.

Book an AI readiness call AI and ML services

AI_AGG and AI_SUMMARIZE_AGG

The aggregate functions work across many rows at once. AI_AGG takes a text expression and an instruction describing the aggregation, and AI_SUMMARIZE_AGG summarises a group without an instruction. Unlike AI_COMPLETE and AI_SUMMARIZE, both handle groups of text larger than the model's context window, which makes them suited to questions such as what customers say about each product.


Summarise reviews per restaurant
SELECT restaurant_id,
       AI_AGG(review, 'Summarize the restaurant reviews for potential consumers') AS summary
FROM reviews
GROUP BY 1;

SELECT product_id, AI_SUMMARIZE_AGG(review_text) AS summary
FROM product_reviews
GROUP BY product_id;

When calling AI_AGG with named arguments, note that the second argument is called instruction.


AI_SIMILARITY

AI_SIMILARITY returns a score from -1 to 1 for two texts or two images; it does not compare a text with an image. An optional configuration object can name the embedding model to use. It is useful for matching near-duplicate descriptions or finding records that say the same thing in different words.


Compare two descriptions
SELECT AI_SIMILARITY(
    'Stainless steel chef knife, 8 inch',
    '20 cm chef''s knife in stainless steel'
) AS similarity;

Keeping costs under control

AI functions are billed by the tokens they process, and a function applied to every row of a large table processes a great many tokens. Three habits keep costs predictable. Develop against a sample with LIMIT, and estimate the input size with AI_COUNT_TOKENS before a full run. Materialise results into a table instead of calling the function again in every dashboard query. And note that resource monitors cover warehouses only; spending on AI services needs a Snowflake budget to be tracked and capped.


Key takeaways


Frequently Asked Questions

Q: What is Snowflake Cortex AISQL?

Cortex AISQL was the name Snowflake used when it announced its AI functions in SQL in June 2025. The documentation now calls them Cortex AI Functions. They include AI_COMPLETE, AI_CLASSIFY, AI_FILTER, AI_AGG, AI_SUMMARIZE_AGG and AI_SIMILARITY, and the core functions became generally available between November 2025 and January 2026.

Q: Which models can I use with AI_COMPLETE?

The list changes as Snowflake adds and retires models, and availability depends on your region. Older models such as llama2-70b-chat, Claude 3.5 Sonnet and, for new users, mistral-7b have been retired or made legacy. Check Snowflake's regional availability page and keep the model name in one place in your code.

Q: How many categories does AI_CLASSIFY need?

At least two distinct categories. Snowflake notes that more than about twenty categories can reduce accuracy.

Q: Can Snowflake AI functions process images?

Yes. AI_COMPLETE, AI_CLASSIFY, AI_FILTER and AI_SIMILARITY accept images passed as FILE objects with TO_FILE, and AI_SIMILARITY compares an image with another image.

Pranay Vatsal, Founder & CEO

Pranay Vatsal is the Founder & CEO of CelestInfo with deep expertise in Snowflake, data architecture, and building production-grade data systems for global enterprises.

Related Articles

Burning Questions
About CelestInfo

Simple answers to make things clear.

Our AI insights are continuously trained on large datasets and validated by experts to ensure high accuracy.

Absolutely. CelestInfo supports integration with a wide range of industry-standard software and tools.

We implement enterprise-grade encryption, access controls, and regular audits to ensure your data is safe.

Insights are updated in real-time as new data becomes available.

We offer 24/7 support via chat, email, and dedicated account managers.

Still have questions?

Get Assistance

Ready? Let's Talk!

Get expert insights and answers tailored to your business requirements and transformation.

Get Assistance