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

StructuredOutputPart.md

100 lines2.3 KB

1---
2id: StructuredOutputPart
3title: StructuredOutputPart
4---
5​
6# Interface: StructuredOutputPart\<TData\>
7​
8Defined in: [packages/typescript/ai/src/types.ts:390](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L390)
9​
10StructuredOutputPart — a typed structured response attached to the assistant
11message that produced it. Generic over the schema-inferred data type so
12consumers can thread `useChat({ outputSchema })`'s schema all the way down
13to `messages[i].parts[j].data`. Defaults to `unknown` so untyped consumers
14(e.g. internal codepaths that don't know about TSchema) keep working.
15​
16## Type Parameters
17​
18### TData
19​
20`TData` = `unknown`
21​
22## Properties
23​
24### data?
25​
26```ts
27optional data: TData;
28```
29​
30Defined in: [packages/typescript/ai/src/types.ts:396](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L396)
31​
32Validated final object — only set when `status === 'complete'`.
33​
34***
35​
36### errorMessage?
37​
38```ts
39optional errorMessage: string;
40```
41​
42Defined in: [packages/typescript/ai/src/types.ts:402](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L402)
43​
44Populated when `status === 'error'`.
45​
46***
47​
48### partial?
49​
50```ts
51optional partial: DeepPartial<TData>;
52```
53​
54Defined in: [packages/typescript/ai/src/types.ts:394](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L394)
55​
56Progressive parse of `raw` via parsePartialJSON — populated while streaming and after complete.
57​
58***
59​
60### raw
61​
62```ts
63raw: string;
64```
65​
66Defined in: [packages/typescript/ai/src/types.ts:398](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L398)
67​
68Accumulating JSON buffer. Source of truth for wire round-trip.
69​
70***
71​
72### reasoning?
73​
74```ts
75optional reasoning: string;
76```
77​
78Defined in: [packages/typescript/ai/src/types.ts:400](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L400)
79​
80Optional chain-of-thought surfaced by reasoning models alongside the structured output.
81​
82***
83​
84### status
85​
86```ts
87status: "error" | "streaming" | "complete";
88```
89​
90Defined in: [packages/typescript/ai/src/types.ts:392](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L392)
91​
92***
93​
94### type
95​
96```ts
97type: "structured-output";
98```
99​
100Defined in: [packages/typescript/ai/src/types.ts:391](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L391)