---
title: "AI Functions in ClickHouse: Upgrade your SQL to the AI age"
description: "ClickHouse's beta AI Functions call LLM and embedding providers directly from SQL."
url: "https://swe.quest/articles/ai-functions-in-clickhouse-upgrade-your-sql-to-the-ai-age-11cec6552950f306"
canonical: "https://clickhouse.com/blog/ai-functions-in-clickhouse"
source: "ClickHouse"
published: "2026-09-11"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 12
tags: ["llms","sql","rag","analytics","cost-optimization"]
---

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

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-09-11, 12 min read, Announcement. Original: [https://clickhouse.com/blog/ai-functions-in-clickhouse](https://clickhouse.com/blog/ai-functions-in-clickhouse)

## Summary

ClickHouse's beta AI Functions call LLM and embedding providers directly from SQL. They include aiClassify, aiExtract, aiGenerate, aiTranslate, aiFilter, aiRedact, aiEmbed and aiSimilarity, added across releases 26.4 to 26.8, and they make one HTTP request per row (batched for embeddings) and return native ClickHouse values. Setup on OSS uses named collections for credentials and works with any OpenAI-compatible endpoint, including local models via Ollama. Examples on the Hacker News dataset show classification, LLM predicates in WHERE, summarization, translation and an in-database RAG pipeline built on materialized-view embeddings and vector indexes. Per-query quotas on API calls and input/output tokens cap spend: call limits are exact, token limits can overshoot by one in-flight request per thread, a soft-stop mode returns partial results, and actual usage is visible in system.query\_log ProfileEvents.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- LLM APIs ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- embeddings and vector search ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))

## Keywords

ClickHouse, aiGenerate, aiFilter, aiEmbed, OpenAI, Ollama, Hacker News dataset

## Related posts

- [Using ClickHouse UDFs to integrate with OpenAI models](https://swe.quest/articles/using-clickhouse-udfs-to-integrate-with-openai-models-798f9ca64f94924a.md): ClickHouse · 2023-09-14 · Medium · 17 min read · Analytics & OLAP, LLMs, SQL, Python
  ClickHouse executable user-defined functions can call the OpenAI chat completions API from SQL, adding sentiment labels or extracted entities to rows at insert or query time.
- [Building a RAG pipeline for Google Analytics with ClickHouse and Amazon Bedrock](https://swe.quest/articles/building-a-rag-pipeline-for-google-analytics-with-clickhouse-and-amazon-bedrock-e2945701d51424da.md): ClickHouse · 2023-11-21 · Medium · 26 min read · RAG & retrieval, LLMs, Vector search, Analytics & OLAP, Cloud platforms
  A natural language interface over raw Google Analytics data stored in ClickHouse is built as a multi-step RAG pipeline that generates SQL from user questions using Amazon Bedrock models.
- [Building an agentic app with ClickHouse MCP and CopilotKit](https://swe.quest/articles/building-an-agentic-app-with-clickhouse-mcp-and-copilotkit-8a892e5035cf8b12.md): ClickHouse · 2025-06-12 · Medium · 9 min read · AI agents, Analytics & OLAP, React, LLMs
  A natural-language analytics dashboard for UK property prices can be built by combining an LLM (Claude Sonnet 3.7), the ClickHouse MCP Server and CopilotKit in a Next.js app.
- [How Fetch built its flexible agentic analytics tool on ClickHouse Cloud](https://swe.quest/articles/how-fetch-built-its-flexible-agentic-analytics-tool-on-clickhouse-cloud-284f56cdf33d7d26.md): ClickHouse · 2026-07-28 · Easy · 6 min read · Analytics & OLAP, AI agents, Data pipelines, LLMs
  Fetch built FAST, a conversational BI agent that lets non-technical sales teams query receipt purchase data in plain language, on ClickHouse Cloud ingesting 150 billion rows (6.5 TB compressed) a day.
- [Agentic coding with ClickHouse. One person, one data stack, one full-stack application](https://swe.quest/articles/agentic-coding-with-clickhouse-one-person-one-data-stack-one-full-stack-ca4c2d9fd47cef68.md): ClickHouse · 2026-04-14 · Easy · 13 min read · AI for coding, Analytics & OLAP, Observability, AI agents
  A ClickHouse Solutions Architect with no frontend or backend background built ClickShop, a full-stack retail analytics demo, in a couple of days using Cursor.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
