Skip to content
spring-projectsPublic

About

An Application Framework for AI Engineering

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9.7k stars

Watchers

111 watching

Forks

Latest commit

 

History

4,422 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Spring AI build status Maven Central

The Spring AI project provides a Spring-friendly API and abstractions for developing AI applications.

Its goal is to apply Spring ecosystem design principles, such as portability and modular design, to the AI domain and promote using strongly-typed data structures and APIs as the building blocks of an application.

At its core, Spring AI addresses the fundamental challenge of AI integration: connecting your enterprise Data and APIs with the AI Models.

The building blocks of Spring AI: the ChatClient and its features, the model APIs and providers, vector stores and retrieval, the Model Context Protocol, the Session API, observability, evaluation and resilience, and the Spring AI Community projects

Getting Started

Create a project on start.spring.io with the Spring Web and OpenAI dependencies, set the spring.ai.openai.api-key property, and inject the auto-configured ChatClient.Builder:

@RestController
class ChatController {

    private final ChatClient chatClient;

    ChatController(ChatClient.Builder chatClientBuilder) {
        this.chatClient = chatClientBuilder.build();
    }

    @GetMapping("/ai")
    String ask(@RequestParam(defaultValue = "Tell me a joke") String message) {
        return this.chatClient.prompt()
            .user(message)
            .call()
            .content();
    }

}

The Quickstart explains each step and runs the same code against a local model. From there, continue with:

Spring Boot version compatibility:

Spring AI Branch Spring Boot
2.1.x main 4.2.x
2.0.x 2.0.x 4.1.x
1.1.x 1.1.x 3.5.x

Features

This is a high level feature overview. The reference documentation follows the same structure.

ChatClient

  • ChatClient - Fluent API for communicating with AI chat models, with synchronous and streaming calls, idiomatically similar to the WebClient and RestClient APIs.
  • Advisors - Encapsulate recurring generative AI patterns, transform the data sent to and from the model, and provide portability across models and use cases.
  • Prompts and Templates - Messages, prompt templates and prompt engineering patterns.
  • Structured Output - Mapping of AI model output to POJOs.
  • Multimodality - Images, audio and other media next to text in a message.
  • Tool Calling - Permits the model to request the execution of client-side tools and functions, with Tool Search for large tool sets and Tool Call Confirmation to let a person approve a call.
  • Memory - The Session API keeps a conversation as an append-only log of events, with turn-aware compaction, recall and a JDBC repository.
  • Agents - The advisor chain of a ChatClient and its tools form the agent harness, with examples of the common workflow patterns.

Models

Data and Retrieval

  • Support for all major Vector Store providers such as Amazon Bedrock Knowledge Base, Amazon S3, Apache Cassandra, Azure Vector Search, Chroma, Couchbase, Elasticsearch, GemFire, MariaDB, Milvus, MongoDB Atlas, Neo4j, OpenSearch, Oracle, Oracle Coherence, PostgreSQL/PGVector, Pinecone, Qdrant, Redis, Typesense, and Weaviate.
  • Portable Vector Store API across providers, including a novel SQL-like metadata filter API.
  • Document ingestion ETL framework for Data Engineering, with document readers for PDF, Markdown, HTML, Office formats and more.
  • Retrieval Augmented Generation (RAG) - Out-of-the-box RAG flows as advisors, and a modular architecture to build your own.
  • Semantic Caching - Returns a cached response to a semantically similar request.

Model Context Protocol

  • MCP (Model Context Protocol) - First-class support via Boot Starters and MCP Java Annotations for building AI applications that consume MCP servers or expose Spring-based services to the AI ecosystem, for both the modern and the legacy generation of the protocol.

Across the Application

  • Observability - Metrics and traces for the ChatClient, advisors, models, tool calls and vector stores.
  • Evaluation and Testing - Utilities to help evaluate generated content and protect against hallucinated responses, with Testcontainers and Docker Compose support.
  • Resilience and Safety - Retry of failed model calls, and guardrails for unwanted content.
  • Spring Boot Auto Configuration and Starters for all AI Models and Vector Stores - use start.spring.io to select the Model or Vector Store of choice.

Community

  • Community-maintained projects add agent tools, MCP security, agent protocols and more model and vector store integrations. They follow their own release schedule and support terms, which that page describes.

Project Resources

Building from source

You don’t need to build from source to use Spring AI. If you want to try out the latest and greatest, Spring AI can be built and published to your local Maven repository:

./mvnw clean install

This command builds all modules, runs unit tests, and publishes artifacts to your local Maven repository.

Please read our contribution guidelines for more details.

Contributing

We welcome contributions of all kinds! Please read our contribution guidelines before submitting a pull request or an issue.

About

An Application Framework for AI Engineering

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9.7k stars

Watchers

111 watching

Forks

Releases

Used by

Contributors

Languages