AI_COMPLETE

functiondeferredAI & MLpreview

docs.snowflake.com ↗

String & binary functionsFile functions

Generates a response (completion) from text, images, documents, audio, or video using a supported language model. The input types you can use depend on the model and on the interface. You can provide: - A text prompt, to generate a response from the model. For more information, see AI_COMPLETE (Single string). - A single file with a text prompt, to generate a response based on the file and prompt. For more information, see AI_COMPLETE (Single file). - A prompt object with text and one or more supported files. For more information, see AI_COMPLETE (Prompt object). For the file formats, size limits, and file counts that each model supports, see Model limitations for images, audio, and video, and Supported models and limitations for documents. You can also use your own text generation or vision-language model deployed as a Snowpark Container Services model inference service. Specify the service name as the model argument. For supported inputs, availability, prerequisites, access requirements, and limitations, see Bring-your-own model for AI_COMPLETE.

Error behavior

By default, if AI_COMPLETE can’t process the input, the function returns NULL. If the query processes multiple rows, rows with errors return NULL and don’t prevent the query from completing. The return value on error depends on the return_error_details argument. The following table shows the return value based on the return_error_details argument: return_error_details | Return value | Description FALSE Not passed | NULL | TRUE | OBJECT with value and error fields | value: The completion response (same type as the normal return value), or NULL if an error occurred. error: A VARCHAR value that contains the error message if an error occurred, or NULL if the function succeeded. For more information about error handling for AI functions, see Snowflake Cortex AI Function: Multirow error handling improvements.

Access control requirements

For Snowflake-hosted Cortex models, 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. For models deployed as Snowpark Container Services model inference services, see Access control requirements. Note AI_COMPLETE is the updated version of COMPLETE. For the latest functionality, use AI_COMPLETE.

Legal notices

Refer to Snowflake AI and ML for legal notices.

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.