# DuckDB AI extension > duckdb-ai is a DuckDB extension that calls LLMs from SQL: classify, summarize and extract typed data, generate embeddings for semantic search, and turn questions into read-only SQL, with Ollama, OpenAI, Claude, Gemini and 30+ providers. Full text of every page: https://leonardovida.github.io/duckdb-ai/llms-full.txt ## Docs - [DuckDB AI: LLMs and embeddings in SQL](https://leonardovida.github.io/duckdb-ai/docs): Call LLMs from DuckDB SQL with the ai extension: classify, summarize and extract typed data, generate embeddings for semantic search, and ask questions in natural language, with Ollama, OpenAI, Claude, Gemini and 30+ providers. - [Use DuckDB AI from coding agents](https://leonardovida.github.io/duckdb-ai/docs/agent-guide): Discover DuckDB AI SQL functions, configure model providers, preview requests without credentials, and verify integrations with local mocks. - [Cookbooks](https://leonardovida.github.io/duckdb-ai/docs/cookbooks): Practical DuckDB AI recipes: enrich tables with LLMs, extract typed records, route rows by decision confidence, evaluate prompts on labeled samples, build semantic search with embeddings, run resumable batch jobs and generate SQL from questions. - [Create the sample support tickets table](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/support-ticket-data): Create the sample support_tickets table used by the DuckDB AI cookbook examples. - [Chain several AI steps in SQL](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/chain-ai-steps): Run multi-step LLM pipelines in DuckDB SQL: avoid repeated model calls, skip rows that failed upstream, branch with CASE, and checkpoint each step so reruns only retry what is missing. - [Evaluate a prompt or model on a labeled sample before a batch run](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/evaluate-before-batch): Compare prompts or models on a small labeled sample in DuckDB SQL: accuracy, per-label errors, confidence thresholds and estimated cost per correct answer, before paying for a full batch. - [Run production batch enrichment from S3 or Parquet](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/production-batch-enrichment): Run LLM enrichment over Parquet or S3 data in DuckDB with bounded batches, row-level failure capture and durable output files. - [Resume a local enrichment job](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/resumable-enrichment): Checkpoint DuckDB LLM enrichment jobs in bounded batches and retry failed rows without repeating saved successes. - [Enrich rows from Postgres or MySQL safely](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/source-database-enrichment): Enrich Postgres or MySQL rows with LLMs from DuckDB safely: attach read-only, materialize local batches and write to reviewed staging tables. - [Write audited AI outputs to lakehouse tables](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/audited-lakehouse-output): Write LLM outputs from DuckDB to Parquet, Delta, Iceberg or DuckLake tables with run metadata, rejected rows and usage events for auditing. - [Monitor AI usage, failures, and cost](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/usage-cost-observability): Monitor DuckDB AI provider calls: latency, retries, failures, cache hits, token counts and estimated cost with ai_usage(). - [Normalize messy documents into structured records](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/messy-document-intake): Normalize mixed JSON, Avro, Excel and CSV inputs into one typed table with LLM extraction in DuckDB SQL. - [Enrich support tickets with AI text functions](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/support-ticket-enrichment): Summarize, classify, filter, extract, redact and translate text columns with LLM functions in DuckDB SQL. - [Compare support tickets with embeddings](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/support-ticket-similarity): Find semantically similar rows in DuckDB with ai_embed, ai_similarity and list_cosine_similarity, then rerank a short list with ai_rerank. - [Store embeddings in Lance for semantic search](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/lance-semantic-search): Store DuckDB AI embeddings in Lance, build a vector index, and combine semantic search, full-text search and reranking in SQL. - [Extract typed records from model output](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/structured-triage-records): Extract structured JSON from LLM output and project it into typed DuckDB columns with ai_extract_record and ai_complete_record. - [Turn rows into typed decisions](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/jev-decisions): Classify, score and flag DuckDB table rows with ai_decide and TypeSafe Jev, and get typed STRUCT fields you can filter, aggregate and export without parsing JSON. - [Route rows by decision confidence](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/decision-routing): Answer several typed questions per row with ai_decide, accept confident answers, and send low-confidence rows to a chat-model fallback or a review table in DuckDB SQL. - [Generate read-only SQL over local tables](https://leonardovida.github.io/duckdb-ai/docs/cookbooks/sql-assistant): Generate and run read-only DuckDB SELECT statements from natural-language questions with ai_sql and ai_query_data. - [SQL function reference](https://leonardovida.github.io/duckdb-ai/docs/functions): DuckDB AI SQL function reference: ai_complete, ai_classify, ai_extract_record, ai_embed, ai_query_data and every other function, with named options, settings, examples and result types. - [Provider guides](https://leonardovida.github.io/duckdb-ai/docs/provider-guides): Configure DuckDB AI with Ollama, llama.cpp, OpenAI, Anthropic Claude, Gemini, Azure OpenAI, Bedrock, Vertex AI, Databricks, Snowflake Cortex, OpenRouter and 30 more LLM providers. - [Best practices](https://leonardovida.github.io/duckdb-ai/docs/best-practices): Production best practices for LLM calls in DuckDB SQL: provider choice, secrets, model defaults, structured output, SQL safety, redaction, rate limits, caching, logging and cost. - [Runtime behavior](https://leonardovida.github.io/duckdb-ai/docs/runtime-behavior): How DuckDB AI runs provider calls: function volatility, concurrency, retries, timeouts, response caching, cancellation, token limits and egress allowlists. - [Security and data flow](https://leonardovida.github.io/duckdb-ai/docs/security-data-flow): What data DuckDB AI sends to model providers, how credentials are resolved, egress controls, logging defaults and how to keep inference fully local. - [Run on a Quack server](https://leonardovida.github.io/duckdb-ai/docs/quack-server): Serve DuckDB AI functions to remote DuckDB clients over Quack: load the extension on the server, keep provider credentials there, and lock down what clients can reach. ## Source - [GitHub repository](https://github.com/leonardovida/duckdb-ai) - [Changelog](https://github.com/leonardovida/duckdb-ai/blob/main/CHANGELOG.md) - [DuckDB community extension page](https://duckdb.org/community_extensions/extensions/ai)