Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

StructuredOutputPart.md

100 lines2.3 KB

Interface: StructuredOutputPart<TData>

Defined in: packages/typescript/ai/src/types.ts:390

StructuredOutputPart — a typed structured response attached to the assistant message that produced it. Generic over the schema-inferred data type so consumers can thread useChat({ outputSchema })'s schema all the way down to messages[i].parts[j].data. Defaults to unknown so untyped consumers (e.g. internal codepaths that don't know about TSchema) keep working.

Type Parameters

TData

TData = unknown

Properties

data?

optional data: TData;

Defined in: packages/typescript/ai/src/types.ts:396

Validated final object — only set when status === 'complete'.


errorMessage?

optional errorMessage: string;

Defined in: packages/typescript/ai/src/types.ts:402

Populated when status === 'error'.


partial?

optional partial: DeepPartial<TData>;

Defined in: packages/typescript/ai/src/types.ts:394

Progressive parse of raw via parsePartialJSON — populated while streaming and after complete.


raw

raw: string;

Defined in: packages/typescript/ai/src/types.ts:398

Accumulating JSON buffer. Source of truth for wire round-trip.


reasoning?

optional reasoning: string;

Defined in: packages/typescript/ai/src/types.ts:400

Optional chain-of-thought surfaced by reasoning models alongside the structured output.


status

status: "error" | "streaming" | "complete";

Defined in: packages/typescript/ai/src/types.ts:392


type

type: "structured-output";

Defined in: packages/typescript/ai/src/types.ts:391