# How to put generative AI directly into a dbt pipeline with plain SQL

DevFeed: [How to put generative AI directly into a dbt pipeline with plain SQL](<https://devfeed.tech/articles/how-to-put-generative-ai-directly-into-a-dbt-pipeline-with-plain-sql-102638.md>)

Original publisher: [Read original article](<https://www.getdbt.com/blog/bigquery-generative-ai-dbt-sql-functions>)

Author: Daniel Poppy

Published: 2026-10-27T19:06:00Z

Content type: article

Language: en

Sources: [dbt Labs](<https://devfeed.tech/sources/dbt-labs.md>)

Topics: [AI Integration Strategies](<https://devfeed.tech/topics/ai-integration-strategies.md>), [Generative AI](<https://devfeed.tech/topics/generative-ai.md>), [BigQuery](<https://devfeed.tech/topics/bigquery.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Analytics Pipeline](<https://devfeed.tech/topics/analytics-pipeline.md>), [JOIN](<https://devfeed.tech/topics/join.md>)

Tags: [2026](<https://devfeed.tech/tags/2026.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-experiments](<https://devfeed.tech/tags/ai-experiments.md>), [ai-logic](<https://devfeed.tech/tags/ai-logic.md>), [api](<https://devfeed.tech/tags/api.md>), [applied-ai](<https://devfeed.tech/tags/applied-ai.md>), [bigquery](<https://devfeed.tech/tags/bigquery.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [dbt](<https://devfeed.tech/tags/dbt.md>), [functions](<https://devfeed.tech/tags/functions.md>), [generative](<https://devfeed.tech/tags/generative.md>), [generative-ai](<https://devfeed.tech/tags/generative-ai.md>), [google](<https://devfeed.tech/tags/google.md>), [google-cloud](<https://devfeed.tech/tags/google-cloud.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [json](<https://devfeed.tech/tags/json.md>), [language-model](<https://devfeed.tech/tags/language-model.md>), [learn](<https://devfeed.tech/tags/learn.md>), [llm](<https://devfeed.tech/tags/llm.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

BigQuery's AI SQL functions let dbt models apply LLM-based analysis directly to table rows, without a separate Python service. The excerpt describes AI.GENERATE for custom prompts and typed JSON via output_schema, plus managed functions such as AI.IF, AI.CLASSIFY, AI.SCORE, and AI.AGG for common analytical tasks; these are generally cheaper than custom prompts. Optimized AI.IF and AI.CLASSIFY use a sample-labeled distilled model to process the remaining data. For production, the speaker recommends incremental models with AI logic inside is_incremental() to avoid resending all rows on full refresh, token estimates and daily caps to manage spend, and max_error_ratio to stop queries when failures exceed a threshold. Pairing output_schema with dbt tests such as not_null and accepted_values can catch invalid results before they reach marts. The described demo scores review sentiment and summarizes it by product. This overview reflects the supplied excerpt.

## Source excerpt

Google Cloud on wiring BigQuery's AI SQL functions into dbt pipelines, from sentiment scoring to LLM-generated product briefings.