AI Functions on Databricks


This feature is in Public Preview.

This article describes Databricks AI Functions, built-in SQL functions that allow you to access and serve Large Language Models (LLMs) directly from SQL.



The ai_generate_text() function calls an LLM selected by the user with the given prompt and returns the text generated by the model. Returns text generated by a selected large language model (LLM) given the prompt. Users can set additional parameters to control the behavior. Currently Databricks supports calling ChatGPT from OpenAI and Azure OpenAI Service.


The ai_query() function allows you to serve your large language models using Databricks Model Serving and query them. To do so, this function invokes an existing Databricks Model Serving endpoint and parses and returns its response.