Loading the documentation…
AI in SQL lets a SQL query ask Kartlos about each row: classify a review, pull a field out of free text, translate, filter rows by a plain-language condition or redact personal data. It works through six ClickHouse functions, listed below. Every call uses Kartlos Standard and is billed to your company's standard bucket.
AI in SQL is off until an administrator turns it on.
While the setting is off, every query that calls an AI function is refused. See Scheduler, health, maps and connector safety.
A person can call the functions only when the setting is on and their role holds Use AI in SQL (in the Data Layer category, group AI in SQL; the standard permission AI in SQL User covers it). Data Layer Administrator does not include it, so grant it on purpose. See Roles and permissions.
| Function | Use it to |
|---|---|
aiGenerate | Write free text from a prompt |
aiClassify | Pick one of the labels you list |
aiExtract | Pull the information you describe out of free text |
aiTranslate | Translate text into another language |
aiFilter | Keep the rows where a plain-language condition holds, in WHERE |
aiRedact | Remove personal data from text |
aiEmbed and aiSimilarity are not available.
SELECT
body,
aiClassify(body, ['positive', 'negative', 'neutral']) AS sentiment
FROM reviews
LIMIT 100They never run inside a view, a materialized view, a dictionary, a function or a column expression: those would ask the model again on every read, insert or refresh. Write the results into a table with a Warehouse transformation instead.
SETTINGS ai_function_max_api_calls_per_query = 5000, from 1 to 20,000. The Editor refuses a value outside that range; Minds, DataMind Oda and Warehouse transformations treat 0 or a higher value as 20,000. A Warehouse transformation run allows 20,000 calls; set the value in the transformation's query settings to lower it.ai_function_max_api_calls_per_query is the only ai_function_* setting a query may change. The functions always use the company's datamind_ai credentials.max_threads may be set from 1 to 16 in a query that calls an AI function.WHERE or LIMIT, or keep the results in a table.An administrator has not turned it on. Ask them to switch AI in SQL on in Admin > System Configuration > AI in SQL.
Your role does not hold it. Ask an administrator to add Use AI in SQL to your role.
1,000 by default, because the functions make one call per row. Add SETTINGS ai_function_max_api_calls_per_query = <n> to raise it, up to 20,000. When the call or token limit is reached, the query stops with an error.
The next page would run the query again and ask the model again for the same rows. Narrow the query, or write the results into a table with a Warehouse transformation and query that table.
No. A view, materialized view, dictionary, function or column expression would call the model on every read, insert or refresh. Store the results with a Warehouse transformation, then build the view on that table.
Kartlos Standard answers every call. The usage is billed to your company's standard bucket.
A Mind's query may call them when the setting is on and the person who asked the Mind holds the permission. If not, the Mind is told the call is refused and answers without it.
No. Only Kartlos Standard serves AI in SQL; a call that names another model is refused.