Skip to main content

Module protocol

Module protocol 

Source
Expand description

The Azure Responses API wire types: what a request carries and what a streamed response deserializes into.

Structs§

AISearchOutput
IncompleteReason
Why a response is incomplete, e.g. max_output_tokens or content_filter.
InputTokensDetails
How much of the input was served from Azure’s prompt cache. The only way to tell whether the prompt prefix is actually stable, since a perturbed prefix fails silently by costing more.
LLMRequest
LLMRequestResponseFormatParam
MistralParams
Mistral’s request parameters are not decided yet; this field exists only so LLMRequestParams::Mistral has a shape of its own to serialize and deserialize as, distinct from the other two variants.
NonThinkingParams
OutputTokensDetails
How much of the output was thinking, which is what moves when the reasoning context widens or narrows.
Reasoning
ReasoningOutput
RequestTextOptions
Response
Response received from LLM API
ResponseError
Error object returned by the LLM API on a failed response. Fields are optional so any error shape deserializes rather than crashing the stream parser.
ResponseOutput
One line of the Azure event stream. Which fields are set depends on response_type: a text delta, a completed item, a whole response, or an error.
ResponseReasoning
The reasoning settings a response reports back, as opposed to the ones the request asked for.
ThinkingParams
Usage
What the request was billed for. Optional throughout: Azure reports the cache fields only on some deployment types, and PTU-M never reports cache_write_tokens at all.

Enums§

InputItem
LLMRequestParams
Each variant’s own struct rejects a field belonging to another, which is what tells them apart on the way back in: untagged tries them in order and they otherwise all match any object.
LLMToolChoice
OutputItem
ReasoningContext
How far back the model reuses its own reasoning.
ReceivedOutputItem
An output item as it arrived, which is not necessarily one this code knows.
SummaryType
Untagged would serialize these unit variants as null, which asks Azure for no summary at all.

Functions§

azure_stream_error 🔒
Builds the error the stream parsers raise when Azure reports a failure on the line they are reading, attaching err as the error’s Azure source.
check_response_complete 🔒
Errors once a response has finished streaming if it stopped short of a complete one, whether output names the reason or the caller only knows a response.incomplete event fired with none.
check_response_output 🔒
Logs output’s usage under context, then errors if it reports a failure — the two checks both stream parsers make on every line, before either looks at its own content.
log_response_usage 🔒
Logs the usage a response line carries, if any, under context.
reported_azure_error 🔒
The error Azure reported on this line, if any: the one nested under response when a response object came with it, otherwise the top-level one. fallback_response_id is used only for the latter, since the former carries its own response id.
reported_incomplete_reason 🔒
Why the response this line carries is incomplete, if it says so. A response that stopped short still streams as if it had finished, so this is the only thing that tells the two apart.
urls_that_parse 🔒
The search results whose url this code can actually fetch. One unparseable entry must not drop every other citation from the same search.