Open History to see the last commit
1---
2id: chatParamsFromRequestBody
3title: chatParamsFromRequestBody
4---
5
6```ts
7function chatParamsFromRequestBody(body): Promise<{
8 aguiContext: Context[];
9 forwardedProps: Record<string, unknown>;
10 messages: (
11 | UIMessage<unknown>
12 | ModelMessage<
13 | string
14 | ContentPart<unknown, unknown, unknown, unknown, unknown>[]
15 | null>)[];
16 parentRunId?: string;
17 resume?: RunAgentResumeItem[];
18 runId: string;
19 state: unknown;
20 threadId: string;
21 tools: object[];
22}>;
23```
24
25Defined in: packages/ai/src/utilities/chat-params.ts:204
26
27Parse and validate an HTTP request body as an AG-UI `RunAgentInput`.
28
29Returns a spread-friendly object whose `messages` field is suitable for
30passing directly to `chat({ messages })`. The existing
31`convertMessagesToModelMessages` handles AG-UI fan-out dedup and
32reasoning/activity/developer-role normalization internally.
33
34Validated structurally against the AG-UI `RunAgentInput` contract without a
35schema library, so this package pulls in no validation runtime of its own.
36
37## Parameters
38
39### body
40
41`unknown`
42
43## Returns
44
45`Promise`\<\{
46 `aguiContext`: `Context`[];
47 `forwardedProps`: `Record`\<`string`, `unknown`\>;
48 `messages`: (
49 \| [`UIMessage`](../interfaces/UIMessage.md)\<`unknown`\>
50 \| [`ModelMessage`](../interfaces/ModelMessage.md)\<
51 \| `string`
52 \| [`ContentPart`](../type-aliases/ContentPart.md)\<`unknown`, `unknown`, `unknown`, `unknown`, `unknown`\>[]
53 \| `null`\>)[];
54 `parentRunId?`: `string`;
55 `resume?`: [`RunAgentResumeItem`](../type-aliases/RunAgentResumeItem.md)[];
56 `runId`: `string`;
57 `state`: `unknown`;
58 `threadId`: `string`;
59 `tools`: `object`[];
60\}\>
61
62## Throws
63
64An error with a migration-pointing message when the body does
65 not conform to AG-UI `RunAgentInput`. Surface this as a
66 400 Bad Request to the client.