Skip to the content.

Spring Cloud AWS Bedrock Starter

Lets you use the AWS Bedrock Service with Spring Boot and Spring Cloud

Alpha Github Action CI Workflow Status Known Vulnerabilities License


This project provides a developer friendly way to access the services of AWS Bedrock, an AWS service that provides a managed Language Model (LLM) service with a catalog of supported LLMs. This is a Spring Cloud Starter for the Bedrock service that removes all the boilerplate code required to access the service. It uses the standard Spring Cloud AWS Starter to provide the credentials for the AWS SDK for Java, and the standards of Spring Boot and Spring Cloud to provide the configuration and the auto-wiring of the service objects.

This project leverages Spring Cloud AWS for credential management

Just provide the right properties as defined below and the appropriate AWSCredentialsProvider object will be activated for injection into your Spring objects. An example for the creation of BasicAwsCredentials is shown below. You can follow the link below to understand all the other supported credential models.

# for BasicAwsCredentials

# an optional method to do the same

See the Credentials section of Spring Cloud AWS Starter documentation for alternate configuration options.

Properties that will enable ClaudeService

The Bedrock and BedrockRuntimeClient

Once the right AWSCredentialsProvider is injected, you can expect the activation of the appropriate versions of the BedrockClient and the BedrockRuntimeClient. These will be conditional on the bedrock.client.type property. The options there are sync and async, which drive the activation of the synchronous or the asynchronous versions of the clients.



One can use the activated clients to interact with the AWS Bedrock service based on the docs for the Bedrock Service.

Bedrock Service

The best part of the Starter is the activation of a service object which has the invoke method.

All you need to do is provide the properties like one of the sets below to activate the appropriate implementations of the BedrockService interface (Claude, Jurassic, Llama, StableDiffusion, or Titan).

Claude model parameters

Jurassic model parameters

Llama2 model parameters

Titan model parameters

Stability model parameters


Once activated, a Service can be autowired and used as below.

public class ClaudeController {

    private final ClaudeService claudeService;

    public ClaudeController(ClaudeService claudeService) {
        this.claudeService = claudeService;

    public String invoke(@RequestParam String prompt) {
        try {
            return claudeService.invoke(prompt);
        } catch (Exception e) {
            return "Error invoking Claude: " + e.getMessage();

If you activate more than one model, then you will need to use the @Qualifier annotation to eliminate ambiguity when choosing to inject by the BedrockService interface. See @Qualifier vs @Primary with Examples for background. You may not activate more than one model variant from a single provider.

You might also want to take a look at and/or run the Service tests. To do that, make sure you’ve set the appropriate AWS_* environment variables, then execute

mvn test

Cosmic Whaleshark generated by Stable Diffusion