Documentation
¶
Overview ¶
Package bedrock provides a plugin to use Amazon Bedrock models.
ListModels reads the model list from the Bedrock control plane. Models must support the Converse and ConverseStream operations.
Authentication has three modes, in priority order:
- Bearer token: a Bedrock API key (ABSK token).
- Explicit credentials: an AWS access key ID and secret access key from fabric --setup or the .env file.
- The AWS credential provider chain, the same chain that the AWS CLI and SDKs use: https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html
Index ¶
- type BedrockClient
- func (c *BedrockClient) ListModels(_ context.Context) ([]string, error)
- func (c *BedrockClient) Send(ctx context.Context, msgs []*chat.ChatCompletionMessage, ...) (ret string, err error)
- func (c *BedrockClient) SendStream(_ context.Context, msgs []*chat.ChatCompletionMessage, ...) (err error)
- func (c *BedrockClient) Setup() (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BedrockClient ¶
type BedrockClient struct {
*plugins.PluginBase
// contains filtered or unexported fields
}
BedrockClient is a plugin to add support for Amazon Bedrock. It implements the plugins.Plugin interface and provides methods for interacting with AWS Bedrock's Converse and ConverseStream APIs.
Authentication modes (in priority order):
- Bearer token: BEDROCK_API_KEY (ABSK token) — simplest, like Claude Code
- Explicit credentials: BEDROCK_AWS_ACCESS_KEY_ID + BEDROCK_AWS_SECRET_ACCESS_KEY provided via setup
- AWS credential chain: Standard AWS SDK credential resolution (env vars, profiles, IAM roles, etc.)
func NewClient ¶
func NewClient() (ret *BedrockClient)
NewClient returns a new Bedrock plugin client. Client initialization is deferred to configure() so that explicit credentials from the .env file or --setup can be used when available.
func (*BedrockClient) ListModels ¶
func (c *BedrockClient) ListModels(_ context.Context) ([]string, error)
ListModels retrieves all available foundation models and inference profiles from AWS Bedrock that can be used with this plugin. When using bearer token auth, the API may not be accessible, so a static fallback list of common models is returned instead.
func (*BedrockClient) Send ¶
func (c *BedrockClient) Send(ctx context.Context, msgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions) (ret string, err error)
Send sends the messages the Bedrock Converse API
func (*BedrockClient) SendStream ¶
func (c *BedrockClient) SendStream(_ context.Context, msgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions, channel chan domain.StreamUpdate) (err error)
SendStream sends the messages to the Bedrock ConverseStream API
func (*BedrockClient) Setup ¶ added in v1.4.430
func (c *BedrockClient) Setup() (err error)
Setup overrides the default plugin Setup to provide a guided auth flow: 1. Choose auth method: API Key (ABSK) or AWS Access Key + Secret 2. Based on choice, ask only the relevant questions 3. Choose region from list or type custom 4. Choose model from list or type custom