Class BedrockLlmClient
- All Implemented Interfaces:
LlmClient
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.
-
Field Summary
Fields inherited from class org.mockserver.llm.client.AbstractLlmClient
OBJECT_MAPPER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildCompletionRequest(LlmBackend backend, ParsedConversation prompt) Build the outbound completion request (URL path, auth headers, request body) for the given backend and prompt.provider()The provider this client handles — the registry key.protected InstantSigning timestamp.Methods inherited from class org.mockserver.llm.client.AnthropicLlmClient
parseCompletionResponseMethods inherited from class org.mockserver.llm.client.AbstractLlmClient
appendRoleContentMessages, postJson, readBody, resolveBaseUrl, resolveModel, writeJson
-
Constructor Details
-
BedrockLlmClient
public BedrockLlmClient()
-
-
Method Details
-
provider
Description copied from interface:LlmClientThe provider this client handles — the registry key.- Specified by:
providerin interfaceLlmClient- Overrides:
providerin classAnthropicLlmClient
-
buildCompletionRequest
Description copied from interface:LlmClientBuild 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 pintemperature=0and a seed where the provider supports it, for reproducibility.- Specified by:
buildCompletionRequestin interfaceLlmClient- Overrides:
buildCompletionRequestin classAnthropicLlmClient
-
signingTimestamp
Signing timestamp. Overridable for testing (pin the clock to produce deterministic signatures). The default returnsInstant.now().
-