What you will be able to do
- Configure the guardrails option on COMPLETE and TRY_COMPLETE to filter unsafe model output
- Explain when TRY_COMPLETE returns NULL and design a pipeline that handles those rows
- Use CLASSIFY_TEXT with labelled, described categories to tag sensitive text
- Distinguish per-request Cortex Guard from account-level Cortex AI Guardrails configured through AI_SETTINGS
- Explain why responsible AI needs human review and LLM-as-a-judge evaluation as well as output filtering
Key concept
Governed AI execution — Cortex AI features don't sit outside Snowflake's security model. Snowflake roles and privileges decide who can call a function or agent and what data each tool can reach, so every safety control in this lesson sits on top of RBAC.
1.COMPLETE and the Cortex Guard option
SNOWFLAKE.CORTEX.COMPLETE sends a prompt to a model you choose and returns the generated text. Access is controlled by role: the caller must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. Note that the function is now legacy. Snowflake points new work at AI_COMPLETE and says COMPLETE will be deprecated by the end of 2026. The exam guide still names COMPLETE, so learn its options.
You configure content filtering in the optional third argument, options. This object holds the model's hyperparameters and the guardrails switch. When guardrails is TRUE, Cortex Guard filters potentially unsafe or harmful responses. When it is left out, it is FALSE, so an application that never sets it gets no Cortex Guard filtering at all.
Adding an options object changes how the call works, even if the object is empty. The prompt must then be an array of role/content objects in chronological order rather than a plain string. The return value also becomes a JSON string with choices, created, model and usage keys, unless you supply response_format. Plan for this before you add guardrails to existing code, because the parsing logic has to change too.
| Option | What it controls | Default |
|---|---|---|
| temperature | Randomness of output, 0 to 1 | 0 |
| top_p | Restricts the set of possible tokens, 0 to 1 | 0 |
| max_tokens | Maximum output tokens (maximum allowed 8192) | 4096 |
| guardrails | Filters unsafe and harmful responses using Cortex Guard (TRUE or FALSE) | FALSE |
| response_format | JSON schema the response should follow | Not set: response is a string |
Checkpoint 1 of 4· Check yourself
A developer adds {'guardrails': TRUE} as the options argument to an existing COMPLETE call that passed a plain-string prompt. What else must change?
Any options argument, even an empty one, switches the prompt to conversation-array form and changes the response format.
“If options is present, the argument must be an array of objects representing a conversation in chronological order.”Source: docs.snowflake.com
Responsible AI is wider than the guardrails switch. Cortex Guard filters potentially harmful output, but filtering does not prove an answer is correct. Snowflake says that the accuracy of LLM responses is not guaranteed and that you should review answers before serving them to your users. Responsible AI therefore combines three layers: filter output (Cortex Guard), keep access under RBAC, and measure quality. For the third layer, AI Observability supports the LLM-as-a-judge approach. An LLM judge scores an application's output between 0 and 1 and gives an explanation. Built-in metrics include context relevance, groundedness, answer relevance, correctness and coherence. Groundedness checks whether a response is supported by the retrieved context. Correctness checks alignment with a ground truth. Judge scores are evidence for a human reviewer. They do not replace review of sensitive responses. The sources listed here do not name bias or toxicity metrics, so don't assume those exist as built-in metrics.
2.TRY_COMPLETE: turning failures into NULL
TRY_COMPLETE has the same signature and the same options as COMPLETE, including guardrails. The difference is what happens on failure. COMPLETE raises an error. TRY_COMPLETE returns NULL. In a batch statement that runs an LLM over many rows, this means one bad row doesn't stop the whole job. Instead, it leaves a NULL that you can find later.
SNOWFLAKE.CORTEX.TRY_COMPLETE( <model>, <prompt_or_history> [ , <options> ] )| Aspect | COMPLETE | TRY_COMPLETE |
|---|---|---|
| Operation cannot be performed | Raises an error | Returns NULL |
| guardrails option (Cortex Guard) | Supported | Supported |
| Status | Legacy; start new work with AI_COMPLETE | Legacy; start new work with AI_COMPLETE |
To use filtered responses safely, treat a NULL from TRY_COMPLETE as a signal and never as an empty answer. Keep the generated column next to its input. Send rows where the result IS NULL to a review or retry path, and don't pass them to downstream consumers. The documentation says when NULL is returned: when the operation cannot be performed. It doesn't describe exactly what a Cortex Guard-filtered response looks like. So check your NULL handling and your guardrails handling separately, and don't assume one covers the other.
Checkpoint 2 of 4· Check yourself
A nightly job summarises 500,000 support tickets. The team wants rows the model cannot process to be flagged without failing the run. Which approach fits?
TRY_COMPLETE returns NULL instead of raising an error, so failed rows can be found and handled while the rest of the statement completes.
“Performs the same operation as the COMPLETE function but returns NULL instead of raising an error when the operation cannot be performed.”Source: docs.snowflake.com
Sources4
3.CLASSIFY_TEXT for sensitive-category tagging
Moderating model output is one half of the job. The other half is knowing which of your own text contains sensitive material. CLASSIFY_TEXT sorts free-form text into categories that you define, such as 'contains health data', 'contains payment details' and 'no sensitive content'. You then act on its output, for example by writing the label to a column or using it to decide which tag or masking treatment a record should get. Like COMPLETE, it is now legacy, and Snowflake directs new work to AI_CLASSIFY.
SNOWFLAKE.CORTEX.CLASSIFY_TEXT( <input> , <list_of_categories>, [ <options> ] )The category list must contain between 2 and 100 unique categories. Both the input and the categories are case sensitive, so 'PII' and 'pii' count as different labels, and the same text written with different capitalisation can be classified differently. Categories can be plain strings or objects. With objects, a required label can have an optional description of about one or two sentences and an optional list of examples (up to 20 per category). Snowflake says this context can improve accuracy. For sensitive-data tagging, where a wrong label decides what gets protected, that improvement matters.
The exam guide pairs classification with anomaly detection. The sources for this lesson document CLASSIFY_TEXT only and don't describe an anomaly-detection function, so that part isn't covered here.
Checkpoint 3 of 4· Match them up
Match each key of a CLASSIFY_TEXT category object to its rule
Tap a term, then the definition that fits it.
Only label is mandatory. Descriptions and examples are optional context that can improve classification accuracy.
“label: The name of the category. This key is required.”Source: docs.snowflake.com
Sources5
4.Cortex Guard is not Cortex AI Guardrails
Two controls have similar names, and the exam relies on the difference. Cortex Guard is the per-request guardrails option you just set on COMPLETE or AI_COMPLETE. It filters harmful model output for that one call. Cortex AI Guardrails is an account-level control. You configure it through the AI_SETTINGS parameter, and it applies at request time to CoCo, Snowflake CoWork and Cortex Agents. It detects prompt injection and jailbreak attempts, including indirect injection hidden in a tool's output. It does not apply to the Cortex REST API or to TruLens External Agents.
ALTER ACCOUNT SET AI_SETTINGS = $$
guardrails:
advanced_prompt_injection:
- enabled: true
$$;Only ACCOUNTADMIN can configure Cortex AI Guardrails. The feature also has a prerequisite: it is available only to Commercial accounts that have cross-region inference enabled, with CORTEX_ENABLED_CROSS_REGION set to one of the allowed values. Check the configuration with SHOW PARAMETERS LIKE 'AI_SETTINGS' IN ACCOUNT, and disable it with ALTER ACCOUNT UNSET AI_SETTINGS.
| Aspect | Cortex Guard | Cortex AI Guardrails |
|---|---|---|
| Where it is set | guardrails request parameter on built-in functions such as AI_COMPLETE | Account level, through AI_SETTINGS |
| What it does | Filters potentially harmful model output | Scans requests at run time; flagged scans are recorded |
| Where it applies | The individual function call | CoCo, Snowflake CoWork, and Cortex Agents |
| Where activity is recorded | Not described in these sources | CORTEX_AI_GUARDRAILS_USAGE_HISTORY |
Checkpoint 4 of 4· Check yourself
An administrator enables Cortex AI Guardrails with AI_SETTINGS and assumes this also protects an application that calls models through the Cortex REST API. Is that right?
Account-level guardrails cover CoCo, Snowflake CoWork and Cortex Agents only. REST API and TruLens External Agents are explicitly excluded.
“They do not apply to the Cortex REST API or TruLens External Agents.”Source: docs.snowflake.com
Sources6
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.COMPLETE filters harmful output by default, so no extra configuration is needed.Why is that wrong?
The guardrails option defaults to FALSE. Cortex Guard filtering only happens when you set it to TRUE in the options argument.
Covered in COMPLETE and the Cortex Guard option
2.Once Cortex Guard filters the output, the response is safe to serve without review, which is all responsible AI requires.Why is that wrong?
Filtering harmful content does not make an answer accurate. Snowflake says LLM accuracy is not guaranteed and that you should review answers before serving them.
Covered in COMPLETE and the Cortex Guard option
3.Setting guardrails: TRUE on AI_COMPLETE is the same as enabling Cortex AI Guardrails for the account.Why is that wrong?
The per-request Cortex Guard option is a separate control from account-level Cortex AI Guardrails, which you configure through AI_SETTINGS.
Covered in Cortex Guard is not Cortex AI Guardrails
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role.”
↩︎ COMPLETE and the Cortex Guard option“This legacy function will be deprecated by the end of 2026.”
↩︎ COMPLETE and the Cortex Guard option“Specifying the options argument, even if it is an empty object ({}), affects how the prompt argument is interpreted”
↩︎ COMPLETE and the Cortex Guard option“guardrails: Filters potentially unsafe and harmful responses from a language model using Cortex Guard. Either TRUE or FALSE. Default: FALSE”
↩︎ Prediction“If options is present, the argument must be an array of objects representing a conversation in chronological order.”
↩︎ Checkpoint - 2.
“You should review all answers from the Agents API before serving them to your users.”
↩︎ COMPLETE and the Cortex Guard option“Data access is governed by Snowflake privileges and the execution context of each configured tool.”
↩︎ Key concept“You should review all answers from the Agents API before serving them to your users.”
↩︎ Exam trap 2 - 3.
“an LLM is used to generate a score (between 0 and 1) with an explanation for the application’s output”
↩︎ COMPLETE and the Cortex Guard option - 4.
“Performs the same operation as the COMPLETE function but returns NULL instead of raising an error when the operation cannot be performed.”
↩︎ TRY_COMPLETE: turning failures into NULL“guardrails: Filters potentially unsafe and harmful responses from a language model using Cortex Guard. Either TRUE or FALSE. Default: FALSE”
↩︎ Exam trap 1 - 5.
“Classifies free-form text into categories that you provide.”
↩︎ CLASSIFY_TEXT for sensitive-category tagging“Must contain at least two and at most 100 unique categories.”
↩︎ CLASSIFY_TEXT for sensitive-category tagging“Using objects, you can provide a description and examples of each category, providing context that can help improve classification accuracy.”
↩︎ CLASSIFY_TEXT for sensitive-category tagging“For new use cases, start with AI_CLASSIFY, which is the canonical surface going forward.”
↩︎ CLASSIFY_TEXT for sensitive-category tagging“label: The name of the category. This key is required.”
↩︎ Checkpoint - 6.
“Users with the ACCOUNTADMIN role can configure Cortex AI Guardrails.”
↩︎ Cortex Guard is not Cortex AI Guardrails“The account parameter CORTEX_ENABLED_CROSS_REGION must be set to ANY_REGION, AWS_US, AWS_EU, AWS_JP, AWS_APJ, or AWS_GLOBAL.”
↩︎ Cortex Guard is not Cortex AI Guardrails
Also cited
“That per-request option is distinct from account-level Cortex AI Guardrails configured through AI_SETTINGS.”
↩︎ Exam trap 3“They do not apply to the Cortex REST API or TruLens External Agents.”
↩︎ Checkpoint