Expedition. Free, on-demand.

Technical tracks for practitioners, outcomes for leaders.

What is Snowflake Cortex?

Snowflake Cortex runs AI models inside Snowflake. You call them as SQL functions, so you don't have to send data to an outside LLM provider or run your own GPUs.

For a Postgres app, the split is simple. Postgres stays your operational database, and Cortex does the AI work when you ask for it.

How It Works with Postgres

Your application keeps two connections:

  1. Postgres, where your data lives. Query it with regular SQL from any Postgres driver.
  2. Snowflake, where Cortex runs. Call Cortex functions with the Snowflake Python connector, Snowpark, or any other Snowflake client.

Your source data stays in Postgres. You send Cortex just the text you want processed (to generate text, produce embeddings, translate, and so on), then use the results in your app or write them back to Postgres.

If you'd rather move data in bulk than call Cortex row by row, pg_lake can exchange files and Iceberg tables between Snowflake Postgres and Snowflake.

Cortex AI Functions

FunctionWhat It Does
AI_COMPLETEGenerate text from a prompt using a hosted LLM
AI_EMBEDGenerate vector embeddings for semantic search
AI_EXTRACTExtract structured information from text
AI_CLASSIFYClassify text into categories you define
AI_SENTIMENTScore the sentiment of text
AI_SUMMARIZE_AGGSummarize across multiple rows
AI_TRANSLATETranslate text between languages

AI_COMPLETE is the newer name for SNOWFLAKE.CORTEX.COMPLETE. The older function still shows up in a lot of example code, but use AI_COMPLETE for new work.

All of these are SQL expressions. Your app sends a query to Snowflake, Cortex runs the model, and you get the result back. There's no model hosting on your side.

Text-to-SQL with AI_COMPLETE

You can use AI_COMPLETE to put a natural-language query interface on top of your Postgres data. The flow looks like this:

  1. Your app sends the user's question plus your Postgres schema (table and column names, maybe a few sample rows) to AI_COMPLETE.
  2. The model writes a SQL query.
  3. Your app runs that SQL against Postgres.
  4. You render the results as a table or chart.

Run the generated SQL as a read-only Postgres role with a statement_timeout set. LLMs write plausible SQL, not always correct or cheap SQL, and you don't want a hallucinated DELETE anywhere near production.

Generating Embeddings with Cortex

Cortex can generate embeddings that you store in Postgres with pgvector, so you don't have to host an embedding model.

  1. Send text to AI_EMBED over your Snowflake connection.
  2. Cortex returns a vector.
  3. Store it in a pgvector vector column in Postgres.
  4. Query with pgvector's distance operators for similarity search.

Available Embedding Models

ModelDimensionsBest For
snowflake-arctic-embed-l-v2.01024High accuracy, general purpose
snowflake-arctic-embed-l-v2.0-8k1024Longer documents (8K token context)
snowflake-arctic-embed-m-v1.5768Good balance of speed and accuracy
voyage-multilingual-21024Multilingual content

Model availability can vary by region, so check the Cortex docs for your account. Size the pgvector column to match the model, for example vector(1024) for the Arctic L models.

Once the embeddings are in Postgres, similarity search runs at application speed, and you can combine vector retrieval with regular relational filters in one query. AI in Postgres covers pgvector indexing, hybrid search, and filtering in detail.

Building a RAG Application

Retrieval-Augmented Generation (RAG) grounds LLM answers in your own data. With Cortex and Postgres it looks like this:

  1. Call AI_EMBED on your documents (usually in chunks) and store the vectors in Postgres with pgvector.
  2. When a user asks a question, call AI_EMBED on the question with the same model.
  3. Search Postgres with pgvector to find the most similar chunks.
  4. Pass those chunks and the question to AI_COMPLETE to get a grounded answer.

Your application orchestrates the steps. Postgres holds the data and embeddings, and Cortex provides the models on demand.

If you want managed semantic search instead of building your own embedding pipeline, Cortex Search handles chunking, embedding, indexing, and retrieval for you.

It does hybrid retrieval, combining vector and keyword search. It generates the embeddings itself, and it keeps the index up to date as the underlying data changes.

Cortex Search works over data in Snowflake, so you first need your Postgres tables there. Use pg_lake to sync them as Iceberg tables, then create a Cortex Search service on top for hybrid search over your operational data.

Conclusion

Cortex gives your Postgres applications LLMs and embedding models without any AI infrastructure to run. Your data stays in Postgres, Cortex does the model work, and your application ties them together.

Related Resources

Reference for Snowflake Cortex AI functions, including AI_EMBED, AI_COMPLETE, AI_EXTRACT, and more.


Overview of Snowflake Cortex AI capabilities.


Open-source vector similarity search extension for Postgres.


Move Postgres data to Snowflake for analytics and AI processing.

Updated Oct 27, 2026

This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances