Documentation
¶
Index ¶
Constants ¶
const ( EnvAWSAccessKeyID = "AWS_ACCESS_KEY_ID" EnvAWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY" EnvAWSRegion = "AWS_REGION" EnvAWSDefaultRegion = "AWS_DEFAULT_REGION" EnvAWSProfile = "AWS_PROFILE" )
Environment variable names for AWS configuration.
const ( // Claude latest (recommended). ModelHaikuLatest = "anthropic.claude-haiku-4-5-20251001-v1:0" ModelOpusLatest = "anthropic.claude-opus-4-6-v1" ModelSonnetLatest = "anthropic.claude-sonnet-4-6" // Claude 4.5 series. ModelOpus45 = "anthropic.claude-opus-4-5-20251101-v1:0" ModelSonnet45 = "anthropic.claude-sonnet-4-5-20250929-v1:0" // Claude 3.x series. ModelHaiku3 = "anthropic.claude-3-haiku-20240307-v1:0" ModelSonnet35 = "anthropic.claude-3-5-sonnet-20240620-v1:0" ModelSonnet37 = "anthropic.claude-3-7-sonnet-20250219-v1:0" )
Anthropic Claude models.
const ( ModelNova2Lite = "amazon.nova-2-lite-v1:0" ModelNovaLite = "amazon.nova-lite-v1:0" ModelNovaMicro = "amazon.nova-micro-v1:0" ModelNovaPremier = "amazon.nova-premier-v1:0" ModelNovaPro = "amazon.nova-pro-v1:0" )
Amazon Nova models.
const ( ModelCohereEmbedV4 = "cohere.embed-v4:0" ModelCommandR = "cohere.command-r-v1:0" ModelCommandRPlus = "cohere.command-r-plus-v1:0" )
Cohere models.
const ( // Llama 4. ModelLlama4Maverick = "meta.llama4-maverick-17b-instruct-v1:0" ModelLlama4Scout = "meta.llama4-scout-17b-instruct-v1:0" // Llama 3.3. ModelLlama33_70B = "meta.llama3-3-70b-instruct-v1:0" // Llama 3.2. ModelLlama32_1B = "meta.llama3-2-1b-instruct-v1:0" ModelLlama32_3B = "meta.llama3-2-3b-instruct-v1:0" ModelLlama32_11B = "meta.llama3-2-11b-instruct-v1:0" ModelLlama32_90B = "meta.llama3-2-90b-instruct-v1:0" // Llama 3.1. ModelLlama31_8B = "meta.llama3-1-8b-instruct-v1:0" ModelLlama31_70B = "meta.llama3-1-70b-instruct-v1:0" // Llama 3. ModelLlama3_8B = "meta.llama3-8b-instruct-v1:0" ModelLlama3_70B = "meta.llama3-70b-instruct-v1:0" )
Meta Llama models.
const ( ModelDevstral2 = "mistral.devstral-2-123b" ModelMagistralSmall = "mistral.magistral-small-2509" ModelMinistral3B = "mistral.ministral-3-3b-instruct" ModelMinistral8B = "mistral.ministral-3-8b-instruct" ModelMinistral14B = "mistral.ministral-3-14b-instruct" ModelMistral7B = "mistral.mistral-7b-instruct-v0:2" ModelMistralLarge2402 = "mistral.mistral-large-2402-v1:0" ModelMistralLarge3 = "mistral.mistral-large-3-675b-instruct" ModelMistralSmall = "mistral.mistral-small-2402-v1:0" ModelMixtral8x7B = "mistral.mixtral-8x7b-instruct-v0:1" ModelPixtralLarge = "mistral.pixtral-large-2502-v1:0" ModelVoxtralMini = "mistral.voxtral-mini-3b-2507" ModelVoxtralSmall = "mistral.voxtral-small-24b-2507" )
Mistral models.
const ( ModelPalmyraX4 = "writer.palmyra-x4-v1:0" ModelPalmyraX5 = "writer.palmyra-x5-v1:0" )
Writer models.
const ( RegionUSEast1 = "us-east-1" RegionUSEast2 = "us-east-2" RegionUSWest2 = "us-west-2" RegionEUCentral1 = "eu-central-1" RegionEUWest1 = "eu-west-1" RegionAPNortheast1 = "ap-northeast-1" )
Common AWS regions.
const ( PrefixEU = "eu" PrefixUS = "us" PrefixAPAC = "apac" PrefixGlobal = "global" )
Inference profile prefixes for cross-region inference.
const DefaultRegion = RegionUSEast1
DefaultRegion is the default AWS region for Bedrock.
const (
ModelDeepSeekR1 = "deepseek.r1-v1:0"
)
DeepSeek models.
Variables ¶
var DefaultModel = ModelSonnetLatest
DefaultModel is the recommended default model (Claude Sonnet 4.6).
var ModelAliases = map[string]string{ "haiku": ModelHaikuLatest, "sonnet": ModelSonnetLatest, "opus": ModelOpusLatest, }
ModelAliases maps short alias names to full Bedrock model IDs. These are used by the auto package for provider-prefixed resolution (e.g., "bedrock/sonnet", "bedrock/haiku", "bedrock/opus").
Functions ¶
This section is empty.
Types ¶
type InferenceProfile ¶ added in v0.16.0
type InferenceProfile struct {
Prefixes []string // Available: PrefixEU, PrefixUS, PrefixAPAC, PrefixGlobal
}
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 WithLLMOptions ¶ added in v0.23.0
WithLLMOptions applies one or more llm.Option values to the Bedrock provider. This allows using shared llm options (e.g. llm.WithHTTPClient) with this provider.
Example:
bedrock.New(bedrock.WithLLMOptions(llm.WithHTTPClient(myClient)))
func WithProfile ¶ added in v0.18.0
WithProfile sets the AWS profile to use for credentials and configuration. This allows using a specific profile from ~/.aws/credentials or ~/.aws/config instead of the default profile or AWS_PROFILE environment variable.
func WithRegion ¶
WithRegion sets the AWS region for Bedrock explicitly. By default, New() reads the region from AWS_REGION or AWS_DEFAULT_REGION environment variables, falling back to DefaultRegion (us-east-1).
func WithRegionFromEnv ¶ added in v0.18.0
func WithRegionFromEnv() Option
WithRegionFromEnv reads the region from AWS_REGION or AWS_DEFAULT_REGION environment variables. This is useful to re-enable environment variable lookup after WithRegion() has been called.
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
Region is determined from:
- AWS_REGION environment variable
- AWS_DEFAULT_REGION environment variable
- DefaultRegion (us-east-1) if neither is set
The AWS_PROFILE environment variable is honored automatically by the SDK. Use WithProfile() to explicitly select a different profile.
When WithCredentialsProvider is used, client creation is deferred until the first CreateStream call, allowing credentials to be fetched lazily.
Example usage:
// Use defaults (reads AWS_REGION, AWS_PROFILE from env)
p := bedrock.New()
// Specify region explicitly
p := bedrock.New(bedrock.WithRegion(bedrock.RegionEUCentral1))
// Use a specific AWS profile
p := bedrock.New(bedrock.WithProfile("production"))
// Combine options
p := bedrock.New(
bedrock.WithProfile("production"),
bedrock.WithRegion(bedrock.RegionEUWest1),
)
// Use custom credentials provider (lazy initialization)
p := bedrock.New(bedrock.WithCredentialsProvider(myProvider))
func (*Provider) CreateStream ¶
func (*Provider) RegionPrefix ¶ added in v0.16.0
RegionPrefix returns the computed inference profile prefix for this provider's region. Returns PrefixEU, PrefixUS, PrefixAPAC, or PrefixGlobal.