Documentation
¶
Index ¶
Constants ¶
const ( EnvAWSAccessKeyID = "AWS_ACCESS_KEY_ID" EnvAWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY" EnvAWSRegion = "AWS_REGION" EnvAWSDefaultRegion = "AWS_DEFAULT_REGION" )
Environment variable names for AWS configuration.
const (
// DefaultModel is the recommended default model (Claude Sonnet 4).
DefaultModel = "anthropic.claude-sonnet-4-20250514-v1:0"
)
Variables ¶
This section is empty.
Functions ¶
func MaybeRegister ¶
MaybeRegister registers the Bedrock provider if AWS credentials are available. Credentials are detected from:
- Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
- Shared credentials file (~/.aws/credentials)
- IAM role (for EC2/ECS/Lambda) - detected at request time
Region is configured from AWS_REGION or AWS_DEFAULT_REGION environment variables, defaulting to us-east-1 if not set.
Types ¶
type InferenceProfile ¶ added in v0.16.0
type InferenceProfile struct {
Prefixes []string // Available: "eu", "us", "apac", "global"
}
InferenceProfile defines available region prefixes for a model.
type Option ¶
type Option func(*Provider)
Option configures a Bedrock provider.
func WithCredentialsProvider ¶ added in v0.14.0
func WithCredentialsProvider(cp aws.CredentialsProvider) Option
WithCredentialsProvider sets a custom AWS credentials provider. When set, the AWS client is created lazily on first use, allowing credentials to be fetched at request time rather than at construction. This enables integration with external secret managers or dynamic credential sources.
func WithDefaultModel ¶
WithDefaultModel sets the default model ID.
func WithRegion ¶
WithRegion sets the AWS region for Bedrock. Defaults to us-east-1 if not specified.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the AWS Bedrock LLM backend.
func New ¶
New creates a new AWS Bedrock provider. The provider uses the AWS SDK's default credential chain:
- Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
- Shared credentials file (~/.aws/credentials)
- IAM role (for EC2/ECS/Lambda)
- SSO credentials
When WithCredentialsProvider is used, client creation is deferred until the first CreateStream call, allowing credentials to be fetched lazily.
Example usage:
// Use defaults (us-east-1, default credentials)
p := bedrock.New()
// Specify region
p := bedrock.New(bedrock.WithRegion("us-west-2"))
// Specify default model
p := bedrock.New(bedrock.WithDefaultModel("anthropic.claude-3-5-haiku-20241022-v1:0"))
// Use custom credentials provider (lazy initialization)
p := bedrock.New(bedrock.WithCredentialsProvider(myProvider))
func (*Provider) CreateStream ¶
func (p *Provider) CreateStream(ctx context.Context, opts llm.StreamOptions) (<-chan llm.StreamEvent, error)
func (*Provider) DefaultModel ¶
DefaultModel returns the configured default model ID.
func (*Provider) RegionPrefix ¶ added in v0.16.0
RegionPrefix returns the computed inference profile prefix for this provider's region. Returns "eu", "us", "apac", or "global".