# Class LittleGhost::Providers::Bedrock

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/Providers/Bedrock.html

Bedrock lets LittleGhost features use models available through Amazon Bedrock.
Generation uses Converse and follows the same streaming events as every other
LittleGhost provider.

    provider = LittleGhost::Providers::Bedrock.new(
      model: ENV.fetch("BEDROCK_MODEL_ID"),
      region: ENV.fetch("AWS_REGION")
    )

The default client uses LittleGhost's standard-library SigV4 and AWS
EventStream implementations. Applications may inject `client` instead.

Transient service and stream failures retry with exponential backoff. Each
retry emits `:model_retry` and reports whether partial text was
already emitted, allowing stream consumers to handle repeated output
deliberately.

## Inheritance

`LittleGhost::Providers::Bedrock < LittleGhost::Providers::Base`

## Attributes

<a id="attribute-i-model"></a>
### `model` (R)

Bedrock model identifier used for requests.

## Class methods

<a id="method-c-new"></a>
### `.new`

```ruby
.new(model:, region: nil, client: nil, max_retries: 2, sleeper: nil,
        on_retry: ->(*) {}, max_embedding_response_bytes: DEFAULT_MAX_EMBEDDING_RESPONSE_BYTES, **client_options)
```

Configures Bedrock for `model`.

`region` and remaining `client_options` configure the built-in HTTP client.
`max_retries`, `sleeper`, and `on_retry` control retry behavior.
`max_embedding_response_bytes` bounds each embedding response retained in
memory. Injecting `client` bypasses creation of the built-in HTTP client.

<a id="method-c-request_options"></a>
### `.request_options`

```ruby
.request_options()
```

Request policy supported by Bedrock retries and its built-in HTTP client.

## Instance methods

<a id="method-i-capabilities"></a>
### `#capabilities`

```ruby
#capabilities(metadata: {})
```

Reads capabilities from Bedrock `supported_parameters` metadata. Missing
metadata produces ModelCapabilities.unknown.

<a id="method-i-embed"></a>
### `#embed`

```ruby
#embed(request)
```

Embeds text with Amazon Titan Text Embeddings V2.

The `:dimensions` request setting accepts 256, 512, or 1024 and
defaults to 1024. `:normalize` controls vector normalization and
defaults to true. Inputs are requested sequentially, and a failure raises
without returning a partial batch.

<a id="method-i-stream"></a>
### `#stream`

```ruby
#stream(request)
```

Streams LittleGhost StreamEvent objects for `request`.

Without a block, returns an Enumerator. Context-window failures normalize to
ContextWindowOverflowError and malformed tool calls normalize to
MalformedToolCallError.
