Categories:

String & binary functions (AI Functions) , File functions (AI Functions)

AI_COMPLETE

Note

AI_COMPLETE is the updated version of COMPLETE (SNOWFLAKE.CORTEX). For the latest functionality, use AI_COMPLETE.

Generates a response (completion) from text or an image using a supported language model. You can provide:

Syntax

The syntax for the function depends on the type of input that you provide. For information about the syntax, see the following sections:

Access control requirements

Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. See Cortex LLM privileges for more information on this privilege.

Error handling

By default, an AI_COMPLETE stops running when there’s an error on a row. This behavior can disrupt large batch operations where an error can stop all processing. With error handling enabled, AI_COMPLETE can return NULL or an error object for rows that encounter non-fatal errors, while continuing to process other rows.

Use the following code to enable error handling for your session:

ALTER SESSION SET AI_SQL_ERROR_HANDLING_USE_FAIL_ON_ERROR=false;
Copy

For more information about error handling, see the following sections:

Limitations

Snowflake Cortex functions do not support dynamic tables.

Language: English