Class BedrockLlmClient

All Implemented Interfaces:
LlmClient

public class BedrockLlmClient extends AnthropicLlmClient
Runtime client for Amazon Bedrock's Anthropic models (POST /model/{modelId}/invoke). The request body and response shape are Anthropic's (so response parsing is inherited from AnthropicLlmClient), wrapped with the Bedrock anthropic_version field.

Auth — SigV4 signing: When LlmBackend.apiKey() is set in the format accessKeyId:secretAccessKey (optionally accessKeyId:secretAccessKey:sessionToken for STS temporary credentials), this client automatically signs the request with AWS Signature Version 4 using JDK crypto only (SHA-256, HmacSHA256). The region is parsed from the baseUrl host (bedrock-runtime.<region>.amazonaws.com) and defaults to us-east-1 if not parseable. The service is bedrock.

Headers escape hatch: The LlmBackend.headers() escape hatch remains supported for pre-signed / signing-proxy setups. When SigV4 creds are present, the auto-generated Authorization header takes precedence over any Authorization supplied via the escape hatch (the SigV4 header is applied after the escape-hatch headers). When no creds are present, the escape hatch is the only source of auth — backward compatible with the original behaviour.

  • Constructor Details

    • BedrockLlmClient

      public BedrockLlmClient()
  • Method Details

    • provider

      public Provider provider()
      Description copied from interface: LlmClient
      The provider this client handles — the registry key.
      Specified by:
      provider in interface LlmClient
      Overrides:
      provider in class AnthropicLlmClient
    • buildCompletionRequest

      public HttpRequest buildCompletionRequest(LlmBackend backend, ParsedConversation prompt)
      Description copied from interface: LlmClient
      Build the outbound completion request (URL path, auth headers, request body) for the given backend and prompt. The returned request carries the socket address resolved from the backend's base URL (or the provider default). Implementations pin temperature=0 and a seed where the provider supports it, for reproducibility.
      Specified by:
      buildCompletionRequest in interface LlmClient
      Overrides:
      buildCompletionRequest in class AnthropicLlmClient
    • signingTimestamp

      protected Instant signingTimestamp()
      Signing timestamp. Overridable for testing (pin the clock to produce deterministic signatures). The default returns Instant.now().