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

StructuredOutputPart.md

98 lines2.1 KB

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