Open History to see the last commit
1---
2id: TextOptions
3title: TextOptions
4---
5
6# Interface: TextOptions\<TProviderOptionsSuperset, TProviderOptionsForModel\>
7
8Defined in: [types.ts:545](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L545)
9
10Options passed into the SDK and further piped to the AI provider.
11
12## Type Parameters
13
14### TProviderOptionsSuperset
15
16`TProviderOptionsSuperset` *extends* `Record`\<`string`, `any`\> = `Record`\<`string`, `any`\>
17
18### TProviderOptionsForModel
19
20`TProviderOptionsForModel` = `TProviderOptionsSuperset`
21
22## Properties
23
24### abortController?
25
26```ts
27optional abortController: AbortController;
28```
29
30Defined in: [types.ts:628](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L628)
31
32AbortController for request cancellation.
33
34Allows you to cancel an in-progress request using an AbortController.
35Useful for implementing timeouts or user-initiated cancellations.
36
37#### Example
38
39```ts
40const abortController = new AbortController();
41setTimeout(() => abortController.abort(), 5000); // Cancel after 5 seconds
42await chat({ ..., abortController });
43```
44
45#### See
46
47https://developer.mozilla.org/en-US/docs/Web/API/AbortController
48
49***
50
51### agentLoopStrategy?
52
53```ts
54optional agentLoopStrategy: AgentLoopStrategy;
55```
56
57Defined in: [types.ts:553](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L553)
58
59***
60
61### conversationId?
62
63```ts
64optional conversationId: string;
65```
66
67Defined in: [types.ts:614](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L614)
68
69Conversation ID for correlating client and server-side devtools events.
70When provided, server-side events will be linked to the client conversation in devtools.
71
72***
73
74### maxTokens?
75
76```ts
77optional maxTokens: number;
78```
79
80Defined in: [types.ts:588](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L588)
81
82The maximum number of tokens to generate in the response.
83
84Provider usage:
85- OpenAI: `max_output_tokens` (number) - includes visible output and reasoning tokens
86- Anthropic: `max_tokens` (number, required) - range x >= 1
87- Gemini: `generationConfig.maxOutputTokens` (number)
88
89***
90
91### messages
92
93```ts
94messages: ModelMessage<
95 | string
96 | ContentPart<unknown, unknown, unknown, unknown, unknown>[]
97 | null>[];
98```
99
100Defined in: [types.ts:550](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L550)
101
102***
103
104### metadata?
105
106```ts
107optional metadata: Record<string, any>;
108```
109
110Defined in: [types.ts:599](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L599)
111
112Additional metadata to attach to the request.
113Can be used for tracking, debugging, or passing custom information.
114Structure and constraints vary by provider.
115
116Provider usage:
117- OpenAI: `metadata` (Record<string, string>) - max 16 key-value pairs, keys max 64 chars, values max 512 chars
118- Anthropic: `metadata` (Record<string, any>) - includes optional user_id (max 256 chars)
119- Gemini: Not directly available in TextProviderOptions
120
121***
122
123### model
124
125```ts
126model: string;
127```
128
129Defined in: [types.ts:549](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L549)
130
131***
132
133### modelOptions?
134
135```ts
136optional modelOptions: TProviderOptionsForModel;
137```
138
139Defined in: [types.ts:600](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L600)
140
141***
142
143### outputSchema?
144
145```ts
146optional outputSchema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>;
147```
148
149Defined in: [types.ts:609](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L609)
150
151Zod schema for structured output.
152When provided, the adapter should use the provider's native structured output API
153to ensure the response conforms to this schema.
154The schema will be converted to JSON Schema format before being sent to the provider.
155
156***
157
158### request?
159
160```ts
161optional request: Request | RequestInit;
162```
163
164Defined in: [types.ts:601](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L601)
165
166***
167
168### systemPrompts?
169
170```ts
171optional systemPrompts: string[];
172```
173
174Defined in: [types.ts:552](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L552)
175
176***
177
178### temperature?
179
180```ts
181optional temperature: number;
182```
183
184Defined in: [types.ts:566](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L566)
185
186Controls the randomness of the output.
187Higher values (e.g., 0.8) make output more random, lower values (e.g., 0.2) make it more focused and deterministic.
188Range: [0.0, 2.0]
189
190Note: Generally recommended to use either temperature or topP, but not both.
191
192Provider usage:
193- OpenAI: `temperature` (number) - in text.top_p field
194- Anthropic: `temperature` (number) - ranges from 0.0 to 1.0, default 1.0
195- Gemini: `generationConfig.temperature` (number) - ranges from 0.0 to 2.0
196
197***
198
199### tools?
200
201```ts
202optional tools: Tool<any, any, any>[];
203```
204
205Defined in: [types.ts:551](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L551)
206
207***
208
209### topP?
210
211```ts
212optional topP: number;
213```
214
215Defined in: [types.ts:579](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L579)
216
217Nucleus sampling parameter. An alternative to temperature sampling.
218The model considers the results of tokens with topP probability mass.
219For example, 0.1 means only tokens comprising the top 10% probability mass are considered.
220
221Note: Generally recommended to use either temperature or topP, but not both.
222
223Provider usage:
224- OpenAI: `text.top_p` (number)
225- Anthropic: `top_p` (number | null)
226- Gemini: `generationConfig.topP` (number)