In today’s generative AI era, organizations struggle to query databases without models hallucinating or leaking data to external APIs. Snowflake Cortex AI completely shifts this paradigm by bringing large language models directly into your secure data perimeter. By translating natural language into governed, precise data insights, it transforms Snowflake from a passive data repository into an active System of Intelligence—bridging the gap between complex schemas and non-technical business leaders.
The Snowflake Cortex AI Architecture
The Snowflake Cortex AI suite provides enterprise developers with serverless analytical capabilities designed to securely parse core corporate knowledge assets. Rather than using an ungrounded model to write arbitrary queries, components are tightly segmented by task complexity and structural demands.
| Module Name | What It Is | General Use |
|---|---|---|
| 1) Snowflake Copilot | An AI-powered assistant built into Snowflake worksheets. | Helps developers write, fix, and explain SQL queries. |
| 2) Document AI | An data extraction tool powered by multimodal machine learning. | Extracts specific data points from unstructured documents like PDFs and invoices. |
| 3) AI Studio & Observability | A hub for tracking and evaluating AI models. | AI studio will give you access to all AI features of Snowflake and Observability in Snowflake Cortex AI provides tracing, systematic evaluation, and monitoring to measure and optimize the behavior of Large Language Model (LLM) applications |
| 4) Cortex Agent | An orchestrator capable of multi-step planning and code execution. | Builds automated assistants that can run Python scripts or connect to external apps. |
| 5) Cortex Analyst | A semantic text-to-SQL engine for conversational analytics. | Allows business users to query structured databases using natural language. |
| 6) Cortex Search | A fully managed search service with built-in vector indexing. | Powers fuzzy search and Retrieval-Augmented Generation (RAG) across documents. |
| 7) AI and ML Functions | Serverless operators built directly into standard SQL rows. | Automates data tasks like text translation, forecasting, or sentiment analysis on the fly. |
| 8) Models | A secure registry of industry-leading open-weights foundation LLMs. | Provides access to advanced language models directly within Snowflake's security perimeter. |
Step-by-Step Guide: Create Cortex Agent with Cortex Analyst
Building an autonomous Cortex Agent requires a modular approach. Rather than relying on simple pattern-matching scripts, you create a robust reasoning loop that connects corporate semantic rules with optional specialized code execution.
Note on the Sample Dataset:
To ground these concepts in a realistic business scenario, the practical examples and configurations throughout this guide are based on a sample dataset from the downstream energy and fuel distribution domain. As you review the code snippets, semantic views, and agent instructions, you will see operational references to data points like fuel storage terminals, regional consumption metrics, and volume predictions.
Step 1: Initialize the Target Environment
Set your active compute warehouse and role contexts using a worksheet. Build or confirm the existence of a governance-compliant internal stage directory (@FUEL_OPS.PUBLIC.AGENT_SKILLS) to host all semantic configurations and skill assets.
Step 2: Establish the Structured Data Grounding (Semantic Layer)
Navigate to AI & ML --> Cortex Analyst inside the main Snowsight console tree or Select the Cortex Analyst from AI Studio.
Map physical tables, precise columns, column-level synonyms, and explicit database relationships inside a centralized configuration file.
To improve the accuracy and better suggestions, you can add verified queries to the semantic view in the same screen at the bottom section.
You can do all these settings in yaml file in any of the preferred editor and copy paste the configuration directly inside Semantic view.
A layout screenshot showing a custom YAML file structure inside a text editor or stage repository, highlighting the structural definitions for tables, relationships, and verified_queries configurations.
Save all the configuration settings from top right section. You can verify the semantic view operation from Playground window. This place will help you to make the semantic view perfect before you generate your agent.
Step 3: Instantiate the Cortex Agent Object
- Navigate to AI & ML --> Agents inside the main Snowsight console tree.
- Click + or Create Agent to spin up a new interface box.
- Assign your baseline identity strings: an Agent Object Name, a Display Name, and your context database scope (e.g., FUEL_OPS).
Step 4: Configuration & Prompts
Under the agent configuration panel, assign the agent display name and description which can be displayed in CoWork when you run your agent. You can also add some basic prompts which will help user to start the conversation related to that agent.
Step 5: Attach Your Cortex Analyst Semantic Tools
Select the Analyst or Structured Data Tool toggle inside the active tools grid. Point the tool resource lookup directly to the staged semantic .yaml path established during Step 2. Assign a dedicated virtual warehouse to handle the text-to-SQL processing tasks behind the scenes.
You can add a custom tools to add any specific operation you want your agent to follow in certain cases. This is similar in operation like MCP. e.g. I have created an email notification stored procedure to let agent know if someone ask to send an email on behalf of them, agent can do that.
CREATE OR REPLACE PROCEDURE FUEL_OPS.PUBLIC.SEND_PUMP_FAILURE_EMAIL("FAILING_TERMINAL" VARCHAR, "DETAILS" VARCHAR, "RECIPIENT" VARCHAR)
RETURNS VARCHAR
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS '
// 1. Configure the email notification integration
// Note: Ensure your Snowflake Admin has run: CREATE NOTIFICATION INTEGRATION my_email_int TYPE=EMAIL ALLOWED_RECIPIENTS=(''your-email@domain.com'');
var subject = "🚨 ALERT: Critical Pump Failure at " + FAILING_TERMINAL;
var body = "An automated incident has been triggered.\\n\\n" +
"Location: " + FAILING_TERMINAL + "\\n" +
"Failure Logs / Details: " + DETAILS + "\\n\\n" +
"Please dispatch a maintenance team immediately.";
try {
var sql_cmd = `CALL SYSTEM$SEND_EMAIL(''my_email_int'', ''${RECIPIENT}'', ''${subject}'', ''${body}'')`;
var statement = snowflake.createStatement({sqlText: sql_cmd});
statement.execute();
return "Success: Notification sent to " + RECIPIENT;
} catch (err) {
return "Failed to send email: " + err.message;
}
';
Step 6: Extend Capabilities with Skills or MCP Connectors (Optional)
Custom Skills: Upload an execution script (e.g. format_export.py) alongside an instructional markdown wrapper (e.g. SKILL.md) to a stage directory to handle specialized logic or formatting overrides.
This will let your agent do some additional capabilities while retrieving the response back to user. e.g. I have created a formatter using python script and SKILL.md file which will change the output of table response to specific format.
Model Context Protocol (MCP) Connectors: Connect the agent to an external tool repository or software-as-a-service platform by establishing a secure CUSTOM MCP SERVER connection profile within your workspace.
To make the connectors available, Snowflake has some inbuilt MCP connectors along with an option to add your own custom connector from Snowflake settings menu. Please refer below screen-shot.
Step 7: Finalize, Deploy, and Verify In CoWork
- Click the Save / Publish button in the top corner of the Agent Studio canvas.
- Open the Snowflake CoWork dashboard or the integrated CoCo side-chat companion panel to start testing queries.
- Select your newly created agent from the active dropdown menu.(as shown in below screenshot)
- Submit a natural language data prompt, and use the Show Trace utility to audit the logic path.
Sample output in Snowflake CoWork:
Step 8: Access Controls, Governance, and CoWork Interactivity
Once published, the agent becomes available to your organization within Snowflake CoWork and the integrated CoCo Panel chat workspace.
Open the CoWork interface on your dashboard, open the agent selector dropdown, and choose your active agent to start running queries.
Configuring Secure Access Controls (RBAC)
To share your agent with terminal managers or logistics coordinators, you manage access using Snowflake's role-based access control (RBAC). Execute these commands to grant access safely:
USE ROLE SECURITYADMIN;
-- Grant execution permissions on the specific operational agent
GRANT EXECUTE ON AGENT FUEL_OPS.PUBLIC.NEXUS_ENERGY_AGENT TO ROLE ENERGY_ANALYST_ROLE;
-- Ensure users have read access to the underlying data and components
GRANT USAGE ON DATABASE FUEL_OPS TO ROLE ENERGY_ANALYST_ROLE;
GRANT USAGE ON SCHEMA FUEL_OPS.PUBLIC TO ROLE ENERGY_ANALYST_ROLE;
GRANT READ ON STAGE FUEL_OPS.PUBLIC.AGENT_SKILLS TO ROLE ENERGY_ANALYST_ROLE;
Once assigned to the ENERGY_ANALYST_ROLE, users can log into their Snowflake CoWork workspace, select the agent, and securely run natural language queries against your energy data platform.
Additional capabilities and things to try out
1) You can build your own chatbot app on streamlit by using same semantic view. So you will be having full control over what to display, how to display, deployment etc.
2) You can use ML functions like FORECAST predict the future metric values from past trends in time-series data.
Here is the sample to train the forecasting model and then generate the forecast data and store it in a table for users questions prediction.
Sample question and response for Forecast model:


















Top comments (0)