0
Fork 0
mirror of https://github.com/TanStack/ai.git synced 2026-11-16 19:38:41 +00:00
ai/docs/reference/functions/createChatOptions.md
github-actions[bot] 92ed27eefc
docs: regenerate API documentation (#1305)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-09-03 11:09:53 +02:00

2.4 KiB

id title
createChatOptions createChatOptions

Function: createChatOptions()

function createChatOptions<TAdapter, TSchema, TStream, TTools, TInterrupts, TContext, TMiddleware>(options): Omit<TextActivityOptions<TAdapter, TSchema, TStream, InferredContext<TTools, TMiddleware>>, "middleware" | "tools" | "interrupts" | "context"> & object & RuntimeContextOption<TTools, TMiddleware, TContext>;

Defined in: packages/ai/src/activities/chat/index.ts:594

Create typed options for the chat() function without executing. This is useful for pre-defining configurations with full type inference.

Type Parameters

TAdapter

TAdapter extends AnyTextAdapter

TSchema

TSchema extends SchemaInput | undefined = undefined

TStream

TStream extends boolean = true

TTools

TTools extends | readonly ( | Omit<Tool<any, any, any, any>, "execute"> & object & object | ProviderTool<string, TAdapter["~types"]["toolCapabilities"][number]>)[] | undefined = | readonly ( | Omit<Tool<any, any, any, any>, "execute"> & object & object | ProviderTool<string, TAdapter["~types"]["toolCapabilities"][number]>)[] | undefined

TInterrupts

TInterrupts extends readonly InterruptDefinition<any, any, any, any, any>[] = []

TContext

TContext = unknown

TMiddleware

TMiddleware extends unknown[] | undefined = undefined

Parameters

options

TextActivityOptionsWithContext<TAdapter, TSchema, TStream, TTools, TInterrupts, TContext, TMiddleware>

Returns

Omit<TextActivityOptions<TAdapter, TSchema, TStream, InferredContext<TTools, TMiddleware>>, "middleware" | "tools" | "interrupts" | "context"> & object & RuntimeContextOption<TTools, TMiddleware, TContext>

Example

const chatOptions = createChatOptions({
  adapter: anthropicText('claude-sonnet-4-5'),
})

const stream = chat({ ...chatOptions, messages })