Use this guide when a framework integration needs NeMo Relay middleware, intercepts, or subscribers to reason about provider-specific LLM payloads through a stable annotated shape.
You will attach request and response codecs to a managed LLM wrapper so that:
You need:
llm.execute, llm.stream_execute, llmCallExecute, typedLlmExecute, or llm_call_execute.A provider codec is a pure data translator at the NeMo Relay LLM boundary.
Provider codecs let framework code keep using provider-native payloads while NeMo Relay middleware works against a shared annotated model. For application-facing type conversion, use Using Codecs.
When a managed LLM call has a request codec:
decode before LLM request intercepts run.encode to merge the annotated request back into the original raw request.When a managed LLM call has a response codec, NeMo Relay decodes the raw provider response for observability and attaches the result to the emitted LLM end event. The response codec does not rewrite the value returned to the application. Use Provider Response Codecs for response-only behavior and custom response codec examples.
Codec implementations should preserve fields they do not understand. Treat encode as a merge operation over the original provider payload, not as a full replacement.
Use the built-in provider codecs when the framework payload already matches a supported provider API:
OpenAIChatCodec: OpenAI Chat Completions-compatible requests and responses.OpenAIResponsesCodec: OpenAI Responses-compatible requests and responses.AnthropicMessagesCodec: Anthropic Messages-compatible requests and responses.Provider codecs have separate request and response roles:
LlmCodec decodes provider-specific requests into an annotated request form and encodes edits back into the provider request.LlmResponseCodec decodes raw provider responses into annotated response data for lifecycle events.The built-in provider codecs expose the same core methods:
Choose the provider codec that matches the payload shape the framework already sends to the provider. Do not translate to a different provider shape only to make the codec fit.
This example uses a request intercept to edit the normalized request. The codec writes the edited messages back into the provider payload before the provider callback runs.
Use a custom codec when a framework uses a payload shape that does not directly match a built-in provider format. The codec decodes the framework shape into AnnotatedLLMRequest, and encodes edits back into the framework shape.
Use this checklist to confirm the implementation preserves the expected runtime contract.
annotated only when the managed call supplies a request codec.encode preserves provider fields that the annotated model does not represent.Use these links to continue from this workflow into the next related task.