AI_EXTRACT, Cortex Code & the ML Functions
AI_EXTRACT turns documents into columns. Safia's supplier invoices arrive as PDFs in a stage, and one function call pulls the fields she names, each as a plain-English question in the responseFormat argument (a JSON schema works too, for lists and tables):
SELECT relative_path, AI_EXTRACT(file => TO_FILE('@invoice_stage' , relative_path), responseFormat => [['vendor', 'Who is the vendor?'],['amount', 'What is the total amount due?'],['due_date', 'What is the due date?']]) AS fieldsFROM DIRECTORY(@invoice_ stage);
The output is JSON per document, with your field names under response, and it lands in the semi-structured pipeline from Part 6: path notation, casts, FLATTEN. Notice the supporting cast, a directory table listing the files and TO_FILE handing each one to the function. AI_EXTRACT bills by tokens, with each page counted as a fixed number of tokens. Until March 2026 this job took a Document AI model build, trained on labeled examples in Snowsight and called with !PREDICT; Snowflake retired both. When you need a document's full text rather than named fields, for example to chunk it for Cortex Search, use AI_PARSE_DOCUMENT: OCR mode returns plain text, LAYOUT mode returns Markdown that keeps headings and tables.
Cortex Code (the docs also call it CoCo) replaced the deprecated Snowflake Copilot as the assistant built into Snowsight. Alice asks for "top 10 customers by revenue last quarter, exclude internal accounts"; it drafts the SQL, shows the change before she applies it, and can run it, explore objects, or work in notebooks and dbt projects. It's an agent, not just a drafter, and the guard rail is role-based access control: it only performs actions her active role permits. Her role needs SNOWFLAKE.CORTEX_USER or the narrower SNOWFLAKE.CORTEX_AGENT_USER. Universal Search is smaller: natural-language lookup across your objects, Marketplace listings, and documentation. It finds the table Marc mentioned; it doesn't query it.
The classic ML functions
Before LLMs, Snowflake shipped statistical ML as SQL, and it's still there under SNOWFLAKE.ML. You create a model object from historical data, then call it. Forecasting projects a time series forward, anomaly detection flags points that break the pattern, classification assigns labels from training examples. These train and predict on your warehouse, not on AI credits, which is the billing distinction to remember. Big training jobs can run out of memory on a standard warehouse: for anomaly detection on one series beyond about 5 million rows, Snowflake suggests a Snowpark-optimized warehouse, Part 2's memory rule.
-- Thomas forecasting daily order volume 14 days outCREATE SNOWFLAKE.ML. order_FORECAST forecast( INPUT_DATA => TABLE(SELECT order_date, order_count FROM daily_orders), TIMESTAMP_COLNAME => 'order_date', TARGET_COLNAME => 'order_ count' );CALL order_forecast!FORECAST( FORECASTING_ PERIODS => 14);
Which AI tool do I reach for?
Score, classify, translate text
AI functionsAI_SENTIMENT, AI_CLASSIFY…BILLED AS tokens + warehouse
Write anything from a prompt
AI_COMPLETEyou pick the modelBILLED AS tokens + warehouse
Chat over company documents
Cortex Search+ AI_COMPLETEBILLED AS GB-month + tokens
Plain-language questions on tables
Cortex Analystsemantic viewBILLED AS per message + warehouse
Pull fields out of PDFs
AI_EXTRACTreplaces Document AIBILLED AS tokens
Help a person write SQL
Cortex Codeacts as your roleBILLED AS warehouse when run
Forecast, spot anomalies
ML functionsFORECAST, ANOMALY_
Name the job and the tool follows. Text in a column: AI functions, one call per row (AI_AGG for a whole group). Passages from documents: Search. Numbers from tables in plain language: Analyst. Fields out of documents: AI_EXTRACT. Help writing SQL: Cortex Code. Forecasts and anomalies: ML functions. Finding objects: Universal Search. Every AI scenario question resolves to one of these sentences.

