TL;DR
Databricks AI Functions call a large language model directly from a SQL query, skipping the endpoint deployment and API key management that used to sit between a table and a model. More than 20 task-specific functions cover classification, translation, summarization, sentiment, extraction, masking, grammar correction, parsing, forecasting and search, plus ai_query for anything outside that set, all governed by Unity Catalog. The catch: cost scales with token volume and compute time, and functions like ai_translate remain in public preview even as ai_query, ai_classify, and ai_extract reached general availability. This blog covers how AI Functions work, cost, governance, and a real Kanerika deployment.
Databricks AI Functions turn a large language model into a callable SQL function, skipping the endpoint deployment, the API key management, and the separate service that used to sit between a table and a model. More than 20 task-specific functions ship ready to call today, covering classification, translation, summarization, sentiment, extraction, masking, grammar correction, document parsing, forecasting and search, plus ai_query for anything the task-specific set skips.
Teams still writing a Python service to call OpenAI or Claude from inside a Databricks pipeline are duplicating work AI Functions already do natively, governed by Unity Catalog the same way a table is. This guide covers how AI Functions work, which function fits which job, practical applications, cost and governance, and what it takes to run them at scale. It closes with a real Kanerika deployment on Databricks.
Key Takeaways AI Functions call LLMs directly from SQL, notebooks, Lakeflow pipelines, and Workflows, with zero endpoint management for Databricks-hosted models. More than 20 task-specific functions cover the common jobs out of the box. ai_query handles custom prompts and external models. AI Functions need Databricks Runtime 15.4 LTS or above, with 18.2 recommended, and do not run on Classic SQL warehouses. Region and model availability vary by cloud. ai_query, ai_classify, and ai_extract reached general availability in June 2026. Other functions, including ai_translate, remain in public preview. Unity Catalog governs execution through the system.ai schema, down to the individual function. Kanerika rebuilt a sales intelligence platform’s document processing on Databricks workflows, cutting processing time by 80%.
Modernize Your Data Pipelines with Databricks AI Functions! Partner with Kanerika for Expert Databricks Consulting Services
Book a Meeting
What Are Databricks AI Functions AI Functions apply AI models to data stored on Databricks using SQL and PySpark syntax, for tasks like translation, classification, and sentiment scoring. They run from Databricks SQL, notebooks, Lakeflow Declarative Pipelines, and Workflows, per the Databricks documentation on AI Functions .
Databricks introduced AI Functions to close a specific gap. Data teams already had the data, the compute, and the governance layer in Unity Catalog.
Applying an LLM to that data used to mean leaving the platform, standing up an external call, and reconciling the output back into a table. AI Functions fold that entire round trip into a single function call, the same efficiency principle behind Kanerika’s broader generative AI work .
UPPER() and LENGTH() run pure computation, independent of any external service.
AI Functions work differently. They route a request to a foundation model, either Databricks-hosted or external, and parse the response into a structured column value, which is what separates an AI Function from a traditional SQL function underneath the identical syntax.
How Databricks AI Functions Work A query calls the function, the function passes the relevant column data and a task definition, or a custom prompt for ai_query, to a model serving endpoint, and the response returns as a typed column.
Databricks handles batching, retries, and parallelization behind that flow automatically, so a query against ten rows and one against ten million rows use identical syntax. Runtime and cost carry the difference, while the query itself stays the same either way.
A single line replaces what used to take a full service to build.
sql
SELECT
ticket_id,
ai_analyze_sentiment(customer_message) AS sentiment,
ai_classify(customer_message, ARRAY('billing', 'technical', 'shipping', 'other')) AS category
FROM support_tickets;Unity Catalog sits underneath this entire flow, governing which users and service principals can execute which functions against which data. That governance layer separates AI Functions from a raw API call bolted onto a pipeline, since permissions, lineage, and audit logging apply the same way they do for a standard table query.
Teams already running Kanerika’s data governance engagements on Databricks find AI Functions slot into an access model that already exists.
Key Features of Databricks AI Functions 1. Native SQL Integration AI Functions drop into a SELECT statement the same way any built-in function does. A data analyst writing routine SQL adds a sentiment score or a translated column without switching languages or involving a separate data engineering team to build the plumbing first.
2. Built-In Large Language Models Databricks hosts foundation models optimized for AI Functions, including databricks-gpt-oss-20b and databricks-gpt-oss-120b , with endpoints created automatically and the provisioning step skipped entirely. This model serving layer runs on the same infrastructure Databricks uses across its broader model deployment stack, the same performance layer behind engines like Photon.
3. Structured Data Extraction and Classification ai_extract and ai_classify turn unstructured text into structured fields, pulling named entities from a contract or sorting a support ticket into a category, directly inside a query. Both functions moved to a v2 signature in March 2026 with improved accuracy and native composability with ai_parse_document for end-to-end document workflows.
4. Translation, Sentiment, and Summarization ai_translate, ai_analyze_sentiment, and ai_summarize cover three of the most common enrichment tasks in customer-facing data, each callable with a single argument beyond the input column.
5. Enterprise Governance Through Unity Catalog Every AI Function call inherits Unity Catalog’s permission model. By default, all users hold execute access through the system.ai schema, which opens every supported function to every user.
Admins needing tighter control revoke that default and re-grant execute permission function by function, mapping to the same access-by-risk approach Kanerika applies in its AI governance engagements .
Together, these five features close the two biggest gaps in AI adoption for data teams, the need for a second toolchain and the governance gap between the data platform and the AI layer.
Types of Databricks AI Functions Databricks groups AI Functions into one general-purpose function and a set of task-specific functions built for common jobs.
Table 1: Databricks AI Functions Reference
Function Purpose Example Call ai_query Custom prompt against any supported model ai_query(‘model-name’, prompt) ai_classify Sorts text into labels you define ai_classify(text, ARRAY(‘label1’, ‘label2’)) ai_extract Pulls named fields from unstructured text ai_extract(text, ARRAY(‘vendor’, ‘amount’, ‘date’)) ai_translate Translates text to a target language ai_translate(text, ‘es’) ai_summarize Condenses text to a target word count ai_summarize(text, 40) ai_analyze_sentiment Scores sentiment as positive, negative, mixed, or neutral ai_analyze_sentiment(text) ai_mask Redacts named entity types ai_mask(text, ARRAY(‘person’, ’email’, ‘phone’)) ai_parse_document Extracts text and structure from PDFs ai_parse_document(file_content) ai_fix_grammar Corrects grammar in input text ai_fix_grammar(text) ai_forecast Projects a time series forward ai_forecast(table_name, horizon)
ai_translate currently supports a fixed set of target languages, including Spanish, German, French, Italian, Portuguese, Hindi, and Thai. Confirm the current list against the official documentation before building a translation pipeline around it, since supported languages and functions both expand over time.
ai_query for Custom Prompts and External Models ai_query is the function to reach for when a task-specific function falls short, when a prompt needs custom wording, or when the model lives outside Databricks entirely. It supports Databricks-hosted models, provisioned throughput endpoints, and external models like OpenAI’s API, all through the same call signature.
sql
SELECT ai_query(
'fraud-model-v3',
named_struct('transaction_amount', amount, 'merchant_category', category, 'account_age_days', account_age),
returnType => 'FLOAT'
) AS fraud_score
FROM transactions;Task-Specific Functions for Common Jobs Databricks recommends starting with a task-specific function whenever one matches the objective, since these functions carry pre-tuned prompts maintained by Databricks and skip the trial-and-error of writing a custom instruction. ai_classify, ai_extract, and ai_parse_document cover the bulk of enrichment work data teams handle day to day.
Mixing both inside one pipeline is common in practice. A document ingestion job might call ai_parse_document to extract raw text, then ai_query with a custom prompt to score that text against a business-specific rubric that falls outside every task-specific function.
Complete List of Databricks AI Functions in 2026 Check the function list before you design a pipeline, because the right built-in function saves you from writing and testing a prompt. The AI Functions documentation lists 21 task-specific functions plus ai_query, grouped by the job each one does.
That is more than twice the nine task-specific functions in Table 1 above. Nine of the 21 carry a Beta label on the docs index. Pilot those first, and keep them out of unattended production jobs until the label changes.
All 21 Task-Specific Functions by Task Group Table 2: AI Functions by Task Group
Function Task group What it does Maturity label ai_parse_document Document processing Parses text, tables, figure descriptions and layout from files None ai_extract Document processing Pulls the fields you define in a schema from documents or text None ai_classify Document processing Sorts text into labels you provide None ai_prep_search Document processing Turns parsed documents into search-ready chunks for RAG Beta ai_search Document processing Returns ranked documents and a grounded answer to a question Beta ai_enrich Document processing Generates new columns for each row from a schema you define Beta ai_transcribe Audio Transcribes audio with timestamps and optional speaker labels Beta ai_fix_grammar Transform text Corrects grammar Public Preview ai_translate Transform text Translates text into a target language Public Preview ai_summarize Transform text Summarizes text Public Preview ai_mask Transform text Masks entity types such as names and email addresses Public Preview ai_decide Analyze text Scores questions against text or data as probabilities, choices or scores Beta ai_analyze_sentiment Analyze text Labels the sentiment of text Public Preview ai_similarity Analyze text Scores the semantic similarity of two strings Public Preview ai_gen Generate content Answers a prompt with a model Databricks picks Public Preview ai_predict_class Predict outcomes Trains a classifier and fills rows where the target is NULL Beta ai_predict_value Predict outcomes Trains a regression model and predicts missing numeric values Beta ai_forecast Forecast time series Projects a time series forward to a horizon Public Preview (version 2 in Beta) ai_detect_anomalies Forecast time series Flags anomalous values with expected values and bounds Beta ai_top_drivers Analyze metric changes Ranks the dimension values behind a metric change between two groups Beta vector_search Search Queries an AI Search index of embeddings from SQL Public Preview
Check Maturity Labels Before Production The docs index tells only half the story. On the reference pages, nine of the twelve untagged functions still show a Public Preview banner. They include ai_translate, ai_summarize, ai_mask, ai_gen and vector_search. Only ai_parse_document, ai_extract and ai_classify show no banner, and ai_extract and ai_classify reached general availability in June 2026.
Preview status matters most for jobs that run unattended, because preview behavior and regional coverage can still change. A contract pipeline built on ai_parse_document and ai_extract stands on the most settled ground today. A nightly translation job on ai_translate should carry a fallback and a date to recheck the label.
ai_similarity for Semantic Matching and Deduplication ai_similarity compares two strings and returns a FLOAT that shows how close they are in meaning. A score of 1 means the strings are identical. The ai_similarity reference treats the score as relative, so use it to rank rows.
Deduplication is the typical job. A CRM table might hold the same company under four spellings. Ranking every row against one reference name surfaces the likely matches for review.
SELECT
company_name
FROM
customers
ORDER BY ai_similarity(company_name, 'Databricks') DESC
LIMIT 10;Each comparison is a model call, so pairwise scoring gets expensive across millions of documents. Large semantic search jobs belong on an embedding index, which our guide to Databricks Vector Search covers.
ai_gen for Prompt-In, Text-Out Generation ai_gen takes a single prompt and returns a STRING, with Databricks choosing the model behind it. It suits quick generation work, such as drafting a short answer for each question in a table, as the ai_gen reference shows.
SELECT question, ai_gen('You are a teacher. Answer the students question in 50 words: ' || question) AS answer FROM questions LIMIT 10;Switch to ai_query when you need to pick the model, set parameters such as temperature, or force the answer into a schema. The shorter ai_gen call gives up that control.
Some jobs need a model that plans several steps, calls tools and checks its own output. A single SQL function is the wrong shape for that work, which is what Databricks Agent Bricks is built for.
Why Data Teams Are Adopting Databricks AI Functions 1. Faster Development With Less Custom Code A team that previously wrote a Python service to call an external LLM, parse the response, and write it back to a table can replace that entire service with a SQL statement. The maintenance surface drops from an application to a query, the same reduction in build time Kanerika targets across its broader AI consulting work.
2. Unified Analytics and AI in One Platform Data engineers, analysts, and data scientists work against the same tables using the same governance model, whether the task is a standard aggregation or an AI-driven enrichment. That consistency pays off as AI use cases multiply across a data estate, tracked over time the same way MLflow tracks model experiments on Databricks, covered in Kanerika’s guide to model lifecycle management .
3. Enterprise Security at the Function Level Because AI Functions inherit Unity Catalog permissions, security teams gain a single control point for both data access and model access, rather than managing API keys and service accounts across a separate AI stack.
Databricks Unity AI Gateway (2026): Configuration and Governance Guide Databricks Unity AI Gateway governs AI agents, guardrails, and spend at runtime. See how the four pillars work and configure it for enterprise use.
Learn More
AI Functions in Production Data Workflows 1. Customer Email Routing A logistics company routes inbound customer emails that used to run through a rules-based keyword filter, which misclassified anything phrased unusually. ai_classify sorts each message into delivery status, damage claim, billing question, or general inquiry, then sends it to the right queue, the same category of work Kanerika covers in its intelligent automation practice.
2. PII Redaction Before Data Sharing A financial services firm strips names, emails, and account numbers from free-text customer service notes before that data leaves the governed environment. ai_mask handles the redaction inside the query itself, the same job Kanerika’s Susan agent is purpose-built for outside a SQL context.
3. Review Summarization at Scale A retail chain summarizes thousands of product reviews every week. ai_summarize condenses each review to a fixed word count, and ai_analyze_sentiment scores it in the same pass, giving the retail and FMCG merchandising team a queryable table instead of a folder of raw text.
4. Supplier Contract Extraction A manufacturing team used to read hundreds of supplier PDFs by hand to pull pricing tiers, delivery terms, and penalty clauses. Chaining ai_parse_document into ai_extract turns that stack into a structured table analysts compare across vendors within minutes, close to the pattern in Kanerika’s vendor agreement processing case study .
5. Intake Form Processing A healthcare operations team pulls patient ID, visit reason, and referring physician from scanned intake documents the same way, feeding a structured table instead of a stack of PDFs nobody queries directly.
6. Claims Volume Forecasting An insurance company projects claims volume forward from historical data using ai_forecast, giving planning teams a baseline without a separate forecasting model to build and maintain outside the warehouse, the same forecasting pattern Kanerika’s predictive analytics practice covers in more depth.
7. Documentation Localization A SaaS company runs ai_translate against its documentation table to produce localized versions in each supported target language, keeping the source table as the single point of truth instead of maintaining separate translated repositories by hand.
Databricks AI Functions SQL Examples: Five Production Patterns Calling one function is easy. The harder part is packaging those calls so they keep working on a schedule. That means typed output, controlled access and inputs that arrive as files.
These five patterns cover the jobs that come up most when AI Functions move from a notebook into a pipeline. Each one uses syntax from the current Databricks reference pages, so you can paste it and swap in your own tables.
1. Enforce Structured Output With responseFormat Free-text answers are hard to load into typed columns. The responseFormat argument of ai_query makes the model return JSON that matches a schema you supply. You can write that schema as a DDL STRUCT string or as a json_schema object with strict set to true.
It needs Databricks Runtime 15.4 LTS or above and works with chat models only. The example below pulls a title, authors and keywords out of research paper abstracts.
SELECT ai_query(
"system.ai.gpt-oss-20b",
"Extract research paper details from the following abstract: " || abstract,
responseFormat => 'STRUCT<research_paper_extraction:STRUCT<title:STRING, authors:ARRAY<STRING>, abstract:STRING, keywords:ARRAY<STRING>>>'
)
FROM research_papers;Every row now returns the same fields in the same order. A downstream job can parse the result into columns without guessing at the shape of each answer.
2. Wrap ai_query in a Reusable SQL UDF Prompts copied into dozens of queries drift apart over time. Wrapping the call in a SQL user-defined function keeps one tested prompt in one place. Unity Catalog then controls who may run it through GRANT EXECUTE.
CREATE FUNCTION correct_grammar(text STRING)
RETURNS STRING
RETURN ai_query(
'system.ai.meta-llama-3-3-70b-instruct',
CONCAT('Correct this to standard English:\n', text));
GRANT EXECUTE ON correct_grammar TO ds;
SELECT
* EXCEPT text,
correct_grammar(text) AS text
FROM articles;Analysts call correct_grammar like any built-in function and never see the prompt behind it. When the prompt improves, one change to the function updates every query that uses it.
3. Send Images From a Unity Catalog Volume ai_query also accepts files. Pass the binary content column from READ_FILES through the files argument, and a multimodal model describes or classifies each image. The reference lists JPEG and PNG as the supported image types.
SELECT *, ai_query(
'system.ai.llama-4-maverick',
'what is this image about?', files => content)
AS output FROM READ_FILES("/Volumes/main/multimodal/unstructured/image.jpeg");Point the path at a folder in the Volume to describe a whole batch of product photos or scanned forms in one query.
4. Redact PII With ai_mask Before Sharing Data Support transcripts and notes often carry names, emails and phone numbers that should never reach a shared table. The ai_mask function replaces each entity type you name with [MASKED] and leaves the rest of the text intact.
SELECT ai_mask(
'John Doe lives in New York. His email is [email protected] .',
array('person', 'email')
);
-- Returns: "[MASKED] lives in New York. His email is [MASKED]."A NULL input returns NULL, so count NULLs before you trust a masked column. Regulated data usually needs a policy layer as well, and our roundup of data masking tools compares the options.
5. Ingest Documents With ai_parse_document and ai_extract Contracts, invoices and claims arrive as files. The ai_parse_document function turns each file into structured text and layout, and ai_extract then pulls the fields you define from that parsed output.
The ai_parse_document reference lists PDF, JPG/JPEG, PNG, TIFF, DOC/DOCX and PPT/PPTX as supported formats. It needs Databricks Runtime 17.3 or above, a higher floor than the 15.4 LTS the other functions need. Read the files with the binaryFile format so the function receives raw bytes.
WITH parsed_docs AS (
SELECT
path,
ai_parse_document(
content,
MAP('version', '2.0')
) AS parsed_content
FROM READ_FILES('/Volumes/finance/invoices/', format => 'binaryFile')
)
SELECT
path,
ai_extract(
parsed_content,
'["invoice_id", "vendor_name", "total_amount"]',
MAP('version', '2.1', 'instructions', 'These are vendor invoices.')
) AS invoice_data
FROM parsed_docs;Whichever pattern you use, land the output in a Delta table with the endpoint name and the run date as columns. Then a new model or prompt can be compared with last month’s run on the same rows.
Kanerika recommends storing AI Functions output this way on Databricks engagements, so a model change is judged on stored results instead of memory.
How Databricks AI Functions Compare to Traditional AI Development Factor Databricks AI Functions Traditional AI Development SQL Integration Direct, native function calls Requires a separate application layer Infrastructure Managed by Databricks Self-managed endpoints and scaling Governance Inherited from Unity Catalog Built and maintained separately Time to Production Days, in many cases Weeks to months Model Flexibility Databricks-hosted, custom, and external models via ai_query Full flexibility, at the cost of setup time
The tradeoff runs in both directions. A team needing deep customization outside what a model serving endpoint supports still reaches for custom development.
For the batch enrichment and classification work most teams need, AI Functions close the gap in a fraction of the time. Most Databricks shops running AI Functions in production still keep a handful of traditional deployments for latency-sensitive or highly customized workloads, and route everything else through AI Functions to keep the maintenance surface small.
Databricks AI Functions vs Snowflake Cortex AI Functions Both platforms now let an analyst call a language model from SQL, so the choice usually follows where the data already lives. The two function sets overlap on classification, extraction, translation, sentiment and summarization.
The differences sit in access control, billing units and a few functions that only one side offers. Snowflake documents its set in the Cortex AI Functions guide , with models from OpenAI, Anthropic, Meta, Mistral AI, DeepSeek and xAI in select regions.
Table 3: Databricks vs Snowflake Cortex AI Functions
Dimension Databricks AI Functions Snowflake Cortex AI Functions Function family 21 task-specific functions plus ai_query AI_COMPLETE, AI_CLASSIFY, AI_FILTER, AI_AGG, AI_EMBED, AI_EXTRACT, AI_SENTIMENT, AI_TRANSLATE, AI_PARSE_DOCUMENT and others General-purpose call ai_query AI_COMPLETE Distinctive functions ai_forecast, ai_top_drivers, ai_predict_class, vector_search (Snowflake keeps forecasting in separate ML Functions) AI_FILTER, AI_AGG, AI_SUMMARIZE_AGG Access control Unity Catalog EXECUTE grants, down to the single function USE AI FUNCTIONS account privilege plus the CORTEX_USER or AI_FUNCTIONS_USER database role Billing unit DBUs, metered per token or per hour Credits per million tokens; AI_PARSE_DOCUMENT billed per page Cost views system.billing.usage METERING_DAILY_HISTORY and CORTEX_AI_FUNCTIONS_USAGE_HISTORY Compute note No Classic SQL warehouses; Databricks Runtime 15.4 LTS or above Warehouse cost still applies; a warehouse no larger than MEDIUM is recommended
Billing is where teams feel the gap first. Snowflake charges text-generating functions for input and output tokens and adds normal warehouse cost, as its AI Functions cost guide explains. Databricks records inference under its own billing products, covered in the cost section below.
Which Platform’s AI Functions Fit When Pick Databricks AI Functions when your tables and permissions already live in Unity Catalog. They also fit jobs that mix LLM enrichment with forecasting, metric-driver analysis and vector search in one SQL function family.
Pick Snowflake Cortex when the data already sits in Snowflake. AI_FILTER and AI_AGG let analysts filter and aggregate text in plain SQL, which suits reporting-heavy teams.
Moving data across platforms only to reach one function rarely pays for itself. Teams weighing the wider platform question can start with our Databricks vs Snowflake comparison. Teams already on Snowflake can review Snowflake Cortex costs in production before they scale.
Best Practices for Production AI Functions 1. Write Structured, Specific Prompts A vague ai_query prompt produces inconsistent output across rows. A structured prompt with an explicit format and constraints produces output that behaves the same way every time, which counts once a job runs unattended on a schedule.
2. Submit the Full Dataset in One Query Splitting a dataset into small manual batches before calling an AI Function slows the job down. Databricks handles parallelization and retries automatically when the full dataset is submitted in a single query.
3. Set failOnError to False on Large Batch Jobs A single malformed row can stop an entire batch job if failOnError stays at its default. Setting it to false returns an error message for that row and lets the rest of the job complete, a difference that counts most on jobs processing millions of rows overnight.
4. Filter the Table Before You Call the Function Cost scales with token volume and compute time together. Running a function against an entire table when only a filtered subset needs enrichment multiplies spend without improving the output analysts use.
Cost itself tracks two things together. Databricks Unit consumption from the compute running the query, and the underlying model serving cost for tokens processed, both feed the total bill.
Model serving on Databricks offers pay-per-token pricing for prototyping and variable-volume work, and provisioned throughput for production workloads needing guaranteed capacity, according to CloudZero’s breakdown of Databricks pricing .
A batch job against a Databricks-hosted model on pay-per-token billing generally costs less per token than the same volume of real-time calls, since batch inference skips the overhead of a warm endpoint sitting idle between requests.
Source: Databricks Limitations to Consider 1. Token Cost and Latency Grow With Input Size A function called on every row of a large table behaves very differently from the same function filtered to a small, high-value subset. Cost and latency both scale with volume, and that scaling stays linear regardless of warehouse size.
2. Model Accuracy Still Needs Human Review Hallucination risk exists regardless of platform. Output headed for a compliance decision or a customer-facing surface still needs a review step before it ships, the same discipline any LLM-backed system requires.
3. Task-Specific Functions Trade Flexibility for Simplicity A task-specific function carries a pre-tuned prompt maintained by Databricks, which is the entire point, though tuning that function for an unusual edge case sits out of reach. ai_query is the answer once a task-specific function’s fixed behavior stops fitting the job.
4. Rollout Status Still Varies by Function Maturity differs across the function set. ai_query, ai_classify, and ai_extract reached general availability in June 2026 , while functions such as ai_translate remain in public preview.
Region coverage and the supported function list keep expanding, so a rollout plan built around today’s exact feature set should include a recheck against current documentation before the production launch date.
How Much Do Databricks AI Functions Cost? Billing, Monitoring and a Worked Example Most AI Functions jobs carry two cost lines, and a budget that counts only one of them comes in low. You pay for the compute that runs the query, whether that is a SQL warehouse, a cluster or a pipeline.
Most task-specific functions also bill model inference on top, because they run on Databricks-managed serverless GPUs through Model Serving. The sections below show what gets billed, where it lands and what a real volume might cost.
What Gets Billed The AI Functions documentation sorts functions into billing groups. The table shows which ones add inference charges and where each one appears in the billing system table.
Table 4: How Databricks AI Functions Are Billed
Function group Inference billed separately? Recorded under ai_classify, ai_extract, ai_parse_document, ai_search Yes AI_FUNCTIONS ai_similarity, ai_analyze_sentiment, ai_summarize, ai_translate, ai_fix_grammar, ai_mask Yes MODEL_SERVING, offering type BATCH_INFERENCE ai_query Yes, for the endpoint you name Usage of that serving endpoint ai_forecast, ai_detect_anomalies, ai_predict_class, ai_predict_value, ai_top_drivers No Query compute only
Query compute applies to every row of this table. The forecasting and prediction functions simply add no separate inference line on top of it.
Track AI Function Spend in system.billing.usage The billing system table records both inference groups, so a query per product shows where the money goes. Start with the AI_FUNCTIONS product, then add the documented product_features filter to isolate one function such as AI_PARSE_DOCUMENT.
-- AI_FUNCTIONS product usage for one workspace
SELECT *
FROM system.billing.usage u
WHERE u.workspace_id = <workspace_id>
AND u.billing_origin_product = "AI_FUNCTIONS";
-- To narrow it to one function, add:
-- AND u.product_features.ai_functions.ai_function = "AI_PARSE_DOCUMENT"
-- Batch inference usage from task-specific functions, joined to jobs
SELECT *
FROM system.billing.usage u
JOIN system.workflow.jobs x
ON u.workspace_id = x.workspace_id
AND u.usage_metadata.job_id = x.job_id
WHERE u.usage_metadata.workspace_id = <workspace_id>
AND u.billing_origin_product = "MODEL_SERVING"
AND u.product_features.model_serving.offering_type = "BATCH_INFERENCE";The docs also give versions of the second query that join to clusters and Lakeflow pipelines instead of jobs. Our guide to Databricks system tables explains the usage schema if you are new to it.
See Total AI Function Cost by User Finance teams tend to ask who spent the money. The documented query below joins usage to list prices. It totals both inference products by month and principal for the current month and the previous 12 months.
SELECT
DATE_TRUNC('MONTH', u.usage_date)::DATE AS usage_month,
COALESCE(
u.identity_metadata.run_as,
u.identity_metadata.run_by,
'UNATTRIBUTED'
) AS principal,
ROUND(
SUM(u.usage_quantity * p.pricing.effective_list.default),
2
) AS list_cost_usd
FROM system.billing.usage u
JOIN system.billing.list_prices p
ON u.cloud = p.cloud
AND u.sku_name = p.sku_name
AND u.usage_unit = p.usage_unit
AND u.usage_end_time >= p.price_start_time
AND (p.price_end_time IS NULL OR u.usage_end_time < p.price_end_time)
WHERE p.currency_code = 'USD'
AND u.usage_date >= ADD_MONTHS(DATE_TRUNC('MONTH', CURRENT_DATE()), -12)
AND (
(
u.billing_origin_product = 'MODEL_SERVING'
AND u.product_features.model_serving.offering_type = 'BATCH_INFERENCE'
)
OR u.billing_origin_product = 'AI_FUNCTIONS'
)
GROUP BY 1, 2
ORDER BY 1 DESC, 3 DESC;It reports list prices, so a negotiated discount makes the real figure lower. Rows marked UNATTRIBUTED point to usage with no run_as or run_by identity, which is worth chasing down.
A Worked Cost Example From Published DBU Rates Numbers make the model choice concrete. Take 1,000,000 support tickets labeled through ai_query, where you name the model endpoint. Each ticket sends about 400 input tokens and returns about 60 output tokens. That totals 400 million input tokens and 60 million output tokens.
Databricks prices model serving as the SKU price per DBU multiplied by the DBUs consumed, per its foundation model serving pricing page . This estimate uses that page’s own example SKU price of $0.07 per DBU on AWS US East.
Table 5: Estimated Inference Cost for 1 Million Tickets (Estimate at $0.07 per DBU)
Model (DBU per 1M input / output tokens) Input DBU Output DBU Total DBU About USD at $0.07/DBU GPT-OSS-20B (1.000 / 4.286) 400.0 257.2 657.2 $46 GPT-OSS-120B (2.143 / 8.571) 857.2 514.3 1,371.5 $96 Llama 3.3 70B (7.143 / 21.429) 2,857.2 1,285.7 4,142.9 $290
Model choice moves the bill about 6x at the same volume, from roughly $46 to roughly $290. Test the smallest model that meets your accuracy bar first, and move up only when a labeled sample says you must.
Treat these figures as an estimate only, and only for ai_query. Task-specific functions such as ai_classify pick their own model and bill under their own products. Your SKU price, pricing tier and cloud all change the rate. Batch runs may also be metered under the Batch Inference DBU-per-hour rates instead. SQL warehouse compute is billed on top, and the real number is whatever system.billing.usage shows after a pilot run.
Kanerika recommends modeling this table against real ticket or document volume before a pilot expands. Check the estimate against billing data after the first run. For wider levers such as warehouse sizing, see our guide to Databricks cost optimization .
Monitor Progress and Failures in the Query Profile Long batch jobs need a progress view as well as a cost view. On Databricks Runtime 16.1 ML or above, run the query in the SQL editor and open the Running link below the results.
From there, choose See query profile and then AI Query. The panel shows completed and failed inferences and the total request time, so a job failing row by row shows up early.
Some workloads outgrow SQL functions altogether, such as fine-tuning or custom GPU training. For those, the Databricks AI Runtime is the next step.
Getting Started With Databricks AI Functions 1. Confirm Compute and Runtime Requirements AI Functions do not run on Classic SQL warehouses, and notebook and workflow use needs Databricks Runtime 15.4 LTS or above, with 18.2 recommended.
2. Confirm Region and Model Availability Availability is limited to specific Model Serving regions rather than every workspace globally. A workspace in an unsupported region can still run other Databricks workloads normally, but AI Function calls from that workspace fail until Databricks extends coverage there.
3. Grant Execute Permissions Through Unity Catalog By default, every user holds execute access to every AI Function through the system.ai schema. Teams that need tighter control revoke that default and re-grant per function:
sql
-- Remove the default open access
REVOKE EXECUTE ON SCHEMA system.ai FROM `account users`;
-- Re-grant only the approved functions
GRANT EXECUTE ON FUNCTION system.ai.ai_summarize TO `data-analysts`;
GRANT EXECUTE ON FUNCTION system.ai.ai_classify TO `data-analysts`;4. Write and Test the Query Choose a task-specific function, or ai_query for a custom prompt, and run it against a sample table rather than a full production one. Compare a sample of AI-generated output to a known-correct answer before pointing the query at the full dataset.
5. Monitor Output and Move to Production Errors caught at the sample stage cost minutes. Errors caught after a job runs against millions of rows cost a rerun and a wasted bill, so the validation step earns the extra day it takes.
6. Deploy Through Lakeflow or Workflows Lakeflow Declarative Pipelines call AI Functions inside a transformation step, enriching a table with a derived column every time the pipeline runs, which fits recurring batch jobs better than an ad hoc query run by hand. Databricks Workflows schedules an AI Functions query on a recurring basis, with configurable retry policies at the task level .
Kanerika’s data engineering team builds this scheduling layer alongside most AI Functions rollouts, since production job behavior rarely matches notebook behavior exactly.
Troubleshooting Databricks AI Functions: Common Errors and Fixes A failing AI Functions query usually points to the compute type, the runtime version, permissions or the data itself. The table below maps each symptom to its likely cause and the fix given in the Databricks documentation.
Work down it in order, since the first rows take seconds to rule out.
Table 6: Databricks AI Functions Troubleshooting Guide
Symptom Likely cause Fix Function not available on the SQL warehouse A Classic SQL warehouse Switch to a Pro or serverless SQL warehouse Runtime error in a notebook or job Databricks Runtime below 15.4 LTS, or below 17.3 for ai_parse_document Upgrade to 15.4 LTS or above, with 18.2 or above recommended responseFormat rejected Runtime below 15.4 LTS, or a model that is not a chat model Upgrade the runtime and call a chat model endpoint One bad row fails the whole job failOnError defaults to true Set failOnError => false and read errorMessage for each row Function missing in the workspace Region not supported, or the preview is not turned on Check regional availability and the Manage previews page Permission denied on a function or UDF No EXECUTE grant for the user or group GRANT EXECUTE on the function to that principal NULL outputs NULL input, as with ai_mask, or a row that failed at the endpoint Filter NULL inputs first, then inspect errorMessage Slow or uneven runs Data split into manual batches, or provisioned throughput endpoints used for batch Submit the full dataset in one query on Databricks-hosted foundation model endpoints
Where to Look When the Table Does Not Help Confirm the warehouse type first, because it is the quickest check. Our guide to Databricks SQL warehouse types explains the options and when each one fits.
Errors that persist after these fixes often sit outside AI Functions, in the cluster, job or workspace setup. The Databricks troubleshooting guide walks through those wider platform issues step by step.
How to Evaluate Databricks AI Functions Output Quality in Production A query can finish without a single error and still return wrong labels, so output quality needs a check of its own. Evaluating AI Functions output works best as three habits that run from the first pilot to steady production.
Build a labeled sample before launch, track errors on every run and score open-ended text with judges. Each habit catches a failure the others miss.
Build a Labeled Sample Before the First Full Run A labeled sample turns “the output looks fine” into a number you can track. Pull a few hundred rows that reflect the real mix of your data and have a domain expert label them by hand.
Sample 200 to 500 rows across every category and source system. Label them by hand, with a second reviewer on unclear cases. Run ai_classify or ai_extract over the sample with each candidate model and prompt. Compare agreement rates and keep the cheapest option that clears your bar. That agreement rate becomes the baseline every later prompt or model change has to beat.
Track Error Rate and Null Outputs per Run With failOnError set to false, ai_query returns a struct holding the response and an errorMessage for each row. If the run stored that struct in a column named result, count the rows where result.errorMessage is not NULL. That count is the run’s error rate.
SELECT
COUNT(*) AS total_rows,
COUNT_IF(result.errorMessage IS NOT NULL) AS failed_rows,
COUNT_IF(result.response IS NULL) AS null_responses
FROM ticket_labels_run;Store these counts with the run date and alert when they drift from the last stable run. A sudden jump usually points to a change in the input data or the endpoint. The failed-inference count in the query profile gives the same signal while a job is still running.
Score Open-Ended Outputs With MLflow Judges Labels work well for classification, while summaries and generated text need a different kind of check. MLflow scorers handle this with LLM judges such as Correctness, Completeness and Fluency, alongside code-based checks you write yourself.
Run mlflow.genai.evaluate() on an evaluation dataset before launch, then turn on production monitoring for a sample of traffic, as the MLflow evaluation docs describe.
Judges are models too, so spot-check a handful of their scores by hand each month. Our overview of LLM evaluation frameworks compares the wider tooling for teams that need more than built-in judges.
A fast-growing, AI-powered sales intelligence platform ran into a scaling problem. Its data engine depended on large-scale web scraping and document ingestion to deliver real-time company and industry insights, running on MongoDB, Postgres, and legacy JavaScript-based processing.
As the client’s customer base and data demands grew, that architecture stopped keeping up. Document handling logic was stuck in JavaScript, pipelines were scattered across disconnected systems, and unstructured data lacked consistency.
That combination slowed insight generation and made maintenance harder with every release. Kanerika re-architected the pipeline on Databricks to modernize the document workflows, improve pipeline performance, and cut manual overhead.
Client’s Challenges Outdated document workflows created maintenance bottlenecks that delayed service delivery and reduced operational agility Disconnected data sources limited visibility across systems, delaying access to timely, reliable insights Unstructured PDF and metadata processes increased manual effort, cutting into team productivity and extending turnaround times
Kanerika’s Solutions Refactored document workflows from JavaScript to Python in Databricks, improving maintainability and processing speed Integrated disconnected data sources into Databricks, improving visibility and enabling faster, more reliable insights Streamlined PDF, metadata, and classification workflows in Databricks, cutting manual effort and accelerating insight delivery
Business Outcomes 80% faster document processing 95% improvement in metadata accuracy 45% faster time-to-insight
How Kanerika Helps Enterprises Deploy AI Functions on Databricks Kanerika holds Databricks Consulting Partner status, applied to production batch inference and document intelligence pipelines. Enterprise rollouts tend to need the same three things:
A governance model that satisfies security review, scoped function by function through Unity Catalog rather than left at the default open state A cost structure that survives production scale, modeled against real data volume before the pilot expands A pipeline architecture built for the data volume ahead, using Lakeflow and Workflows from the start rather than retrofitted after a notebook prototype breaks under load
Kanerika’s Databricks engagements start with the same document and data enrichment patterns covered in this guide, adapted to each client’s stack, industry, and compliance requirements.
Wrapping Up AI Functions fold AI capability directly into SQL, closing the gap between a data table and a model call. Task-specific functions cover the common jobs out of the box, and ai_query handles anything more custom.
Getting production value out of them takes the same discipline as any data platform investment. Right-sized governance, predictable cost controls, and a pipeline built for real volume from day one make the difference.
Transform Your Business with AI-Powered Solutions! Partner with Kanerika for Expert AI implementation Services
Book a Meeting
FAQs
1. What are Databricks AI Functions? Databricks AI Functions are built-in SQL functions that enable users to apply generative AI directly to their data. They support tasks such as summarization, translation, sentiment analysis, classification, and information extraction without requiring custom AI integrations. This allows data teams to build AI-powered workflows faster using familiar SQL syntax.
2. How do Databricks AI Functions work? Databricks AI Functions send prompts or input data to supported AI models and return the results within SQL queries or notebooks. The platform manages model execution and scaling behind the scenes, allowing users to integrate AI into existing data pipelines without building or maintaining separate AI infrastructure.
11. What is the difference between ai_query and ai_gen? ai_gen takes a single prompt and returns text from a model that Databricks chooses, which makes it the quickest way to generate content in SQL. ai_query lets you name the serving endpoint, set model parameters, send files and enforce structured output with responseFormat. Use ai_gen for simple prompts and ai_query when control matters.
12. How do Databricks AI Functions compare to Snowflake Cortex AI Functions? Both run language models from SQL and cover classification, extraction, translation and summarization. Databricks governs access through Unity Catalog EXECUTE grants and bills in DBUs, and its AI Functions set also covers forecasting, metric drivers and vector search. Snowflake needs the USE AI FUNCTIONS privilege plus a role such as CORTEX_USER, bills credits per million tokens, adding AI_FILTER and AI_AGG.
13. Do Databricks AI Functions work on Classic SQL warehouses? No. The Databricks documentation states that AI Functions are not available on Classic SQL warehouses, so use a Pro or serverless SQL warehouse instead. Notebooks and jobs need Databricks Runtime 15.4 LTS or above, and Databricks recommends 18.2 or above. Region and model availability also vary, so confirm both before planning a rollout.
14. Can Databricks AI Functions return structured JSON output? Yes. The responseFormat argument of ai_query makes a chat model return output that matches a schema, written as a DDL STRUCT string or a JSON schema with strict mode. It needs Databricks Runtime 15.4 LTS or above. Task-specific functions such as ai_extract also return structured results for the fields you define in the call.
15. How do you extract data from PDFs with Databricks AI Functions? Read the files with READ_FILES using the binaryFile format, then pass the content to ai_parse_document, which turns each PDF into structured text and layout on Databricks Runtime 17.3 or above. Call ai_extract on the parsed output with the list of fields you need, such as invoice number and total. The same flow supports images, Word and PowerPoint files.
16. Are Databricks AI Functions available in Azure Databricks? Yes. Microsoft documents AI Functions for Azure Databricks on Microsoft Learn, so teams on Azure can call them from SQL, notebooks and jobs. Availability still depends on the Azure region of your workspace and on which foundation models are served there, so check the regional list before you design a production pipeline around one function.
3. What can you do with Databricks AI Functions? Databricks AI Functions can automate a variety of data tasks, including document summarization, customer feedback analysis, sentiment detection, text translation, entity extraction, and content generation. They help organizations process unstructured data more efficiently while reducing manual effort and accelerating business insights.
4. Can you use Databricks AI Functions in SQL? Yes. Databricks AI Functions are designed to work directly within Databricks SQL. Users can incorporate AI-powered tasks like summarizing text, classifying records, or extracting key information into SQL queries, making it easier for analysts and engineers to build intelligent data workflows.
5. What is the difference between Databricks AI Functions and AI_QUERY? Databricks AI Functions offer predefined capabilities for common AI tasks such as summarization and classification. AI_QUERY, on the other hand, provides greater flexibility by allowing users to send custom prompts to supported AI models. Built-in AI Functions are ideal for standard use cases, while AI_QUERY is better suited for more advanced or customized workflows.
6. What are the best use cases for Databricks AI Functions? Databricks AI Functions are commonly used for summarizing documents, analyzing customer reviews, classifying support tickets, extracting information from invoices, translating multilingual content, and enriching datasets. These capabilities help organizations automate repetitive tasks and improve the speed and accuracy of data-driven decision-making.
7. Which AI models do Databricks AI Functions support? Databricks AI Functions work with Databricks-managed foundation models and can also support external or custom models through AI_QUERY, depending on your workspace configuration. This flexibility allows organizations to choose the right model for their AI applications while maintaining governance and scalability.
8. Why should businesses use Databricks AI Functions? Databricks AI Functions simplify enterprise AI adoption by embedding generative AI into existing data workflows. They reduce development effort, improve productivity, and enable teams to automate AI-powered tasks directly within SQL and notebooks. This helps organizations scale AI initiatives while maintaining security and governance.
9. How much do Databricks AI Functions cost? You pay for the compute that runs the query, and most task-specific functions add model inference billed in DBUs. Inference cost equals the DBUs consumed times your SKU price per DBU. At Databricks’ example price of $0.07 per DBU, ai_query inference for one million short tickets is estimated at about $46 to $290, depending on the model you name.
10. How do you track Databricks AI Functions spend? Query the system.billing.usage table. Functions such as ai_classify, ai_extract and ai_parse_document appear under the AI_FUNCTIONS product, while ai_summarize, ai_translate, ai_mask and similar functions appear under MODEL_SERVING with the BATCH_INFERENCE offering type. Joining usage to system.billing.list_prices gives a monthly cost per user, and the query profile shows failed inferences while a job runs.