bedrock

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvAWSAccessKeyID     = "AWS_ACCESS_KEY_ID"
	EnvAWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
	EnvAWSRegion          = "AWS_REGION"
	EnvAWSDefaultRegion   = "AWS_DEFAULT_REGION"
)

Environment variable names for AWS configuration.

View Source
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

func MaybeRegister(reg *llm.Registry)

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

func WithDefaultModel(model string) Option

WithDefaultModel sets the default model ID.

func WithRegion

func WithRegion(region string) Option

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

func New(opts ...Option) *Provider

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

func (p *Provider) DefaultModel() string

DefaultModel returns the configured default model ID.

func (*Provider) Models

func (p *Provider) Models() []llm.Model

Models returns a curated list of popular Bedrock models.

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) RegionPrefix added in v0.16.0

func (p *Provider) RegionPrefix() string

RegionPrefix returns the computed inference profile prefix for this provider's region. Returns "eu", "us", "apac", or "global".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL