RAG on CDS

Answering a question from your own data rather than from what a model remembers — embeddings stored beside the records they describe, and a similarity search that runs where the data already is.

Overview

SAP SHIPS
Node.js →

@cap-js/ai Out-of-the-box value-help recommendations powered by SAP RPT-1, SAP AI Core as a standard CAP service, and an experimental local embedding model behind SQLite's vector functions.

@sap/cds Carries the modelled half: the Vector type is built into CDS and the vector functions are part of the query language, so an embedding is an element of an entity and a retrieval is a WHERE clause. vector_embedding turns a text into a vector, cosine_similarity and l2distance compare two, and a stored calculated element keeps a row's embedding in the database and recomputes it whenever the row changes. Splitting a text into chunks and assembling what was found into a prompt are not here.

Not covered: At the vector. Which text of a record gets embedded, how a text too long for one embedding is split, how many rows go into the prompt and what the prompt says are written by hand in every entry here, and capire's guide documents no chunking. On PostgreSQL capire states that CAP provides no built-in vector_embedding, so the embedding is computed in the application or by a custom database function, and the local embeddings in @cap-js/ai are declared experimental and intended for local development only.

Both are present because the core answers the modelled half and the layer above it is written in every entry here. No source states why each stops where it does, so the relationship stays unassessed.

Built into @sap/cds
THE COMMUNITY ADDS

What the community adds is that layer above the vector. cap-llm-plugin folds the similarity search, the embedding and the model call into one retrieval method, and @saptarishi/cds-plugin-vector-hana keeps a vector table in step with an annotated entity and declares the search and the ask as actions on it. mi8y-cap-agents-aicore-vectorstore takes the other route and reaches an AI Core Document Grounding collection through the LangChain vector store interface, so the application stores no vectors.

Licence1

LicenceSAP Developer License Agreement 3.2 CAP§ 3AlwaysCovered SAP materials or a covered CAP customer application are included in training data, model development or model refinement.
  • § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.

Retrieval and inference are not automatically AI training. The section becomes relevant if the indexed or retrieved covered material is instead used for training, developing or refining the model or system.

SAP Developer License Agreement 3.2 CAP →

Artifacts9

9 of 9 artifacts
ArtifactSignals
CDS plugins4
@cap-js/aiValue-help recommendations and SAP AI Core as a CAP service
Signals
Use terms
@saptarishi/cds-plugin-llmCAP service kind putting eleven model providers behind one API
Signals
Use terms
@saptarishi/cds-plugin-vector-hanaVector storage and similarity search on SAP HANA from CAP
Signals
Use terms
cap-llm-pluginGenerative AI in CAP with fields anonymised through SAP HANA
Signals
Functional boundary+1
Packages3
@mi8y/cap-agents-aicore-vectorstoreLangChain vector store on SAP AI Core Document Grounding
Signals
none
@mi8y/cap-agents-cds-vectorstoreLangChain vector store with CDS entities for embeddings
Signals
none
@sap/cdsCAP Node.js runtime
Signals
none
Services2
SAP AI CoreAI runtime on BTP with the Generative AI Hub
Signals
none
SAP HANA CloudManaged SAP HANA database service on BTP
Signals
Functional boundary

Tasks1Beta

CoversCovers, under conditionsNot assessed
Answer a question from records in a CAP service3 covers, 3 under conditions

A question asked in plain words is answered from rows the CAP model already holds: the records nearest to the question in meaning are found and put in front of a language model, so the answer rests on those records rather than on what the model remembers.

Covers embedding the records, finding the nearest ones and getting them into the prompt. The call to the model is LLM integration, answering from documents in a connected repository is document grounding on the BTP door, and who may see a retrieved row is authorization. Which entitlements a subaccount holds is a project question and is not assessed here.

Covers@sap/cdsThe Vector type is built into CDS, so the embedding is an element of the entity it describes, and vector_embedding, cosine_similarity and l2distance are functions of the query language, so the retrieval is a WHERE clause and not a call to anything outside the model. A stored calculated element keeps a row's embedding in the database and recomputes it whenever the row changes on CREATE or UPDATE, which answers the question of when a record's vector is written.

Remaining work: Everything above the vector: choosing which fields of a record are embedded, splitting a text too long for one embedding, deciding how many rows to take and writing the prompt they go into. capire's guide documents no chunking function and no prompt assembly.

Open artifact →

Covers@saptarishi/cds-plugin-llmThe half the store composes with: the provider that produces the embeddings and runs the chat call, with the model chosen there rather than in the store. The store's README names it for exactly that, and lists the providers it can be pointed at.

Remaining work: Configure a provider and its credentials. Which model is used, and what it costs, is decided in this package and not in the store.

Open artifact →

Covers@saptarishi/cds-plugin-vector-hanaMoves the embed-on-write and the search into the model: a @rag annotation on an entity names the fields to embed, the plugin builds the vector table and keeps it in sync on every CRUD operation, and what is embedded is one row's projected fields as one vector. A SQLite fallback ships with it, so the same code runs on a laptop without SAP HANA Cloud.

Remaining work: Choose the fields to embed and install a provider for the embedding and chat calls, which are not in this package. A record whose text does not fit one vector is not addressed: the README describes no chunking. The README says its HANA backend is verified against a mock hdb client and not yet against a HANA Cloud instance, which it names as its top open item; the SQLite backend is what its integration tests exercise.

Open artifact →

Covers, under conditions@cap-js/aiMakes the similarity search on a laptop behave like the one in the database. Without it, capire states that SQLite and H2 emulate vector_embedding with lexical character-hash vectors, which match spelling rather than meaning; with it, the standard sqlite database generates semantic embeddings from a local ONNX model and no external service is called.

Conditions: @sap/cds ^10.1 and @cap-js/sqlite ^3.1, the versions capire states the local embeddings require Local development: the README calls the facility experimental and sends production vector workloads to SAP HANA's vector engine

Remaining work: Install the plugin in a project on the stated versions. The retrieval, the prompt and the model call are the same work as on the core path, and the answer still has to be built somewhere else for production.

Open artifact →

Covers, under conditionsSAP HANA CloudHolds the vectors in the same database as the records: REAL_VECTOR is an SQL data type of the vector engine, and COSINE_SIMILARITY and L2DISTANCE are its functions, which is what the CDS Vector type and the CQL functions map to. capire adds where the embedding model itself comes from on this database, the NLP extension or an SAP AI Core remote source, so the text-to-vector step can run inside the database rather than in the application.

Conditions: The application's database is SAP HANA Cloud. On the CAP-native way that is the way itself. On the way through [@saptarishi/cds-plugin-vector-hana](artifact:saptarishi-cds-plugin-vector-hana) it is the store's HANA backend rather than the SQLite fallback the README ships for a laptop, and that README says the HANA backend is verified against a mock client and not yet against a HANA Cloud instance.

Remaining work: Provision the database and, for vector_embedding, make an embedding model reachable from it. Nothing here retrieves for a question or writes a prompt.

Open artifact →

Covers, under conditionscap-llm-pluginCollapses the steps into one method: the README's retrieval feature embeds through SAP AI Core, searches SAP HANA Cloud's vector engine and hands the result to the model, with the embedding and the similarity search also available on their own for a handler that wants them apart.

Conditions: The vectors are in SAP HANA Cloud's vector engine, which every retrieval feature in the README is written against An SAP AI Core binding provides the embedding and chat models

Remaining work: Fill the vector table first: the README describes generating embeddings and searching them, and neither chunking nor an embed-on-write handler is part of it. The README also states that the plugin is not an official SAP product and is published as a community contribution.

Open artifact →

Content16

Group by16 of 16 pieces
Piece, what it offers
CAP in the age of AI #7 - vector embeddings wrap-up
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, part 7 of 7, Video
CAP in the age of AI #6 - vector embeddings
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, Daniel Schlachter, part 6 of 7, Video
CAP in the age of AI
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, Simon Engel, Stefan Rudi, Daniel Schlachter, Series
Show 6 more
Generative AI on SAP BTP
SAP Architecture Center, SAP Architecture Center, Reference architectureThe reasoningA reference
Core changed
HANA Cloud’s VECTOR EMBEDDING in CAP and Comparison with OpenAI Embedding
SAP Community, lalitmohan, BlogThe reasoningA recipeRunnable code
Using HANA Cloud’s "VECTOR_EMBEDDING" Function in CAP
SAP Community, Mio Yasutake, BlogThe reasoningRunnable code
RAG with SAP HANA Cloud Vector Engine, GenAI Hub & CAP
SAP Community, KevinR, BlogThe reasoningA recipeRunnable code
Document Grounding
SAP BTP AI Best Practices, SAP, DocThe reasoningA reference
Building agentic applications with SAP HANA Cloud
SAP TechEd — session catalogue, TalkA recipe
CAP in the age of AI #7 - vector embeddings wrap-up
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, part 7 of 7, Video
CAP in the age of AI #6 - vector embeddings
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, Daniel Schlachter, part 6 of 7, Video
Document Grounding
SAP BTP AI Best Practices, SAP, DocThe reasoningA reference
Show 2 more
Building agentic applications with SAP HANA Cloud
SAP TechEd — session catalogue, TalkA recipe
🟣 Bring AI into Your ABAP Applications with ISLM: Build, Integrate, and Consume AI Natively
YouTube — SAP Developers playlists, SAP Developers, Talk
CAP in the age of AI #7 - vector embeddings wrap-up
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, part 7 of 7, Video
CAP in the age of AI #6 - vector embeddings
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, Daniel Schlachter, part 6 of 7, Video
Building agentic applications with SAP HANA Cloud
SAP TechEd — session catalogue, TalkA recipe
Show 6 more
Accelerating Your Analytics with Delta Table Replication into SAP HANA Cloud
SAP Community, SeungjoonLee, Blog
Talking to your database: The new data exploration tools in SAP HANA Cloud
SAP TechEd — session catalogue, TalkThe reasoning
Build AI agents and applications natively on SAP HANA Cloud
SAP TechEd — session catalogue, TalkThe reasoning
Road map for SAP HANA Cloud: What’s next for the AI database
SAP TechEd — session catalogue, Thomas Hammer, TalkThe reasoning
SAP HANA Cloud: The data foundation for contextualizing and reasoning
SAP TechEd — session catalogue, TalkThe reasoning
SAP HANA Cloud as the AI database for SAP Business Data Cloud
SAP TechEd — session catalogue, Thomas Hammer, TalkThe reasoning
CAP in the age of AI #7 - vector embeddings wrap-up
YouTube — SAP Developers playlists, DJ Adams, Johannes Vogt, part 7 of 7, Video
HANA Cloud’s VECTOR EMBEDDING in CAP and Comparison with OpenAI Embedding
SAP Community, lalitmohan, BlogThe reasoningA recipeRunnable code
RAG with SAP HANA Cloud Vector Engine, GenAI Hub & CAP
SAP Community, KevinR, BlogThe reasoningA recipeRunnable code

Seen working7

ArtifactSignals
Samples7
cap-bp-ragEvent-driven RAG app with CAP, Cloud Integration and SAP HANA Cloud
No license
cap-embedding-functionCAP service computing embeddings with HANA Cloud vector_embedding
none
cap-vector-hcVECTOR_EMBEDDING in a CDS entity for FAQ similarity search
No license
SAP BTP AI Best Practice Demo - Vector Embedding (RAG) - CAPCAP samples embedding CSV rows into the SAP HANA Cloud vector store
Functional boundary
SAP BTP AI Best Practice Demo - Vector Query (RAG) - CAPCAP samples running RAG similarity queries over SAP HANA Cloud vectors
Functional boundary
SAP-samples/btp-cap-genai-ragCAP reference app for GenAI email support with RAG on HANA Cloud
none
SAP-samples/btp-cap-genai-semantic-searchCAP sample for semantic search with Generative AI Hub and HANA Cloud
none

Details

What changed — and what it makes stale1
CAP Java 4.9.0, CAP, Java

Before this, the core's similarity function was HANA's alone, and turning text into a vector at query time meant calling SAP HANA's VECTOR_EMBEDDING directly rather than through a CQL function. CAP Java gained CQL.vectorEmbedding, which calls VECTOR_EMBEDDING for you, and CQL.cosineSimilarity / CQL.l2Distance now work — per capire — as 'Retrieval-augmented generation (RAG) with vector embeddings on all the four databases,' not just HANA. It ships Beta and CAP-Java-only; Node.js has no equivalent. CAP Java 4.9.0 reached Maven Central on 2026-04-23.

Makes stale:

Guidance that the CAP-modelled similarity function only ever runs against HANA, or that turning text into a query-time vector always means a raw HANA call outside CQL — true for CAP Java before April 2026, not since. It does not touch Node.js, and it does not touch chunking or the embed-on-write pipeline, which is still every entry in this capability's own job.

SourceCAP Release April 26 — capirechecked
Coverage
Designs that place it1
Integrating and Extending JouleIntegrating and Extending Joulereference architecturedocument grounding in customer-owned content
For your agent
Ref
capability:retrieval-augmented-generation
JSON
/capabilities/retrieval-augmented-generation.json
MCP
Connecting an agent