Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Openai Openai node Parsed Output Consumption

From Leeroopedia
Revision as of 18:01, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/Openai_Openai_node_Parsed_Output_Consumption.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Schema_Validation, NLP
Last Updated 2026-02-15 00:00 GMT

Overview

A principle for consuming typed, schema-validated output from language model responses where raw JSON content has been automatically parsed into application-level objects.

Description

Parsed Output Consumption is the final step in the structured output pipeline. After the API response is received and parsed, the consumer accesses the typed result via the message.parsed property (Chat Completions) or output_parsed property (Responses API). The parsed value is null when the model issues a refusal or when content is empty.

This principle addresses the common pattern of: (1) checking for refusals, (2) accessing the parsed content, and (3) using it with full TypeScript type safety.

Usage

Use this pattern after calling completions.parse() or responses.parse(). Always check for null (refusal or empty content) before using the parsed value.

Theoretical Basis

Parsed output consumption follows a Nullable Result Pattern:

// Chat Completions pattern:
completion = await parse(params)
message = completion.choices[0].message

if message.refusal:
    handle_refusal(message.refusal)
else if message.parsed:
    use_typed_data(message.parsed)  // TypeScript type: ParsedT

// Responses API pattern:
response = await responses.parse(params)

if response.output_parsed:
    use_typed_data(response.output_parsed)  // TypeScript type: ParsedT

The parsed property is typed as ParsedT | null, enforcing null-checking at the type level.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment