{"slug": "data-ai-anywhere-alloydb-omni-integration-with-local-models", "title": "Data + AI Anywhere: AlloyDB Omni integration with local models", "summary": "Google's AlloyDB Omni, the downloadable, PostgreSQL-compatible edition of AlloyDB, now integrates with locally hosted large language models including Gemma 4 from Google DeepMind and Qwen3.8, letting users invoke models through SQL functions such as ai.generate() while keeping data on-premises. The integration targets air-gapped networks and data-locality-constrained environments, with the database and model running in the same local environment so data never crosses the public internet. Google documents a step-by-step deployment using the AlloyDB Omni Kubernetes Operator on Google Kubernetes Engine, registering a local model via the google_ml_integration extension.", "body_md": "Open models like Gemma 4 from Google DeepMind are a great option to keep your data local. But how can a local AI model integrate with on-premises data?\n\nAlloyDB Omni, Google’s 100% PostgreSQL-compatible database that runs anywhere, now integrates with locally hosted large language models (LLMs). With AlloyDB Omni, you can build agentic experiences on your own infrastructure and on your own terms. Whether it’s in the cloud, in your datacenter, or even on your laptop, you can have data plus AI anywhere.\n\nBuilt-in AI for your local environment\n\nAlloyDB Omni is a downloadable, run-anywhere edition of AlloyDB that easily deploys to your own infrastructure, including on-premises. AlloyDB Omni packs powerful, built-in AI, including the same ScaNN indexing technology powering Google Search. When you pair AlloyDB Omni with a model, you can store vector embeddings at scale; search them semantically; and even query the database using natural language. You can use virtually any model you like, whether that’s a frontier Cloud-hosted model like Gemini or a local model. And with locally hosted models you maintain complete control over your data environment.\n\nConnecting to Gemma 4, Qwen3.8, and other local models\n\nYou can now connect AlloyDB Omni to local models like Gemma 4 and Qwen3.8. No matter which model you choose, the architecture remains the same.\n\nThis setup enables entirely new use cases for environments that were previously blocked from adopting agentic capabilities. If you operate an air-gapped network or have data locality requirements, you can still build intelligent applications. You can analyze local logs, generate summaries of proprietary internal documents, and power localized chatbots—all while maintaining strict data governance.\n\nKeep data on-premises: Because the database and the model sit in the same local environment, your data never crosses the public internet.\n\nQuery directly via SQL: Your standard database queries can invoke machine learning functions that process data locally. Like this:\n\ncode_block\n\n<ListValue: [StructValue([('code', \"SELECT customer_name,\\r\\n ai.generate('Summarize in 1 short sentence: ' || comment,\\r\\n model_id => 'gemma4_llm') AS summary\\r\\nFROM customer_feedback;\\r\\n\\r\\n customer_name | summary \\r\\n---------------+-----------------------------------------------------------------------\\r\\n Alice | The customer demands a refund for a double charge or they will cancel\\r\\n Bob | The user likes the product but requests dark mode support.\"), ('language', ''), ('caption', <wagtail.rich_text.RichText object at 0x7f7ee1f50510>)])]>\n\nNext, you’ll see how to run queries like this yourself, step by step.\n\nGet started\n\nYou can test this integration on your own machines today. Using a Kubernetes environment we will show you how to deploy and integrate AlloyDB Omni and a local open model.\n\nStep 0: Before you begin\n\nIn this example, we will use Google Kubernetes Engine (GKE) to host the AlloyDB Omni database and local model. GKE gives us a standardized, reproducible environment but you can use the same setup on-prem or almost anywhere.\n\nStep 1: Deploy the AlloyDB Omni Kubernetes Operator\n\nWe will use the AlloyDB Omni Kubernetes operator to set up our AlloyDB Omni database. The Operator makes deploying and maintaining AlloyDB Omni a breeze.\n\nIn this example we deploy Gemma 4 from Google DeepMind. Or, you can modify this command to deploy Qwen3.8 – just change a few lines as noted in the comments.\n\nNote: If you receive a connection error, you might need to wait a moment for your database to provision.\n\nNow you should be connected to your AlloyDB Omni database with the psql client. Next, run the following SQL script to register your local model.\n\ncode_block\n\n<ListValue: [StructValue([('code', \"CREATE EXTENSION IF NOT EXISTS google_ml_integration;\\r\\nALTER SYSTEM SET google_ml_integration.request_timeout_in_seconds = 600;\\r\\nSELECT pg_reload_conf();\\r\\nCREATE OR REPLACE FUNCTION google_ml.ollama_llm_input_transform(\\r\\n model_id character varying, prompt text,\\r\\n generation_config json, system_instructions json\\r\\n) RETURNS json AS $$\\r\\n SELECT json_build_object(\\r\\n 'model', CASE model_id\\r\\n WHEN 'gemma4_llm' THEN 'gemma4:12b'\\r\\n WHEN 'qwen3_8_llm' THEN 'qwen3.8'\\r\\n END,\\r\\n 'messages', json_build_array(\\r\\n json_build_object('role', 'system', 'content',\\r\\n COALESCE(system_instructions->'systemInstruction'->'parts'->0->>'text',\\r\\n 'You are a helpful assistant.')),\\r\\n json_build_object('role', 'user', 'content', prompt)\\r\\n )\\r\\n );\\r\\n$$ LANGUAGE sql;\\r\\n\\r\\nCREATE OR REPLACE FUNCTION google_ml.ollama_llm_output_transform(\\r\\n model_id character varying, response json\\r\\n) RETURNS text AS $$\\r\\n SELECT trim(regexp_replace(\\r\\n response->'choices'->0->'message'->>'content',\\r\\n '<think>.*?</think>', '', 's'));\\r\\n$$ LANGUAGE sql;\\r\\n\\r\\nCALL google_ml.create_model(\\r\\n model_id => 'gemma4_llm', -- and/or 'qwen3_8_llm',\\r\\n model_request_url => 'http://ollama-service.ai-demo.svc.cluster.local:11434/v1/chat/completions',\\r\\n model_provider => 'custom',\\r\\n model_type => 'llm',\\r\\n model_in_transform_fn => 'google_ml.ollama_llm_input_transform',\\r\\n model_out_transform_fn => 'google_ml.ollama_llm_output_transform'\\r\\n);\"), ('language', ''), ('caption', <wagtail.rich_text.RichText object at 0x7f7ee10a2810>)])]>\n\nNote: If you receive a Resource not found error, wait a moment for the model to load.\n\nIn addition to registering your model, the above script tells AlloyDB Omni how to interpret the model’s raw output. In this example chain-of-thought (CoT) reasoning is part of the response inside <think></think> tags. We don’t want the CoT, so our output transform function removes it.\n\nStep 5: Try it out!\n\nYou can use functions like ai.generate built-in to AlloyDB Omni to connect to your local model – without ever leaving the SQL client!\n\ncode_block\n\n<ListValue: [StructValue([('code', \"CREATE TABLE customer_feedback (\\r\\n id SERIAL PRIMARY KEY,\\r\\n customer_name TEXT,\\r\\n comment TEXT\\r\\n);\\r\\nINSERT INTO customer_feedback (customer_name, comment) VALUES\\r\\n('Alice', 'I was charged twice on my credit card! Please refund $49 immediately or I will cancel.'),\\r\\n('Bob', 'Great product, but can you please add dark mode support?');\\r\\n\\r\\nSELECT customer_name,\\r\\n ai.generate('Summarize in 1 short sentence: ' || comment,\\r\\n model_id => 'gemma4_llm' /* or 'qwen3_8_llm' */) AS summary\\r\\nFROM customer_feedback;\"), ('language', ''), ('caption', <wagtail.rich_text.RichText object at 0x7f7ee0f9c6d0>)])]>\n\nMake it your own\n\nTry out all the AI features that AlloyDB Omni has to offer! AlloyDB Omni supports fast vector search, built-in AI functions, and more. Give them a try and build something great.", "url": "https://wpnews.pro/news/data-ai-anywhere-alloydb-omni-integration-with-local-models", "canonical_source": "https://cloud.google.com/blog/products/databases/alloydb-omni-integration-with-local-models/", "published_at": "2026-11-23 17:00:00+00:00", "updated_at": "2026-11-23 17:14:56.071230+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "ai-products", "ai-infrastructure", "developer-tools"], "entities": ["Google", "AlloyDB Omni", "Gemma 4", "Google DeepMind", "Qwen3.8", "Google Kubernetes Engine", "PostgreSQL", "Gemini"], "also_reported_by": [], "takeaway": "AlloyDB Omni can now call locally hosted models like Gemma 4 and Qwen3.8 directly from SQL via the google_ml_integration extension's ai.generate() function, keeping data on-premises.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/data-ai-anywhere-alloydb-omni-integration-with-local-models", "markdown": "https://wpnews.pro/news/data-ai-anywhere-alloydb-omni-integration-with-local-models.md", "text": "https://wpnews.pro/news/data-ai-anywhere-alloydb-omni-integration-with-local-models.txt", "jsonld": "https://wpnews.pro/news/data-ai-anywhere-alloydb-omni-integration-with-local-models.jsonld"}}