# `LlmCall.Dialect.Bedrock.Converse`
[🔗](https://github.com/gilbertwong96/llm_call/blob/main/lib/llm_call/dialect/bedrock/converse.ex#L1)

Bedrock's `Converse` API (`POST /model/{modelId}/converse`).

One request shape covers every model Bedrock serves, which is why it is the
dialect worth implementing first: `anthropic_version` and each vendor's own
envelope disappear behind `messages`, `system` and `inferenceConfig`.

A model ID is **one** path segment. Bedrock IDs carry `:` and inference-profile
ARNs carry `/`, so the ID is percent-encoded here and signed verbatim by the
transport.

This phase carries text, tool use, images and documents, in both the inline and the
S3 form. A part whose bytes travel with the request is encoded (`source.bytes`); a
`{:uri, "s3://…"}` part becomes `s3Location`, which is what `{:uri, _}` is for — a
location only Bedrock can resolve. Anything else, including an `https://` URL, is
refused locally: sending it is a `400` from the service. `capabilities/2` reports
exactly that: `image_input` and `file_input` accept `:inline` and `:uri`, and
neither `:url` nor `:file`.

## Native options

`provider_options.bedrock` is merged into the **top level** of the Converse
request, the rule the OpenAI, Anthropic and Gemini codecs already follow. That
is what makes `guardrailConfig`, `performanceConfig`, `requestMetadata` and
`promptVariables` reachable, and `additionalModelRequestFields` is one more
top-level field rather than a special case:

    provider_options: %{bedrock: %{"additionalModelRequestFields" => %{"top_k" => 200}}}

The canonical envelope keys — `messages`, `system`, `inferenceConfig`,
`toolConfig` — are reserved: an option that would replace one is a
`:validation` error, never a silent override.

## Streaming

`ConverseStream` is a second endpoint, not a flag in the body, so
`encode_request/2` picks `/converse-stream` from `Request.stream`. Its body is a
single binary frame stream rather than SSE, declared through `stream_framing/0`.

Bedrock sends usage **after** `messageStop`, so this codec cannot emit the IR
terminator there: `:message_stop` would be followed by another event. The stop
reason arrives at `messageStop`, the usage at `metadata`, and `finish_stream/2`
emits `:message_stop` when the body ends — the same shape Gemini uses, and the same
rule: a stream that ends without `messageStop` is an `:invalid_response`, not a
quietly truncated one.

---

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