
Aws Sdk Java V2 Bedrock
Wire Amazon Bedrock Runtime from Java with model-specific payloads for Claude and Llama when building server-side AI features.
Overview
aws-sdk-java-v2-bedrock is an agent skill for the Build phase that documents Java v2 BedrockRuntimeClient invoke patterns for Claude and related foundation models.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-bedrockWhat is this skill?
- Claude 3 Sonnet and Haiku InvokeModel examples with anthropic_version and message JSON
- BedrockRuntimeClient request builder pattern with SdkBytes bodies
- Model-specific IDs and parameter knobs (max_tokens, temperature, top_p)
- Advanced model-pattern section for extending to additional Bedrock foundation models
- Claude 3 Sonnet and Haiku model ID examples
- anthropic_version bedrock-2023-05-31 in sample payloads
Adoption & trust: 1.1k installs on skills.sh; 271 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need to call Bedrock from Java but each model expects different JSON and SDK wiring.
Who is it for?
Indie JVM APIs or internal tools already on AWS that need managed Claude/Llama inference without a separate Python microservice.
Skip if: Python-only stacks, browser-side LLM calls, or teams needing full IAM, streaming, and cost governance in one skill.
When should I use this skill?
When implementing or extending Amazon Bedrock model invocation in Java using AWS SDK v2 BedrockRuntimeClient.
What do I get? / Deliverables
You get working InvokeModel snippets with correct model IDs and response parsing you can drop into your service layer.
- InvokeModel client methods
- Model-specific JSON request templates
- Response parsing snippets
Recommended Skills
Journey fit
How it compares
Skill package for Java Bedrock payloads—not an MCP server and not a hosted model router.
Common Questions / FAQ
Who is aws-sdk-java-v2-bedrock for?
Solo builders and small teams writing Java or Kotlin services that integrate Amazon Bedrock Runtime.
When should I use aws-sdk-java-v2-bedrock?
During Build → Integrations while implementing server-side model calls, choosing Sonnet vs Haiku defaults, or extending Bedrock model coverage in an existing SDK v2 client.
Is aws-sdk-java-v2-bedrock safe to install?
Check the Security Audits panel on this page; the skill includes network-facing AWS API usage—scope IAM least privilege and never commit long-lived keys.
SKILL.md
READMESKILL.md - Aws Sdk Java V2 Bedrock
# Advanced Model Patterns ## Model-Specific Configuration ### Claude Models Configuration ```java // Claude 3 Sonnet public String invokeClaude3Sonnet(BedrockRuntimeClient client, String prompt) { String modelId = "anthropic.claude-3-sonnet-20240229-v1:0"; JSONObject payload = new JSONObject() .put("anthropic_version", "bedrock-2023-05-31") .put("max_tokens", 1000) .put("temperature", 0.7) .put("top_p", 1.0) .put("messages", new JSONObject[]{ new JSONObject() .put("role", "user") .put("content", prompt) }); InvokeModelResponse response = client.invokeModel(request -> request .modelId(modelId) .body(SdkBytes.fromUtf8String(payload.toString()))); JSONObject responseBody = new JSONObject(response.body().asUtf8String()); return responseBody.getJSONArray("content") .getJSONObject(0) .getString("text"); } // Claude 3 Haiku (faster, cheaper) public String invokeClaude3Haiku(BedrockRuntimeClient client, String prompt) { String modelId = "anthropic.claude-3-haiku-20240307-v1:0"; JSONObject payload = new JSONObject() .put("anthropic_version", "bedrock-2023-05-31") .put("max_tokens", 400) .put("messages", new JSONObject[]{ new JSONObject() .put("role", "user") .put("content", prompt) }); // Similar invocation pattern as above } ``` ### Llama Models Configuration ```java // Llama 3 70B public String invokeLlama3_70B(BedrockRuntimeClient client, String prompt) { String modelId = "meta.llama3-70b-instruct-v1:0"; JSONObject payload = new JSONObject() .put("prompt", prompt) .put("max_gen_len", 512) .put("temperature", 0.7) .put("top_p", 0.9) .put("stop", new String[]{"[INST]", "[/INST]"}); // Custom stop tokens InvokeModelResponse response = client.invokeModel(request -> request .modelId(modelId) .body(SdkBytes.fromUtf8String(payload.toString()))); JSONObject responseBody = new JSONObject(response.body().asUtf8String()); return responseBody.getString("generation"); } ``` ## Multi-Model Service Layer ```java @Service public class MultiModelService { private final BedrockRuntimeClient bedrockRuntimeClient; private final ObjectMapper objectMapper; public MultiModelService(BedrockRuntimeClient bedrockRuntimeClient, ObjectMapper objectMapper) { this.bedrockRuntimeClient = bedrockRuntimeClient; this.objectMapper = objectMapper; } public String invokeModel(String modelId, String prompt, Map<String, Object> additionalParams) { Map<String, Object> payload = createModelPayload(modelId, prompt, additionalParams); try { InvokeModelResponse response = bedrockRuntimeClient.invokeModel( request -> request .modelId(modelId) .body(SdkBytes.fromUtf8String(objectMapper.writeValueAsString(payload)))); return extractResponseContent(modelId, response.body().asUtf8String()); } catch (Exception e) { throw new RuntimeException("Model invocation failed: " + e.getMessage(), e); } } private Map<String, Object> createModelPayload(String modelId, String prompt, Map<String, Object> additionalParams) { Map<String, Object> payload = new HashMap<>(); if (modelId.startsWith("anthropic.claude")) { payload.put("anthropic_version", "bedrock-2023-05-31"); payload.put("messages", List.of(Map.of("role", "user", "content", prompt))); // Add common parameters with defaults payload.putIfAbsent("max_tokens", 1000); payload.putIfAbsent("temperature", 0.7); } else if (modelId.startsWith("meta.llama")) { payload.put("prompt",