Open History to see the last commit
1---
2id: createChatOptions
3title: createChatOptions
4---
5
6```ts
7function createChatOptions<TAdapter, TSchema, TStream, TTools, TInterrupts, TContext, TMiddleware>(options): Omit<TextActivityOptions<TAdapter, TSchema, TStream, InferredContext<TTools, TMiddleware>, readonly DefinedAgent<string, readonly SubagentTool[], SchemaInput | undefined, readonly InterruptDefinition<any, any, any, any, any>[], any, unknown, AgentProduces | undefined>[]>, "middleware" | "tools" | "threadId" | "interrupts" | "context"> & object & RuntimeContextOption<TTools, TMiddleware, TContext>;
8```
9
10Defined in: packages/ai/src/activities/chat/index.ts:834
11
12Create typed options for the chat() function without executing.
13This is useful for pre-defining configurations with full type inference.
14`threadId` is optional here. `chat()` still needs it, so pass it on the
15call.
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 \| readonly (
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 \| readonly (
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### TInterrupts
44
45`TInterrupts` *extends* readonly [`InterruptDefinition`](../interfaces/InterruptDefinition.md)\<`any`, `any`, `any`, `any`, `any`\>[] = \[\]
46
47### TContext
48
49`TContext` = `unknown`
50
51### TMiddleware
52
53`TMiddleware` *extends* `unknown`[] \| `undefined` = `undefined`
54
55## Parameters
56
57### options
58
59`Omit`\<`TextActivityOptions`\<`TAdapter`, `TSchema`, `TStream`, `any`, readonly [`DefinedAgent`](../interfaces/DefinedAgent.md)\<`string`, readonly `SubagentTool`[], [`SchemaInput`](../type-aliases/SchemaInput.md) \| `undefined`, readonly [`InterruptDefinition`](../interfaces/InterruptDefinition.md)\<`any`, `any`, `any`, `any`, `any`\>[], `any`, `unknown`, [`AgentProduces`](../type-aliases/AgentProduces.md) \| `undefined`\>[]\>,
60 \| `"middleware"`
61 \| `"tools"`
62 \| `"threadId"`
63 \| `"toolChoice"`
64 \| `"interrupts"`
65 \| `"context"`\> & `object` & `object` & `RuntimeContextOption`\<`TTools`, `TMiddleware`, `TContext`\>
66
67## Returns
68
69`Omit`\<`TextActivityOptions`\<`TAdapter`, `TSchema`, `TStream`, `InferredContext`\<`TTools`, `TMiddleware`\>, readonly [`DefinedAgent`](../interfaces/DefinedAgent.md)\<`string`, readonly `SubagentTool`[], [`SchemaInput`](../type-aliases/SchemaInput.md) \| `undefined`, readonly [`InterruptDefinition`](../interfaces/InterruptDefinition.md)\<`any`, `any`, `any`, `any`, `any`\>[], `any`, `unknown`, [`AgentProduces`](../type-aliases/AgentProduces.md) \| `undefined`\>[]\>, `"middleware"` \| `"tools"` \| `"threadId"` \| `"interrupts"` \| `"context"`\> & `object` & `RuntimeContextOption`\<`TTools`, `TMiddleware`, `TContext`\>
70
71## Example
72
73```ts
74const chatOptions = createChatOptions({
75 adapter: anthropicText('claude-sonnet-5-5'),
76})
77
78const stream = chat({ ...chatOptions, messages, threadId })
79```