Introducing new AI functions for AlloyDB: ai.classify and ai.extract Google announced the preview of two new SQL functions, ai.classify and ai.extract, in the AlloyDB AI query engine, available in the google_ml_integration extension version 1.6.1 or later on PostgreSQL 18. The functions let developers run single- or multi-label text classification and JSON-schema-based structured extraction directly inside the database using Gemini models, with smart batching that groups inputs into optimized micro-batches to cut query latency and model token spend. Google said the native functions target operational workflows in healthcare, financial services, legal technology and real estate, keeping sensitive text within the database rather than exporting it to external model endpoints. Transactional databases store vast amounts of unstructured text — clinical notes, customer reviews, support tickets, invoices, and property descriptions. Historically, working with this text meant building complex application code: You had to export data from the database, call external model endpoints, write custom prompt wrappers, parse unpredictable responses, manage retry logic, and update database records. This application-side loop creates operational friction. It introduces query latency, bloats application code, increases model token costs, and creates data compliance risks by moving sensitive information across multiple network boundaries. We built AlloyDB AI https://cloud.google.com/alloydb/ai to bring Gemini world knowledge directly into your operational database. Rather than treating artificial intelligence as a disconnected external service, we integrated model intelligence directly into the database engine. Today, we are announcing the preview of two new SQL functions in the AlloyDB AI query engine — ai.classify and ai.extract — available in the google ml integration extension version 1.6.1 or later on PostgreSQL 18, allowing you to perform classification and structured extraction directly inside your database using standard SQL. Supported by smart batching for AI functions previously known as AI Function Acceleration , these functions deliver production scalability and performance. Now, let’s take a look at these new functions and how to use them. The ai.classify function categorizes text into user-defined classes without requiring manual prompt engineering. You can specify categories as a simple list of labels or provide a list containing label names and descriptions to guide model context. Key capabilities include: Single-label classification output mode = 'single' to assign the single best category Multi-label classification output mode = 'multi' to return all matching categories Category descriptions using 2D arrays to provide explicit context for each label Few-shot prompting by supplying inline examples Flexible execution modes for individual rows TEXT , arrays TEXT , and cursors REFCURSOR Here’s a quick example showing how you can classify customer feedback directly within a SQL query: The ai.extract function transforms unstructured text into structured JSON data matching your target schema — specified as a JSON schema or a text list of fields. It handles system instructions internally, saving you from writing prompt templates or response parsers. Schema flexibility supporting standard JSON schemas or plain text field lists Automatic transformation of unstructured text into machine-readable JSON Overloaded function signatures for single rows, arrays, and cursor batching Here’s an example extracting clinical fields from free-form medical notes: Running AI evaluations row-by-row can slow down query execution. AlloyDB addresses this with smart batching for AI functions. When you use ai.classify or ai.extract in SQL WHERE clause expressions, the database engine automatically groups inputs into optimized micro-batches before sending them to Gemini Enterprise Agent Platform models. Smart batching delivers significant performance and efficiency improvements: Faster inference for query execution compared to row-at-a-time evaluations Reduces total model token spend by optimizing input prompt overhead Native classification and extraction functions support operational workflows across key industry sectors: Healthcare: Securely convert free-text clinical notes into structured records containing patient names, symptoms, and prescribed medications, keeping patient data safely within the confines of the database. Financial services: Extract vendor details, invoice dates, and line-item totals from scanned document text. Legal technology: Pull governing law, liability caps, and termination notice periods from contract documents. Real estate: Extract property types, bedroom counts, and price ranges from descriptive listing text. Knowledge graphs: Extract entities and relationships from documents to populate PostgreSQL Property Graph PGQ structures. We are continuing to expand in-database AI capabilities in AlloyDB, with upcoming enhancements planned for advanced cost optimization, line-level provenance tracking, and query pushdowns beyond WHERE clauses. To start using ai.classify and ai.extract in your database: Review the AlloyDB AI Query Engine documentation https://docs.cloud.google.com/alloydb/docs/ai . Explore the AlloyDB release notes https://docs.cloud.google.com/alloydb/docs/release-notes .