A lightweight Spring Boot application demonstrating Spring AI with Amazon Bedrock without the AgentCore starter. This shows traditional REST endpoints for comparison.
- Traditional REST API: Manual endpoint creation (not using
@AgentCoreInvocation) - Synchronous and Streaming: Both response types supported
- Custom Tool Integration: Date/time tools available to AI
- Amazon Bedrock: Integration with Claude 3 Sonnet model
This example uses manual REST controllers instead of the AgentCore starter:
- Manual
@PostMappingendpoints vs@AgentCoreInvocation - Custom paths (
/ai,/ai/stream) vs fixed/invocations - No automatic AgentCore health monitoring
- Java 21
- Maven
- AWS account with access to Amazon Bedrock
- AWS credentials configured locally
Uses Amazon Bedrock's Claude 3 Sonnet model in EU West 1:
spring.application.name=agents
spring.ai.bedrock.aws.region=eu-west-1
spring.ai.bedrock.converse.chat.options.model=eu.anthropic.claude-3-7-sonnet-20250219-v1:0mvn spring-boot:runThe application starts on port 8080.
curl -XPOST 'http://localhost:8080/ai' \
-H "Content-Type: application/json" \
-d '{"prompt":"Tell me about Spring AI in 2 sentences."}'curl -XPOST -N 'http://localhost:8080/ai/stream' \
-H "Content-Type: application/json" \
-d '{"prompt":"Who is George Mallory?"}'curl -XPOST -N 'http://localhost:8080/ai/stream' \
-H "Content-Type: application/json" \
-d '{"prompt":"What is the current date and time?"}'ChatController.java: Manual REST endpoints (no AgentCore)PromptRequest.java: Request payload recordDateTimeTools.java: Custom tool for date/time informationAgentsApplication.java: Spring Boot application entry point
- Manual Endpoints: Uses
@PostMappinginstead of@AgentCoreInvocation - Custom Paths:
/aiand/ai/streaminstead of/invocations - No Health Monitoring: No automatic
/pingendpoint - More Code: Requires manual controller setup vs single annotation