Open History to see the last commit
1---
2id: createChatOptions
3title: createChatOptions
4---
5
6# Function: createChatOptions()
7
8```ts
9function createChatOptions<TAdapter, TSchema, TStream, TTools, TMiddleware>(options): TextActivityOptions<TAdapter, TSchema, TStream, InferredContext<TTools, TMiddleware>>;
10```
11
12Defined in: [packages/ai/src/activities/chat/index.ts:346](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/index.ts#L346)
13
14Create typed options for the chat() function without executing.
15This is useful for pre-defining configurations with full type inference.
16
17## Type Parameters
18
19### TAdapter
20
21`TAdapter` *extends* [`AnyTextAdapter`](../type-aliases/AnyTextAdapter.md)
22
23### TSchema
24
25`TSchema` *extends* [`SchemaInput`](../type-aliases/SchemaInput.md) \| `undefined` = `undefined`
26
27### TStream
28
29`TStream` *extends* `boolean` = `true`
30
31### TTools
32
33`TTools` *extends*
34 \| (
35 \| `Omit`\<[`Tool`](../interfaces/Tool.md)\<`any`, `any`, `any`, `any`\>, `"execute"`\> & `object` & `object`
36 \| [`ProviderTool`](../interfaces/ProviderTool.md)\<`string`, `TAdapter`\[`"~types"`\]\[`"toolCapabilities"`\]\[`number`\]\>)[]
37 \| `undefined` =
38 \| (
39 \| `Omit`\<[`Tool`](../interfaces/Tool.md)\<`any`, `any`, `any`, `any`\>, `"execute"`\> & `object` & `object`
40 \| [`ProviderTool`](../interfaces/ProviderTool.md)\<`string`, `TAdapter`\[`"~types"`\]\[`"toolCapabilities"`\]\[`number`\]\>)[]
41 \| `undefined`
42
43### TMiddleware
44
45`TMiddleware` *extends*
46 \| [`ChatMiddleware`](../interfaces/ChatMiddleware.md)\<`any`\>[]
47 \| `undefined` =
48 \| [`ChatMiddleware`](../interfaces/ChatMiddleware.md)\<`any`\>[]
49 \| `undefined`
50
51## Parameters
52
53### options
54
55`TextActivityOptionsWithContext`\<`TAdapter`, `TSchema`, `TStream`, `TTools`, `TMiddleware`\>
56
57## Returns
58
59`TextActivityOptions`\<`TAdapter`, `TSchema`, `TStream`, `InferredContext`\<`TTools`, `TMiddleware`\>\>
60
61## Example
62
63```ts
64const chatOptions = createChatOptions({
65 adapter: anthropicText('claude-sonnet-4-5'),
66})
67
68const stream = chat({ ...chatOptions, messages })
69```