Skip to main content

Crate llmsdk_anthropic_aws

Crate llmsdk_anthropic_aws 

Source
Expand description

Claude Platform on AWS (a.k.a. “Anthropic on AWS”) provider for llmsdk.

Rust port of @ai-sdk/anthropic-aws. Reuses the entire llmsdk_anthropic request pipeline (Messages, Files, Skills, typed server tools) and swaps in a per-request authentication hook that signs each outbound POST with AWS Signature Version 4 or, alternatively, attaches an x-api-key header for AWS-provisioned keys.

§Authentication precedence

Matches the upstream package:

  1. If apiKey is provided (option or ANTHROPIC_AWS_API_KEY env var) — x-api-key is sent and SigV4 is not attempted.
  2. Otherwise SigV4 signs every POST using AWS credentials resolved from accessKeyId / secretAccessKey / sessionToken options or AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN env vars.

§Required configuration

  • region (or AWS_REGION): used both to template the default base URL https://aws-external-anthropic.{region}.api.aws/v1 and as the SigV4 signing region.
  • workspace_id (or ANTHROPIC_AWS_WORKSPACE_ID): sent on every request as anthropic-workspace-id.

§Quick start

use llmsdk_anthropic_aws::AnthropicAws;
use llmsdk_provider::language_model::{CallOptions, Message, TextPart, UserPart};
use llmsdk_provider::LanguageModel;

let provider = AnthropicAws::builder()
    .region("us-west-2")
    .workspace_id("wrkspc_123")
    .api_key("sk-aws-platform-key")
    .build()?;

let result = provider
    .language_model("claude-sonnet-4-6")
    .do_generate(CallOptions {
        prompt: vec![Message::User {
            content: vec![UserPart::Text(TextPart {
                text: "Hi".into(),
                provider_options: None,
            })],
            provider_options: None,
        }],
        max_output_tokens: Some(64),
        ..Default::default()
    })
    .await?;
println!("{result:?}");

Modules§

tools
Re-export of llmsdk_anthropic::tools for convenience.

Structs§

AnthropicAws
Claude Platform on AWS provider handle.
AnthropicAwsBuilder
Builder for AnthropicAws.
ApiKeyAuth
Authenticate every outbound request with an AWS-provisioned x-api-key.
SigV4Auth
Authenticate every outbound POST with AWS Signature Version 4.

Constants§

API_KEY_ENV_VAR
Environment variable consulted for the AWS-provisioned API key.
AWS_REGION_ENV_VAR
Environment variable consulted for the AWS region.
DEFAULT_BASE_URL_TEMPLATE
Base-URL template applied when no explicit base_url is set.
PROVIDER_NAME_FILES
Reported provider name for the Files handle.
PROVIDER_NAME_MESSAGES
Reported provider name for Messages / Language-model handles.
PROVIDER_NAME_SKILLS
Reported provider name for the Skills handle.
SIGV4_SERVICE
AWS service id used when generating SigV4 signatures.
WORKSPACE_ID_ENV_VAR
Environment variable consulted for the Anthropic workspace id.