Class AwsBackend
-
- All Implemented Interfaces:
-
com.anthropic.backends.Backend
public final class AwsBackend implements BackendThe AWS backend that manages the AWS credentials or API key required to access Anthropic's AI models via the AWS API gateway and signs requests using AWS SigV4.
Unless using an API key, requests are cryptographically signed using credentials issued by AWS. These can be provided via system properties, environment variables, or other AWS facilities. They can be resolved automatically by the default AWS provider chain by calling Builder.fromEnv. Alternatively, a custom AWS credentials provider can be configured on the builder.
If using an API key, the key can be set directly, or provided via the
ANTHROPIC_AWS_API_KEYenvironment variable. If that variable is set, it will be resolved by Builder.fromEnv unless an AWS credentials provider is specified explicitly to that method.Both the credentials (or API key) and the region can be resolved independently and passed to Builder.awsCredentials (or Builder.apiKey) and Builder.region should an alternative method of resolution be required.
A workspace ID must be set via Builder.workspaceId or the
ANTHROPIC_AWS_WORKSPACE_IDenvironment variable. It is sent as theanthropic-workspace-idrequest header.See the AWS documentation for details on how to configure AWS credentials.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classAwsBackend.BuilderA builder for an AwsBackend used to connect an Anthropic client to the AWS API gateway backend service.
The AWS credentials and region can be extracted from the environment and set on the builder by calling fromEnv before calling build to create the AwsBackend. Alternatively, set the AWS credentials and region explicitly via awsCredentials and region before calling build. A custom AWS credentials provider can be passed to fromEnv or awsCredentialsProvider.
You should set either the AWS credentials provider or the API key, but not both. If both are set, an error will occur.
-
Method Summary
Modifier and Type Method Description final Optional<AwsCredentialsProvider>awsCredentialsProvider()final Optional<String>apiKey()final Optional<Region>region()final Optional<String>workspaceId()final BooleanskipAuth()final AwsCredentialsawsCredentials()Gets the AWS credentials resolved from the configured AWS credentials provider. StringbaseUrl()HttpRequestprepareRequest(HttpRequest request)HttpRequestauthorizeRequest(HttpRequest request)Unitclose()final static AwsBackend.Builderbuilder()final static AwsBackendfromEnv()Creates an AWS Backend configured to use the default AWS credentials provider. -
-
Method Detail
-
awsCredentialsProvider
final Optional<AwsCredentialsProvider> awsCredentialsProvider()
-
workspaceId
final Optional<String> workspaceId()
-
awsCredentials
final AwsCredentials awsCredentials()
Gets the AWS credentials resolved from the configured AWS credentials provider. Calling this will result in an error if an API key was used instead of an AWS credentials provider.
-
prepareRequest
HttpRequest prepareRequest(HttpRequest request)
-
authorizeRequest
HttpRequest authorizeRequest(HttpRequest request)
-
builder
final static AwsBackend.Builder builder()
-
fromEnv
final static AwsBackend fromEnv()
Creates an AWS Backend configured to use the default AWS credentials provider. See Builder.fromEnv for more details, or to configure a different provider.
-
-
-
-