> This page is for NeMo Relay, version v0.10.3.
> For other versions, use one of these documentation indexes:
> - Latest (v0.10.3) (default): https://docs.nvidia.com/nemo/relay/latest/llms.txt
> - dev: https://docs.nvidia.com/nemo/relay/dev/llms.txt
> - v0.10.3: https://docs.nvidia.com/nemo/relay/v0.10.3/llms.txt
> - v0.10.2: https://docs.nvidia.com/nemo/relay/v0.10.2/llms.txt
> - v0.9.4: https://docs.nvidia.com/nemo/relay/v0.9.4/llms.txt
> - v0.8.4: https://docs.nvidia.com/nemo/relay/v0.8.4/llms.txt
> - v0.7.3: https://docs.nvidia.com/nemo/relay/v0.7.3/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/relay/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/relay/_mcp/server.

# Trait Streaming Codec

> Per-provider streaming codec used with `crate::api::llm::llm_stream_call_execute`.

Generated from `cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`.

<pre />

Per-provider streaming codec used with [`crate::api::llm::llm_stream_call_execute`](/reference/api/rust-library-reference/nemo-relay/api/llm/fn-llm-stream-call-execute).

`collector()` and `finalizer()` produce owned closures that share the codec's internal accumulation state. Implementations typically wrap that state in `Arc<Mutex<...>>` so each `&self`-produced closure captures a clone of the handle.

[`LlmFinalizerFn`](/reference/api/rust-library-reference/nemo-relay/api/runtime/callbacks/type-llmfinalizerfn) is `FnOnce`, so a [`StreamingCodec`](/reference/api/rust-library-reference/nemo-relay/codec/streaming/trait-streamingcodec) instance is single-use: callers construct a fresh instance per managed-lifecycle call and discard it after the stream completes.

## Required Methods

#### `collector`

<pre />

Returns a closure that consumes one decoded provider event per call.

#### `finalizer`

<pre />

Returns a closure that, when called once at end of stream, produces the assembled response payload in the shape the matching [`crate::codec::traits::LlmResponseCodec`](/reference/api/rust-library-reference/nemo-relay/codec/traits/trait-llmresponsecodec) can decode.

## Provided Methods

#### `validate_stream`

<pre />

Wraps the source stream to check provider completion rules.

Feed the returned stream to this instance's collector and finalizer. The default leaves the stream unchanged. An override must forward close and cleanup operations.

## Implementors

### `impl StreamingCodec for AnthropicMessagesStreamingCodec`

<pre />

### `impl StreamingCodec for GeminiGenerateContentStreamingCodec`

<pre />

### `impl StreamingCodec for OCIGenAIStreamingCodec`

<pre />

### `impl StreamingCodec for OpenAIChatStreamingCodec`

<pre />

### `impl StreamingCodec for OpenAIResponsesStreamingCodec`

<pre />