DEV Community

Alex Spinov
Alex Spinov

Posted on

Spring AI Has a Free API You Should Know About

Spring AI brings AI capabilities to the Spring ecosystem. If you're a Java developer, you can now integrate LLMs, vector stores, and RAG into your Spring Boot apps with familiar patterns.

Why Spring AI for Java Teams

A Java enterprise team needed to add AI features but their stack was entirely Spring Boot. They didn't want to maintain a separate Python service. Spring AI lets them use LLMs with the same dependency injection and configuration patterns they already know.

Key Features:

  • Spring-Native — Dependency injection, auto-configuration
  • Multi-Provider — OpenAI, Anthropic, Ollama, Azure, AWS Bedrock
  • Vector Stores — PostgreSQL/pgvector, Qdrant, Pinecone, Chroma
  • RAG Support — Document readers, transformers, and embedding
  • Function Calling — Map Java methods as LLM tools

Quick Start

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
Enter fullscreen mode Exit fullscreen mode
@RestController
public class ChatController {
    private final ChatClient chatClient;

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

    @GetMapping("/chat")
    public String chat(@RequestParam String message) {
        return chatClient.prompt()
            .user(message)
            .call()
            .content();
    }
}
Enter fullscreen mode Exit fullscreen mode

Structured Output

record MovieRecommendation(String title, String genre, int year) {}

MovieRecommendation movie = chatClient.prompt()
    .user("Recommend a sci-fi movie")
    .call()
    .entity(MovieRecommendation.class);
Enter fullscreen mode Exit fullscreen mode

Why Choose Spring AI

  1. Java-native — no Python, no separate services
  2. Spring patterns — DI, config, testing all work
  3. Enterprise-ready — built for production Java apps

Check out Spring AI docs to get started.


Building enterprise AI? Check out my Apify actors or email spinov001@gmail.com for data extraction.

Top comments (0)