Ground AI and agents in enterprise data
Build RAG pipelines, agent tools, and application search on one retrieval layer. Combine vector, full-text, and keyword search with SQL over live, structured, and unstructured data.

Do more with your data
100x
up to 100x faster queries
80%
up to 80% cost savings on data lakehouse spend
2x
Increase in data reliability
RAG breaks down without unified, real-time data
Good retrieval blends keyword search for precision, full-text search for context, and vector search for meaning. Fragmented RAG pipelines split these methods across separate search engines, connectors, and model APIs. Models and agents then answer from incomplete or outdated data, which leads to hallucinations, inconsistent results, and production risk.
How do you build a RAG pipeline with Spice?
Define your data, an embedding model, and a chat model in one spicepod.yaml file. Spice indexes the text columns you choose for vector and full-text search. Your application or agent then retrieves context with SQL and sends it to the model through the same runtime.
- Connect: add a dataset for each source. Turn on acceleration to keep a local copy for fast retrieval.
- Index: add
embeddingsandfull_text_searchto the text columns. Spice creates the vectors and a BM25 full-text index. - Retrieve: call
vector_search(),text_search(), andrrf()in SQL, or call the/v1/searchHTTP API. - Generate: pass the results to a chat model with the
ai()SQL function, the OpenAI-compatible/v1/chat/completionsAPI, or an agent.
The following Spicepod indexes the body column of a PostgreSQL tickets table for hybrid search:
version: v1
kind: Spicepod
name: support-rag
embeddings:
- from: openai:text-embedding-3-small
name: embed
params:
openai_api_key: ${secrets:OPENAI_API_KEY}
models:
- from: openai:gpt-4o-mini
name: assistant
params:
openai_api_key: ${secrets:OPENAI_API_KEY}
tools: auto
datasets:
- from: postgres:public.tickets
name: tickets
params:
pg_host: ${secrets:PG_HOST}
pg_db: support
pg_user: ${secrets:PG_USER}
pg_pass: ${secrets:PG_PASS}
acceleration:
enabled: true
columns:
- name: body
embeddings:
- from: embed
row_id: id
full_text_search:
enabled: true
row_id: idHow do you run hybrid search in SQL?
Run each search as a table function, then merge the ranked lists with rrf(). Reciprocal Rank Fusion (RRF) scores each row by its rank in each list. Rows that rank high in both lists move to the top:
SELECT id, body, _fused_score
FROM rrf(
vector_search(tickets, 'customer cannot reset password'),
text_search(tickets, 'password reset', body),
join_key => 'id'
)
ORDER BY _fused_score DESC
LIMIT 5;Results are rows, so you can join and aggregate them like any other table. To tune relevance per query, give a search a rank_weight. To boost recent rows, set time_column and a recency_decay function. To reorder the top results with a reranker or a chat model, wrap the query in rerank().
Which retrieval method fits which question?
| Method | SQL function | Best for |
|---|---|---|
| Vector search | vector_search() | Natural-language questions and matches by meaning |
| Full-text search (BM25) | text_search() | Exact terms, product names, error codes, and IDs |
| Hybrid search | rrf() | Questions that mix concepts and keywords |
| Reranking | rerank() | Higher precision in the top results before generation |
| SQL over structured data | SELECT with joins and filters | Facts such as account status, order totals, and permissions |
How do AI agents use Spice for retrieval?
Agents call Spice tools instead of a fixed retrieval step. The built-in search tool runs hybrid search. The sql tool queries structured data, and list_datasets and table_schema show what data exists. Expose these tools to an external agent through the MCP server at /v1/mcp. Or set tools: auto on a model in your Spicepod, so the model calls the tools itself during a chat completion.
Where does retrieval run?
Spice runs as one process next to your application, in your cloud, or as a managed service on Spice Cloud. Accelerated datasets and their search indexes stay in that runtime, so retrieval reads the local copy and does not query each source. Store large vector sets in Amazon S3 Vectors to search millions or billions of embeddings without an always-on vector database. For the model side of the pipeline, see LLM inference and AI model serving. To join retrieved text with data from many sources, see SQL Federation and Acceleration.
Build data-grounded AI faster
Deliver accurate, context-rich results by combining SQL federation, hybrid search, and LLM inference in one governed runtime.
Federate structured data
Query operational and analytical data across databases, object stores, and APIs using standard SQL. All in real time with zero ETL.
Learn more about Spice federation
Search and embed unstructured data
Create embeddings from text, documents, or logs using local or hosted models. Run vector similarity search directly inside Spice to find relevant context, semantic matches, and related insights instantly.
Learn how hybrid search works
Retrieve and augment intelligently
Blend structured SQL results and semantic search results in one query using hybrid search. Deliver precise, context-rich data to your LLMs without manual data engineering or pipeline maintenance.
Learn about real-time hybrid search using RRF
Generate insights with the AI Gateway
Invoke and run models like OpenAI, Anthropic, or local LLMs directly in SQL queries. Feed retrieved context into the model and generate accurate, compliant, and contextual results within the same SQL workflow.
Explore LLM inference and AI model serving
Hybrid search in one SQL query
Run vector, full-text, and keyword search in standard SQL, next to your filters and joins. Scale to billions of embeddings without a separate search engine or ETL pipeline.
Compose hybrid search in SQL
Call vector_search and text_search in one query, and fuse the results with rrf(). Results are tables, so you can filter, join, and aggregate them with the rest of your data.
Explore search features

Tune relevance per query
Set a rank_weight on each search, and add a recency decay on a time column to rank newer rows higher. Reciprocal Rank Fusion merges ranks, so scores on different scales need no normalization.
Explore Reciprocal Rank Fusion

Search billions of vectors in Amazon S3
Store, index, and retrieve embeddings with partitioned Amazon S3 Vectors indexes. Spice manages ingest, refresh, and metadata for each index, and embeds with hosted or local models.
See S3 Vectors docs

Serve hot data locally
Materialize hot data with DuckDB, SQLite, or Spice Cayenne acceleration, and keep large vector indexes in object storage. Index-only reads and filter pushdown keep common queries predictable.
Explore Spice Cayenne

Give agents retrieval as a tool
Agents call the built-in search and SQL tools over the Model Context Protocol (MCP), or through a model that Spice serves. Each tool call runs hybrid search or SQL in the same runtime, over only the datasets in the Spicepod.

Trusted by teams building intelligent applications
Run data-intensive workloads on a high-performance engine trusted by teams building real-time systems at scale.

“Partnering with Spice AI has transformed how NRC Health delivers AI-driven insights. By unifying siloed data across systems, we accelerated AI feature development, reducing time-to-market from months to weeks - and sometimes days. With predictable costs and faster innovation, Spice isn't just solving some of our data and AI challenges - it's helping us redefine personalized healthcare.”
Tim Ottersburg
VP of Technology, NRC Health

“Spice AI grounds AI in our actual data, using SQL queries across many data sources. This brings accuracy to probabilistic AI systems, which are very prone to hallucinations.”
Rachel Wong
CTO, Basis Set
Trusted by global enterprises
Build a scalable RAG app
Guides and examples to learn more about building RAG applications with Spice.
Hybrid Search Docs
Spice provides robust search capabilities enabling developers to query datasets beyond traditional SQL, including semantic (vector-based) search, full-text keyword search, and hybrid search methods.
True Hybrid Search: Vector, Full-Text, and SQL in One Runtime
TL;DR Show Me the (Data)! It’s well established (and maybe even trite) to say that enterprises are going all-in on artificial intelligence, with more than $40 billion directed toward generative AI projects in recent years. The initial results have been underwhelming. A recent study from the Massachusetts Institute of Technology's NANDA initiative concluded that despite the enormous allocation of […]
Real-Time Hybrid Search Using RRF: A Hands-On Guide with Spice
Surfacing relevant answers to searches across datasets has historically meant navigating significant tradeoffs. Keyword (or lexical) search is fast, cheap, and commoditized, but limited by the constraints of exact matching. Vector (or semantic) search captures nuance and intent, but can be slower, harder to debug, and expensive to run at scale. Combining both usually entails standing up multiple engines […]
FAQs
Answers to common questions about building RAG pipelines and agentic retrieval with Spice
Agentic retrieval is retrieval that an AI agent directs. The agent decides when to search, which datasets to query, and how to refine a query after it reads the results. In Spice, agents call the built-in search and sql tools through the MCP server gateway or through a model with tools: auto.
RAG reduces hallucinations by grounding model responses in data retrieved at query time instead of relying only on training data. Models grounded in incomplete or outdated data are more likely to hallucinate, so retrieval quality and freshness matter as much as the model itself. Spice retrieves live, governed data with SQL and hybrid search so the context passed to the model stays accurate.
Hybrid search combines vector similarity search and BM25 full-text search. In SQL, call vector_search() and text_search(), then merge the two ranked lists with rrf() (Reciprocal Rank Fusion). Results are rows, so you can join and aggregate them like any other table. The /v1/search HTTP API runs vector search across one or more datasets.
No. Spice creates embeddings with local or hosted models and runs vector similarity search inside the runtime. A vector database usually needs other systems for text search, keyword search, and joins with structured data. Spice runs all of these in one runtime that you can deploy locally, in your cloud, or as a managed service.
Yes. Spice federates queries across databases, object stores, and APIs with standard SQL. One query can retrieve structured records and combine them with semantic search results. This grounds model responses in operational data without manual data engineering.
Use hosted models from providers such as OpenAI, Anthropic, and Amazon Bedrock, or run local models, through the Spice AI Gateway. Call a model in SQL with the ai() function, so retrieved rows go to the model in the same query. Use a prompt in ai() to classify, label, or summarize each search result. See LLM inference and AI model serving for how model serving works in Spice.
The rrf() SQL function merges the result sets with Reciprocal Rank Fusion. Each search can set a rank_weight, and time_column with recency_decay boosts recent rows. Give keyword search more weight for exact lookups, and vector search more weight for natural-language questions. To reorder the top results with a reranker model or a chat model, wrap the query in rerank().
Spice keeps a local copy of hot data with DuckDB, SQLite, or Spice Cayenne acceleration, so retrieval does not query each source. Store large vector sets in Amazon S3 Vectors, which holds millions or billions of embeddings without always-on compute. To answer repeated searches without running them again, turn on the search results cache.
See Spice in action
Walk through your use case with an engineer and see how Spice handles federation, acceleration, and AI integration for production workloads.
Talk to an engineer (opens in a new tab)







