parse_structured_output()

Parse raw CLI stdout into text or a validated model.

Usage

Source

parse_structured_output(raw: str, response_model: None) -> str
 
parse_structured_output(raw: str, response_model: type[M]) -> M

Parameters

raw: str

Raw stdout from the backend CLI.

response_model: type[M] | None
The Pydantic model to validate against, or None for text.

Returns

str | M
raw for text calls; otherwise structured_output from the stream-json events, else raw validated as JSON.