Open History to see the last commit
1---
2id: UIMessage
3title: UIMessage
4---
5
6Defined in: packages/ai/src/types.ts:787
7
8UIMessage - Domain-specific message format optimized for building chat UIs
9Contains parts that can be text, tool calls, or tool results. Generic over
10the structured-output data type so `useChat({ outputSchema })`'s schema
11narrows `parts.find(p => p.type === 'structured-output').data` on the
12consumer side without manual casts.
13
14## Type Parameters
15
16### TData
17
18`TData` = `unknown`
19
20## Properties
21
22### createdAt?
23
24```ts
25optional createdAt?: Date;
26```
27
28Defined in: packages/ai/src/types.ts:791
29
30***
31
32### id
33
34```ts
35id: string;
36```
37
38Defined in: packages/ai/src/types.ts:788
39
40***
41
42### metadata?
43
44```ts
45optional metadata?: Record<string, any>;
46```
47
48Defined in: packages/ai/src/types.ts:798
49
50Optional AG-UI metadata bag. TanStack writes the `tanstack` key.
51User keys stay at the top.
52
53***
54
55### name?
56
57```ts
58optional name?: string;
59```
60
61Defined in: packages/ai/src/types.ts:793
62
63Optional AG-UI sender name. Converters preserve it across wire and persist.
64
65***
66
67### parts
68
69```ts
70parts: MessagePart<TData>[];
71```
72
73Defined in: packages/ai/src/types.ts:790
74
75***
76
77### role
78
79```ts
80role: "assistant" | "user" | "activity" | "system";
81```
82
83Defined in: packages/ai/src/types.ts:789