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

UIMessage.md

83 lines1.7 KB

1---
2id: UIMessage
3title: UIMessage
4---
5​
6Defined in: [packages/ai/src/types.ts:610](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L610)
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:614](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L614)
29​
30***
31​
32### id
33​
34```ts
35id: string;
36```
37​
38Defined in: [packages/ai/src/types.ts:611](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L611)
39​
40***
41​
42### metadata?
43​
44```ts
45optional metadata?: Record<string, any>;
46```
47​
48Defined in: [packages/ai/src/types.ts:621](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L621)
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:616](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L616)
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:613](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L613)
74​
75***
76​
77### role
78​
79```ts
80role: "assistant" | "user" | "system";
81```
82​
83Defined in: [packages/ai/src/types.ts:612](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L612)