Available on crate feature
bedrock only.Expand description
AWS Bedrock support: a RequestSigner that signs HTTP requests
with sigv4.
claude-api is the Anthropic API client; this module exposes the
signing primitive only. Users who want to talk to Bedrock Anthropic
models still need to:
- Set
Client::builder().base_url("https://bedrock-runtime.{region}.amazonaws.com"), - Use Bedrock’s URL shape (
/model/{model_id}/invoke), - Inject
anthropic_version: "bedrock-2023-05-31"and remove themodelfield from the body (Bedrock takes the model in the URL).
The typed namespace handles still use Anthropic’s URL shape; Bedrock
model IDs and the anthropic_version header must be supplied by the
caller. See examples/bedrock.rs for a complete working sketch.
Gated on the bedrock feature.
§Set up the client
use std::sync::Arc;
use claude_api::{Client, bedrock::{BedrockCredentials, BedrockSigner}};
let region = std::env::var("AWS_REGION").unwrap_or_else(|_| "us-east-1".into());
let creds = BedrockCredentials::from_env()
.expect("AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set");
let client = Client::builder()
.signer(Arc::new(BedrockSigner::new(creds, ®ion)))
.base_url(format!("https://bedrock-runtime.{region}.amazonaws.com"))
.build()?;Structs§
- Bedrock
Credentials - AWS access credentials. Carries the same fields as
aws_credential_types::Credentialsbut is owned,Clone, and kept opaque – the underlying secret is moved into a freshCredentialsper call so this type is safe to share viaArc. - Bedrock
Signer - AWS sigv4 signer for the
bedrockservice.