---
title: "AI Functions in ClickHouse: Upgrade your SQL to the AI age"
description: "ClickHouse’s beta AI Functions let SQL queries call an LLM or embedding provider directly, keeping classification, extraction, generation, translation, redaction, filtering, embedding, and similarity work alongside stored data. The feature addresses workflows that export rows to separate LLM, orchestration, or vector-database systems and then reload results, with the stated goal of running the full RAG cycle in ClickHouse. Functions make remote HTTP calls per input, or batch embedding inputs, and return native ClickHouse values; in open-source deployments, named collections store provider credentials and endpoint settings. Examples use Hacker News data for topic classification and natural-language filtering, while the guidance emphasizes cheap predicates, quotas, LIMIT tests, prompt-injection defenses, non-determinism, cost, latency, and provider access to data in cleartext after TLS termination."
---

# AI Functions in ClickHouse: Upgrade your SQL to the AI age

[Clickhouse](https://yomu.fyi/company/clickhouse) · Sep 11, 2026

**Type:** Explainer

## Summary

ClickHouse’s beta AI Functions let SQL queries call an LLM or embedding provider directly, keeping classification, extraction, generation, translation, redaction, filtering, embedding, and similarity work alongside stored data. The feature addresses workflows that export rows to separate LLM, orchestration, or vector-database systems and then reload results, with the stated goal of running the full RAG cycle in ClickHouse. Functions make remote HTTP calls per input, or batch embedding inputs, and return native ClickHouse values; in open-source deployments, named collections store provider credentials and endpoint settings. Examples use Hacker News data for topic classification and natural-language filtering, while the guidance emphasizes cheap predicates, quotas, LIMIT tests, prompt-injection defenses, non-determinism, cost, latency, and provider access to data in cleartext after TLS termination.

## Context

Data such as logs, reviews, descriptions, and support tickets already resides in ClickHouse, but traditional LLM workflows move it into separate classification, embedding, vector-database, orchestration, and API systems before loading results back. The post describes that process as slow, error-prone, and operationally complex.

## Approach / What changed

AI Functions expose LLM and embedding operations as ClickHouse SQL functions. They call configured providers over HTTP, parse responses into native ClickHouse values, and can use named collections for provider credentials and endpoint configuration in open-source deployments. The examples apply these functions directly to Hacker News data.

## Takeaways

- AI Functions arrived across ClickHouse releases: aiGenerate(), aiClassify(), aiExtract(), and aiTranslate() in 26.4; aiEmbed() in 26.6; and aiFilter(), aiRedact(), and aiSimilarity() in 26.8.
- aiFilter() returns UInt8, allowing a natural-language condition to be used directly in WHERE, PREWHERE, or JOIN ... ON clauses after cheaper predicates have narrowed the input.
- API-call and token quotas are shared within an execution context; retries count toward call limits, distributed queries can apply limits per shard, and providers that omit usage data do not trigger token limits.

**Tags:** [ClickHouse](https://yomu.fyi/topic/clickhouse), [LLMs](https://yomu.fyi/topic/llm), [SQL](https://yomu.fyi/topic/sql)

- Source: [Clickhouse](https://clickhouse.com/blog/ai-functions-in-clickhouse)
- Source URL: https://clickhouse.com/blog/ai-functions-in-clickhouse
- Ingested by Yomu: 2026-09-11T16:03:07.733Z

[Read original post](https://clickhouse.com/blog/ai-functions-in-clickhouse)
