# `LlmComposer.Providers.Bedrock.HttpClient`
[🔗](https://github.com/doofinder/llm_composer/blob/master/lib/llm_composer/providers/bedrock/http_client.ex#L2)

ExAws HTTP client for Bedrock using Mint by default, with optional Finch support.

When `stream: true` is present in `http_opts`, uses streaming HTTP via a spawned
process that forwards events as messages to the caller. Returns a lazy `Stream` as
the response body — required for the ConverseStream binary event-stream response.

The spawned task is monitored with `Process.monitor/1` so any unexpected crash
surfaces immediately to the caller instead of waiting for the stream timeout.

## Default behaviour (Mint)

Uses `Mint.HTTP` directly for both streaming and regular requests. No additional
configuration is required since Mint is a required dependency of `llm_composer`.

## Finch (optional)

If the `:llm_composer` `:tesla_adapter` config is set to a Finch adapter, Finch
is used instead of Mint:

    config :llm_composer, :tesla_adapter, {Tesla.Adapter.Finch, name: MyFinch}

Finch must be started in your supervision tree:

    children = [{Finch, name: MyFinch}]

The Finch path honors the same `:bedrock, :receive_timeout` / `:timeout` config the Mint
path reads (see `receive_timeout/0`), so switching adapters doesn't change the effective
timeout. `:pool_timeout` and `:request_timeout` can also be set directly in the adapter
tuple's options and are forwarded to Finch as-is, taking precedence over the configured
receive timeout if both are present:

    config :llm_composer, :tesla_adapter,
      {Tesla.Adapter.Finch, name: MyFinch, receive_timeout: 60_000}

## Streaming errors

Once the response status and headers have arrived, the lazy `Stream` returned as the
response body raises `LlmComposer.Providers.Bedrock.HttpClient.StreamError` if the
underlying connection fails, crashes, or stalls before the body is fully received —
callers consuming the stream (e.g. via `Enum.into/2` or `Stream.each/2`) see that error
instead of a silently truncated body.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
