SpringAiModel

class SpringAiModel @JvmOverloads constructor(val name: String, chatModel: ChatModel, coroutineContext: CoroutineContext = Dispatchers.IO) : Model

A Model backed by a Spring AI ChatModel, letting any Spring AI chat provider (OpenAI, Anthropic, Bedrock, Ollama, ...) drive an ADK agent.

The adapter wraps the low-level ChatModel rather than a ChatClient: ADK owns the agent loop, so the model runs a single turn, returns any tool-call requests as ADK function-call parts, and ADK executes the tools. Tools are handed to the model as schema only; Spring AI never executes them (see SpringAiTools.kt).

Parameters

chatModel

The Spring AI chat model to wrap. Streaming requires the model to support it; a model whose provider does not override streaming surfaces Spring AI's own UnsupportedOperationException.

coroutineContext

The coroutine context the blocking Spring AI call runs on; defaults to Dispatchers.IO and is injectable so tests can supply a deterministic dispatcher.

Constructors

Link copied to clipboard
constructor(name: String, chatModel: ChatModel, coroutineContext: CoroutineContext = Dispatchers.IO)

Properties

Link copied to clipboard
open override val name: String

The model name, reported to ADK and traces.

Functions

Link copied to clipboard
open override fun generateContent(request: LlmRequest, stream: Boolean): Flow<LlmResponse>