Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Explain the roles of ChatModel, ChatClient, EmbeddingModel and VectorStore in Spring AI and how they relate to each other.

ChatModel is Spring AI's low-level, provider-specific interface: it takes a Prompt and returns a ChatResponse. ChatClient is the fluent API we use in application code, built on top of a ChatModel, adding defaults, advisors, tools and structured output. EmbeddingModel turns text into vectors, and VectorStore stores documents with their embeddings and finds the most similar ones; implementations include PGvector, Redis, Elasticsearch and others. Swapping providers is mostly configuration, but options and features still differ between providers.

Why this question is asked

Spring AI has many types, and the first week with it often goes into working out which one to inject. Interviewers ask this question because knowing the four core abstractions, and how they fit together, is the difference between using the framework and fighting it. The same four types show up in every chat feature, every retrieval feature and every test. In this answer, we will look at each abstraction in turn with a short example, see how they connect in a retrieval feature, and finish with what portability between providers really means.

1ChatModel: the Low-Level Interface

ChatModel is the interface every chat provider implements: OpenAiChatModel, AnthropicChatModel, OllamaChatModel and so on. Its central method takes a Prompt, which is a list of messages (system, user, assistant) plus options such as temperature, and returns a ChatResponse, which holds one or more generations and metadata such as token usage and the model name.

Java
ChatResponse response = chatModel.call(new Prompt(
List.of(new SystemMessage("Answer in one sentence."), new UserMessage("What is a JVM?")),
ChatOptions.builder().temperature(0.2).build()));
String text = response.getResult().getOutput().getText(); // "The JVM is the virtual machine that runs Java bytecode."
Integer tokens = response.getMetadata().getUsage().getTotalTokens(); // 31

Notice how much ceremony this is for one question. That is deliberate: ChatModel is the provider integration point, and it is also what we replace with a fake in tests. Application code rarely calls it directly. The exact accessor names on messages, such as getText(), have changed between versions, so check yours.

2ChatClient: the Fluent API on Top

ChatClient wraps a ChatModel and gives us a fluent request builder. It is where the useful features live: default system text and options for the client, advisors that add behaviour such as memory or retrieval, tools the model may call, and structured output that converts the answer into a Java type.

Java
ChatClient chatClient = ChatClient.builder(chatModel) // or the auto-configured builder
.defaultSystem("Answer in one sentence.")
.build();
String text = chatClient.prompt().user("What is a JVM?").call().content();
// "The JVM is the virtual machine that runs Java bytecode."
record Definition(String term, String meaning) {}
Definition d = chatClient.prompt().user("Define JVM").call().entity(Definition.class);
// Definition[term=JVM, meaning=Java Virtual Machine, runs bytecode]

So the relationship is simple: ChatClient builds a Prompt, passes it through its advisors, calls ChatModel, and post-processes the ChatResponse. One ChatModel can sit behind several ChatClients with different defaults.

3EmbeddingModel: Text to Vectors

An embedding is a list of numbers, a vector, that represents the meaning of a text. Texts with similar meaning have vectors that point in similar directions, so we can measure similarity with a calculation such as cosine similarity. EmbeddingModel is the interface for models that produce these vectors, again with one implementation per provider.

Java
float[] a = embeddingModel.embed("How do I reset my password?");
float[] b = embeddingModel.embed("I forgot my login credentials");
float[] c = embeddingModel.embed("Quarterly revenue grew 8 percent");
System.out.println(a.length); // 1536 (depends on the model)
// cosine(a, b) = 0.83 similar meaning
// cosine(a, c) = 0.12 unrelated

Embedding models are separate from chat models and much cheaper. A service often uses one provider's chat model and another's embedding model, or a local embedding model, and Spring AI keeps them as separate beans for that reason.

4VectorStore: Storing and Searching Embeddings

A VectorStore keeps Documents, each a piece of text with metadata, together with their embeddings, and answers similarity searches: give me the five documents closest to this question. It uses an EmbeddingModel internally, so when we add documents it embeds them, and when we search it embeds the query. Implementations include PgVectorStore for PostgreSQL with the pgvector extension, Redis, Elasticsearch, and many dedicated vector databases.

Java
vectorStore.add(List.of(
new Document("Passwords can be reset under Settings > Security.", Map.of("source", "help-12")),
new Document("Invoices are sent on the 1st of each month.", Map.of("source", "help-40"))));
List<Document> hits = vectorStore.similaritySearch(
SearchRequest.builder().query("forgot my password").topK(1).build());
System.out.println(hits.get(0).getMetadata().get("source")); // help-12

5How the Four Fit Together

The four abstractions meet in a retrieval feature. At ingestion time, the VectorStore uses the EmbeddingModel to store documents. At question time, an advisor on the ChatClient searches the VectorStore, adds the matching text to the prompt, and the ChatClient sends the enlarged Prompt to the ChatModel. Our code only talks to ChatClient and, for ingestion, to VectorStore.

Step throughSpring AI's core abstractions
  1. Application codecalls ChatClient and, for ingestion, VectorStore
  2. ChatClientfluent API: defaults, advisors, tools, entity()
  3. Advisorsmemory, retrieval from VectorStore
  4. ChatModelprovider chat API: Prompt in, ChatResponse out
  5. VectorStoredocuments plus embeddings, similarity search
  6. EmbeddingModelprovider embedding API: text in, vector out

6 layers, from the top down. Step through them one at a time.

ChatClient sits on ChatModel; VectorStore sits on EmbeddingModel.

6What Swapping Providers Really Means

Because our code depends on the interfaces, moving from one provider to another is mostly a change of starter dependency and properties. But it is not free. Options differ: one provider supports a seed, another does not; maximum context sizes differ; tool calling and native structured output have different capabilities. Embeddings are the hardest case. Vectors from two different embedding models are not comparable, so switching the EmbeddingModel means re-embedding every document in the VectorStore. Prompts tuned for one model also behave differently on another, which is why a switch needs a run of our evaluation set, not just a configuration change.

7Follow-up questions

Why does ChatModel exist if everyone uses ChatClient?

Because it is the stable boundary between Spring AI and each provider. Provider modules implement ChatModel, and ChatClient builds all its features once, on top of that interface. It is also the simplest thing to replace with a fake in a unit test.

Is VectorStore only for retrieval-augmented generation?

No. Any similarity search works: finding duplicate tickets, recommending related articles, or grouping customer feedback. Retrieval for prompts is just the most common use.

Can I use the same vector store with two embedding models?

Not in the same index. Each model produces vectors in its own space, often with a different number of dimensions, so a query embedded with model B cannot be compared meaningfully with documents embedded with model A. Keep separate collections and record the embedding model version with each document.

8Conclusion

In this answer, we saw that ChatModel is the provider-specific interface that turns a Prompt into a ChatResponse, and that ChatClient is the fluent API on top of it with defaults, advisors, tools and structured output. EmbeddingModel turns text into vectors, and VectorStore stores documents with those vectors and runs similarity searches through implementations such as PGvector, Redis and Elasticsearch. They combine in retrieval features, and while swapping providers is mostly configuration, options, features and especially embeddings differ.

What to say in the interviewAbout 90 seconds aloud

Open with

ChatModel is the low-level interface each provider implements, like the OpenAI or Anthropic chat model. It takes a Prompt, which is a list of system, user and assistant messages plus options such as temperature, and returns a ChatResponse with the generated message and metadata like token usage.

Then, if they want more

ChatClient is what I use in application code. It is a fluent API built on a ChatModel, so I write prompt, user, call, content, and it adds the features I need: default system text and options, advisors for things like chat memory and retrieval, tool calling, and entity() to map the answer onto a Java record.

EmbeddingModel is the separate interface for embedding models, which turn text into a vector so that similar meanings end up close together. VectorStore stores documents with their embeddings and metadata and does similarity search; it uses an EmbeddingModel to embed documents on add and the query on search, and there are implementations for PGvector, Redis, Elasticsearch and others.

In a retrieval feature they all connect: a retrieval advisor on the ChatClient searches the VectorStore and adds the results to the prompt that goes to the ChatModel. Because I code against interfaces, switching provider is mostly configuration, but options and features differ, prompts need re-testing, and changing the embedding model means re-embedding everything.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring AI reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain the roles of ChatModel, ChatClient, EmbeddingModel and VectorStore in Spring AI...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/d30054f151/