Open History to see the last commit
1---
2id: TextOptions
3title: TextOptions
4---
5
6Defined in: [packages/ai/src/types.ts:1025](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1025)
7
8Options passed into the SDK and further piped to the AI provider.
9
10## Type Parameters
11
12### TProviderOptionsSuperset
13
14`TProviderOptionsSuperset` *extends* `Record`\<`string`, `any`\> = `Record`\<`string`, `any`\>
15
16### TProviderOptionsForModel
17
18`TProviderOptionsForModel` = `TProviderOptionsSuperset`
19
20### TContext
21
22`TContext` = `unknown`
23
24## Properties
25
26### abortController?
27
28```ts
29optional abortController?: AbortController;
30```
31
32Defined in: [packages/ai/src/types.ts:1125](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1125)
33
34AbortController for request cancellation.
35
36Allows you to cancel an in-progress request using an AbortController.
37Useful for implementing timeouts or user-initiated cancellations.
38
39#### Example
40
41```ts
42const abortController = new AbortController();
43setTimeout(() => abortController.abort(), 5000); // Cancel after 5 seconds
44await chat({ ..., abortController });
45```
46
47#### See
48
49https://developer.mozilla.org/en-US/docs/Web/API/AbortController
50
51***
52
53### agentLoopStrategy?
54
55```ts
56optional agentLoopStrategy?: AgentLoopStrategy;
57```
58
59Defined in: [packages/ai/src/types.ts:1053](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1053)
60
61***
62
63### approvals?
64
65```ts
66optional approvals?: ReadonlyMap<string, boolean>;
67```
68
69Defined in: [packages/ai/src/types.ts:1183](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1183)
70
71Client approval decisions for this run, keyed by approval id. The engine
72populates this from approvals carried on the incoming messages. Harness
73adapters consult it to resolve `ask`-policy permission requests (the agent
74pauses on a risky action; the client re-runs with a decision recorded
75here). Undefined for direct adapter usage outside the chat engine.
76
77***
78
79### capabilities?
80
81```ts
82optional capabilities?: CapabilityContext;
83```
84
85Defined in: [packages/ai/src/types.ts:1174](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1174)
86
87Middleware capability context for this run. The engine populates it with
88the live middleware context so harness adapters that declare
89`requires: [SomeCapability]` can read provided capabilities from inside
90`chatStream` — e.g. `getSandbox(options.capabilities)`. Capabilities are
91provisioned by middleware `setup` before the adapter runs. Undefined for
92direct adapter usage outside the chat engine.
93
94***
95
96### context?
97
98```ts
99optional context?: TContext;
100```
101
102Defined in: [packages/ai/src/types.ts:1037](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1037)
103
104Runtime context provided by the caller and passed to middleware and
105server-side tool implementations.
106
107***
108
109### ~~conversationId?~~
110
111```ts
112optional conversationId?: string;
113```
114
115Defined in: [packages/ai/src/types.ts:1111](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1111)
116
117#### Deprecated
118
119Use `threadId` instead. `conversationId` is the legacy
120pre-AG-UI name for the same concept (a stable per-conversation
121identifier used to correlate client/server devtools events). When
122`conversationId` is omitted, the runtime falls back to `threadId`
123automatically, so most callers can simply pass `threadId` (or rely
124on `chatParamsFromRequest`, which surfaces it on `params`).
125
126Will be removed in a future major release.
127
128***
129
130### lazyToolsConfig?
131
132```ts
133optional lazyToolsConfig?: LazyToolsConfig;
134```
135
136Defined in: [packages/ai/src/types.ts:1059](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1059)
137
138Optional configuration for lazy-tool discovery (tools marked `lazy: true`).
139Tunes how much of each lazy tool's description appears in the discovery
140catalog. Optional — defaults to `{ includeDescription: 'none' }`.
141
142***
143
144### logger
145
146```ts
147logger: InternalLogger;
148```
149
150Defined in: [packages/ai/src/types.ts:1132](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1132)
151
152Internal logger threaded from the chat entry point. Adapter implementations
153must call `logger.request()` before SDK calls, `logger.provider()` for each
154chunk received, and `logger.errors()` in catch blocks.
155
156***
157
158### messages
159
160```ts
161messages: ModelMessage<
162 | string
163 | ContentPart<unknown, unknown, unknown, unknown, unknown>[]
164 | null>[];
165```
166
167Defined in: [packages/ai/src/types.ts:1031](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1031)
168
169***
170
171### metadata?
172
173```ts
174optional metadata?: Record<string, any>;
175```
176
177Defined in: [packages/ai/src/types.ts:1070](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1070)
178
179Observability metadata attached to this call. Surfaced to middleware,
180devtools, and the event client; values may be arbitrarily structured
181(objects, arrays). Adapters never forward this field onto the provider
182wire request.
183
184To send provider-side request metadata, use the provider's
185`modelOptions` field instead, where the provider supports one (e.g.
186OpenAI's and OpenRouter's `metadata` are both Record<string, string>).
187
188***
189
190### model
191
192```ts
193model: string;
194```
195
196Defined in: [packages/ai/src/types.ts:1030](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1030)
197
198***
199
200### modelOptions?
201
202```ts
203optional modelOptions?: TProviderOptionsForModel;
204```
205
206Defined in: [packages/ai/src/types.ts:1071](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1071)
207
208***
209
210### outputSchema?
211
212```ts
213optional outputSchema?: SchemaInput;
214```
215
216Defined in: [packages/ai/src/types.ts:1100](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1100)
217
218Schema for structured output.
219
220**Two distinct use sites:**
221
2221. **User-facing (activity layer):** accepts any
223 [SchemaInput](../type-aliases/SchemaInput.md) — Zod, ArkType, Valibot, or a raw JSON Schema.
224 The activity layer converts to JSON Schema before handing off.
225
2262. **Adapter-facing (`chatStream` call):** the engine populates this with
227 a pre-converted JSON Schema **only** when the adapter declared
228 `supportsCombinedToolsAndSchema(modelOptions) === true`. The adapter
229 should then wire the schema into the upstream request (e.g.
230 `response_format: { type: 'json_schema', ... }`, `text.format`,
231 `output_format`, `--json-schema`) alongside any `tools`.
232
233 How the engine then takes the object depends on
234 `combinedStructuredOutputSource()`:
235 - `'text'` (default): the final-turn assistant text is the JSON.
236 - `'event'`: the adapter emits `structured-output.complete` during
237 `chatStream`. Accumulated prose is not parsed.
238
239 Adapters that did NOT declare the capability never see this field
240 populated — the engine instead invokes `structuredOutput` /
241 `structuredOutputStream` after the agent loop.
242
243***
244
245### parentRunId?
246
247```ts
248optional parentRunId?: string;
249```
250
251Defined in: [packages/ai/src/types.ts:1149](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1149)
252
253Parent run ID for AG-UI protocol nested run correlation.
254Surfaced for observability/middleware; not consumed by the LLM call.
255
256***
257
258### request?
259
260```ts
261optional request?: Request | RequestInit;
262```
263
264Defined in: [packages/ai/src/types.ts:1072](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1072)
265
266***
267
268### resume?
269
270```ts
271optional resume?: RunAgentResumeItem[];
272```
273
274Defined in: [packages/ai/src/types.ts:1164](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1164)
275
276AG-UI interrupt resume responses supplied by the client on a follow-up run.
277A first-party generic item carries the original request in `metadata`.
278
279***
280
281### runId?
282
283```ts
284optional runId?: string;
285```
286
287Defined in: [packages/ai/src/types.ts:1144](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1144)
288
289Run ID for AG-UI protocol run correlation.
290When provided, this will be used in RunStartedEvent and RunFinishedEvent.
291If not provided, a unique ID will be generated.
292
293***
294
295### state?
296
297```ts
298optional state?: unknown;
299```
300
301Defined in: [packages/ai/src/types.ts:1158](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1158)
302
303Application state mirrored in a STATE_SNAPSHOT before an interrupt terminal.
304
305***
306
307### subagentRunId?
308
309```ts
310optional subagentRunId?: string;
311```
312
313Defined in: [packages/ai/src/types.ts:1155](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1155)
314
315AG-UI subagent run id when this chat runs as a child of another run.
316A child `chat()` passes `ctx.subagentRunId`. Middleware reads it as
317`ctx.subagentRunId`. Absent on a top-level run.
318
319***
320
321### systemPrompts?
322
323```ts
324optional systemPrompts?: SystemPrompt[];
325```
326
327Defined in: [packages/ai/src/types.ts:1052](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1052)
328
329System prompts to include with the request.
330
331Accepts plain strings (the common case) or `{ content, metadata }`
332objects that let providers attach typed metadata (e.g. Anthropic
333`cache_control` for prompt caching) per prompt. At the chat call site
334the adapter narrows `metadata`'s type via `~types['systemPromptMetadata']`
335— providers that don't declare one default to `never`, which makes the
336field carry no meaningful value (TypeScript will only accept
337`undefined` there). Provider-foreign metadata that reaches an adapter
338via JS / `as any` is silently dropped, never written to the wire.
339
340#### See
341
342SystemPrompt
343
344***
345
346### threadId?
347
348```ts
349optional threadId?: string;
350```
351
352Defined in: [packages/ai/src/types.ts:1138](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1138)
353
354Thread ID for AG-UI protocol run correlation.
355When provided, this will be used in RunStartedEvent and RunFinishedEvent.
356
357***
358
359### tools?
360
361```ts
362optional tools?: AnyTool[];
363```
364
365Defined in: [packages/ai/src/types.ts:1032](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1032)