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

createChatOptions.md

71 lines2.9 KB

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