openai.internal.chat_parse

One decoded response -> canonical content blocks, stop reason and usage.

Reference version

Signature

function openai.internal.chat_parse(
provider: string,
raw: string,
audio_mime: string = …
) -> ai.ModelTurn throws ai.errors.ParseFailed

One decoded response -> canonical content blocks, stop reason and usage.

raw is the response text, used only to populate ai.errors.ParseFailed when the envelope carries no usable choice.

Divergence from both prior implementations, deliberate: more than one choice is not an error here. n > 1 is reachable through the request_body passthrough, and rejecting the response the caller asked for would be hostile; the first choice is used and the rest ignored.

Source:<builtin>/openai/ns_internal/chat.bamlbytes 4782351471