This version is still in development and is not considered stable yet. For the latest stable version, please use Spring AI 2.1.0!

Model APIs

Spring AI defines a portable interface for each type of AI model. Every provider integration implements these interfaces, so application code can change provider without changing the code that calls the model. Chat, transcription and text-to-speech models can also stream their output, and each implementation exposes its provider-specific options.

The model interfaces of Spring AI Seven model interfaces extend the generic Model interface: ChatModel, TranscriptionModel, TextToSpeechModel, EmbeddingModel, ImageModel, ModerationModel and DecisionModel. ChatModel, TranscriptionModel and TextToSpeechModel also extend StreamingChatModel, StreamingTranscriptionModel and StreamingTextToSpeechModel, which extend the generic StreamingModel interface. Model<TReq, TRes>call(TReq): TRes ChatModel TranscriptionModel TextToSpeechModel EmbeddingModel ImageModel ModerationModel DecisionModel StreamingChatModel StreamingTranscriptionModel StreamingTextToSpeechModel StreamingModel<TReq, TResChunk>stream(TReq): Flux<TResChunk> ChatModel, TranscriptionModel and TextToSpeechModel also extend their streaming interface. The other model types answer in one response.
Model type Interface Purpose

Chat

ChatModel

Generates a response to a prompt made of messages.

Embedding

EmbeddingModel

Turns text into vectors for similarity search.

Image

ImageModel

Generates images from text.

Transcription

TranscriptionModel

Converts speech to text.

Text to speech

TextToSpeechModel

Converts text to speech.

Moderation

ModerationModel

Checks text for potentially harmful content.

Decision

DecisionModel

Answers yes/no, choice and score questions.

All of them build on the Generic Model API.

Most applications talk to a chat model through the ChatClient instead of using ChatModel directly.

To see which provider implements which model type, go to Model Providers.