AI and ML functions
These functions run AI and machine learning operations directly within your query, enabling LLM inference, custom model predictions, and AI-powered data enrichment at scale.AI and ML functions are currently available on Snowflake data planes only. They are not supported on AWS-hosted data planes.
AI_COMPLETE
Sends a prompt to a large language model and returns the response as a JSON string. UseAI_COMPLETE to enrich, classify, or extract structured data from text columns without leaving NQL.
Syntax:
Returns: STRING — A JSON string containing the model’s response.
When
show_details is TRUE, the returned JSON has this structure:
Because
AI_COMPLETE runs within your Snowflake data plane, your data never leaves your infrastructure. No external API calls are made to model providers. See Data Privacy in Model Inference for details.AI_COMPLETE can run, the customer’s Snowflake account must grant the Cortex role to the Narrative application and enable cross-region model access. See the data enrichment cookbook for the exact GRANT statements.
Common errors:
When to use
AI_COMPLETE vs a Model Inference job:
Related: Model Inference Overview, Structured Output, Data Enrichment Cookbook
CALL_MODEL_FUNCTION
Invokes a function on a custom model registered in the Snowflake ML Model Registry. UseCALL_MODEL_FUNCTION to run predictions, embeddings, or other operations from your own trained models directly within NQL.
Syntax:
Returns: STRING — A JSON string containing the model function’s output.
The return format depends on the model’s function signature. Custom models typically return JSON objects:
NULL:
Related content
Data Enrichment with AI
Complete cookbook for enriching data using AI_COMPLETE
Model Inference
How AI inference works within your data plane
Structured Output
JSON Schema for predictable AI responses
All Functions
Browse all function categories

