snowflake-cortex-ai
Installation
SKILL.md
Snowflake Cortex AI
This skill covers Snowflake Cortex — the SQL-callable AI layer of Snowflake, including Cortex AI Functions for LLM/ML tasks and Cortex Search for managed hybrid (vector + keyword) search — all running inside Snowflake with no data leaving the platform.
Workflow for Building a Cortex-Powered Feature
- Pick the narrowest function for the task — Use
AI_CLASSIFYfor categorization,AI_FILTERfor natural-language row filtering,AI_EXTRACTfor structured field pulls, and reserveAI_COMPLETEfor open-ended generation — narrower functions are cheaper and more reliable than routing everything throughAI_COMPLETE. - Check token cost before batch jobs — Run
AI_COUNT_TOKENS(model, text)on a sample before running a function over a large table. - Prototype in SQL — Call the function on a small
LIMIT-ed sample and inspect results before running it over a full table. - Structure prompts explicitly — Use
PROMPT('template {0}', arg)for parameterized prompts and cast JSON output toVARIANTwhen you need structured fields back. - For RAG, stand up Cortex Search — Create a
CORTEX SEARCH SERVICEover the source table, query it via the Python or REST API to retrieve context, then pass that context intoAI_COMPLETE. - Use dedicated compute — Size Cortex Search's backing warehouse no larger than MEDIUM, and separate it from other pipeline warehouses.
- Guard against failures — Use
TRY_COMPLETEin place ofAI_COMPLETEfor batch jobs where a single failure shouldn't fail the whole run; it returnsNULLinstead of raising an error.
Cortex AI Functions
Available functions (use these current names — do not use deprecated names like COMPLETE or CLASSIFY_TEXT):