@ai-sdk/anthropic 4.0.96 → 4.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -244,10 +244,196 @@ Initial usage may be incomplete; use `result.usage` for final token counts.
244
244
  Like other custom parts, this event is included in response content and forwarded
245
245
  to UI message streams. It is ignored when replaying conversation history to Anthropic.
246
246
 
247
+ ### Message Threads
248
+
249
+ [Anthropic message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads)
250
+ reduce request upload size and time to first token in long conversations. The first
251
+ request sends the full conversation; subsequent requests send only new messages.
252
+ Token usage, pricing, and rate limits remain unchanged. Prompt caching is separate.
253
+
254
+ ```ts
255
+ import { anthropic } from '@ai-sdk/anthropic';
256
+ import { generateText } from 'ai';
257
+
258
+ const model = anthropic('claude-sonnet-4-6');
259
+ const first = await generateText({
260
+ model,
261
+ system: 'Keep replies brief.',
262
+ prompt: 'Remember that my favorite color is cobalt blue.',
263
+ providerOptions: { anthropic: { thread: { type: 'create' } } },
264
+ });
265
+
266
+ if (first.response.id == null) throw new Error('Missing message ID.');
267
+
268
+ const second = await generateText({
269
+ model,
270
+ prompt: 'What is my favorite color?',
271
+ providerOptions: {
272
+ anthropic: {
273
+ thread: { type: 'continue', previousMessageId: first.response.id },
274
+ },
275
+ },
276
+ });
277
+ ```
278
+
279
+ The provider adds the `message-threads-2026-08-12` beta header. On continuation it
280
+ omits `system` and tool definitions from the request, even if supplied: Anthropic
281
+ retains them from the create request. If the create request used tools, you must
282
+ supply identical tool definitions to the SDK on continuation for tool name mapping,
283
+ execution, tool choice, and tool beta headers. They are not uploaded again.
284
+ Supplied system instructions are ignored on continuation; the provider emits a
285
+ compatibility warning when supplied system or tool definitions are omitted.
286
+ Start a new thread to change instructions rather than passing new leading system
287
+ messages to a continuation.
288
+
289
+ **Conversation management is explicit.** The provider does not retain history,
290
+ remove previously sent messages, or automatically replay requests. Keep a full
291
+ local copy of the conversation. Passing the entire history on continuation can
292
+ duplicate messages or cause an API error. For tool calls, continue with only the
293
+ new tool results. In a multi-step agent, use `prepareStep` to update the response
294
+ ID and select only new messages; simply setting `thread: { type: 'create' }` on an
295
+ agent does not automatically continue its thread.
296
+
297
+ For example, with an existing client-side `weather` tool:
298
+
299
+ ```ts
300
+ import { ToolLoopAgent, stepCountIs } from 'ai';
301
+
302
+ const agent = new ToolLoopAgent({
303
+ model,
304
+ tools: { weather },
305
+ stopWhen: stepCountIs(5),
306
+ prepareStep: ({ steps }) => {
307
+ const previous = steps.at(-1);
308
+ if (previous == null) {
309
+ return { providerOptions: { anthropic: { thread: { type: 'create' } } } };
310
+ }
311
+ const previousMessageId = previous.response.id;
312
+ if (previousMessageId == null) throw new Error('Missing message ID.');
313
+ return {
314
+ messages: previous.response.messages.filter(m => m.role === 'tool'),
315
+ providerOptions: {
316
+ anthropic: { thread: { type: 'continue', previousMessageId } },
317
+ },
318
+ };
319
+ },
320
+ });
321
+ ```
322
+
323
+ This pattern is for a loop with client-side tools that execute without approval.
324
+ Provider-executed tool continuations and tool-approval flows require their own
325
+ message selection. The compatibility warning about retained instructions and tool
326
+ definitions is expected in this example. Persist the original input and
327
+ each step's response messages for recovery; never rerun completed tools just to
328
+ rebuild history. Do not reuse a static continuation ID across multiple steps.
329
+
330
+ **Pin content-dependent beta headers.** The beta header set is fixed for a thread,
331
+ but features such as PDFs and Files API references enable headers based on the
332
+ messages in the current request. For example, when creating a thread with a PDF,
333
+ set `anthropicBeta: ['pdfs-2024-09-25']` on both the create request and every
334
+ continuation, including text-only continuations. The provider warns when message
335
+ content enables a beta that has not been pinned explicitly through `anthropicBeta`
336
+ or request headers. Plan for the features the conversation will use; start a new
337
+ thread with full history if a later turn needs additional beta headers.
338
+
339
+ Threads expire five minutes after their last request and can become unavailable
340
+ earlier. Inspect `APICallError.data.error.details.error_code` (after narrowing the
341
+ unknown `data` value). On `thread_not_found`, `thread_already_continued`, or
342
+ `thread_continue_in_flight`, replay the full conversation once with
343
+ `thread: { type: 'create' }`, including the original system prompt and tools.
344
+ Do not treat every 404 as an expired thread. Remove cache breakpoints from older
345
+ replayed messages to stay within Anthropic's four-breakpoint limit. If the
346
+ conversation cannot be stored, send the full history without `thread`.
347
+
348
+ Continue only from the latest response ID, which can be continued once. With
349
+ `streamText`, fully consume the stream before using `await result.response` to
350
+ continue. Check that `await result.finishReason` is not `'interrupted'` before continuing.
351
+ A partial or aborted stream must not be treated as a completed turn.
352
+ If a stream drops, recovery is the application's responsibility; don't blindly
353
+ append a replay to output already shown to the user.
354
+
355
+ To change the system prompt, tools, model, thinking, tool choice, output format,
356
+ context management, top-level cache control, or beta headers, start a new thread
357
+ with the full history. Fixed fields must otherwise have the same values on every
358
+ request. Send MCP configuration and container IDs on each request that needs them.
359
+ After a fallback model responds, start a new thread with the full history. Detect
360
+ this through a `fallback_message` entry in
361
+ `providerMetadata.anthropic.iterations`. After a refusal (`finishReason ===
362
+ 'content-filter'` or `rawFinishReason === 'refusal'`), start a new thread with the
363
+ refused turn removed or rephrased.
364
+
365
+ On models that bind preserved thinking to the prompt prefix, changing system
366
+ instructions or tools can invalidate earlier reasoning. Remove the earlier
367
+ reasoning parts, or set `sendReasoning: false`, when creating that new thread.
368
+
369
+ The provider-level interface accepts empty continuation prompts for `pause_turn`,
370
+ but `generateText` and `streamText` currently reject empty `messages`. Check
371
+ `rawFinishReason === 'pause_turn'` to detect this case. Resuming an empty turn
372
+ requires using the provider-level `doGenerate` or `doStream` interface with the
373
+ same fixed settings; the agent example above does not handle paused server turns.
374
+
375
+ The `@ai-sdk/anthropic` provider supports this beta on the native Claude API and
376
+ compatible Anthropic-managed endpoints. Anthropic's Claude Platform on AWS and
377
+ Anthropic-managed Google Cloud are distinct from Amazon Bedrock and Vertex AI.
378
+ The direct `@ai-sdk/anthropic-aws` provider supports message threads; with SigV4,
379
+ use the same IAM role or IAM user throughout the thread.
380
+
381
+ `@ai-sdk/amazon-bedrock/anthropic` and `@ai-sdk/google-vertex/anthropic` do not
382
+ support message threads.
383
+
384
+ Threads do not support Message Batches, compaction, or context editing other than
385
+ `clear_thinking_20251015` with `keep: 'all'`. They are not eligible for zero data
386
+ retention or HIPAA readiness. Contents are encrypted in memory, never written to
387
+ durable storage, and deleted within one hour of their last use. There is no API
388
+ to list, read, or delete threads. See Anthropic's documentation for platform
389
+ availability and all limitations.
390
+
391
+ ### Streaming heartbeats
392
+
393
+ To receive typed Anthropic heartbeat events, set
394
+ `providerOptions.anthropic.includePings: true`. This option defaults to `false`
395
+ and is handled locally; it is not sent in the Anthropic request body.
396
+
397
+ ```ts
398
+ const result = streamText({
399
+ model: anthropic('claude-haiku-4-5'),
400
+ prompt: 'Explain how rainbows form.',
401
+ providerOptions: { anthropic: { includePings: true } },
402
+ });
403
+
404
+ for await (const part of result.stream) {
405
+ if (part.type === 'ping') console.log('Provider is still connected.');
406
+ }
407
+ ```
408
+
409
+ Pings are transient stream events. They do not contain generated output, change
410
+ usage, reset model-output timeouts, or become response content. They are omitted
411
+ from text projections and UI message streams. Raw pings remain available through
412
+ `include.rawChunks` independently of this option. Workflow durable streams record stream parts, including
413
+ pings, even though pings are excluded from generated content and UI messages.
414
+ This option applies to the Anthropic Messages implementation (including wrappers
415
+ that use it); Amazon Bedrock Converse does not emit typed Anthropic pings.
416
+
417
+ Enable this option only when all normalized stream consumers support the `ping`
418
+ part. In particular, a Gateway server must negotiate support before forwarding
419
+ these parts to older SDK clients. This option does not add transport keepalives to
420
+ UI responses; applications can send SSE comments at their transport boundary.
421
+
247
422
  ### Provider options
248
423
 
249
424
  The following optional provider options are available for Anthropic models:
250
425
 
426
+ - `thread` _object_
427
+
428
+ Optional. Use `{ type: 'create' }` to create a short-lived server-side message
429
+ thread, or `{ type: 'continue', previousMessageId: string }` to continue one.
430
+ The required beta header is added automatically. See [Message Threads](#message-threads).
431
+
432
+ - `includePings` _boolean_
433
+
434
+ Optional. Defaults to `false`. Emit typed `ping` parts during streaming without
435
+ enabling raw chunks. See [Streaming heartbeats](#streaming-heartbeats).
436
+
251
437
  - `disableParallelToolUse` _boolean_
252
438
 
253
439
  Optional. Disables the use of parallel tool calls. Defaults to `false`.
@@ -273,6 +459,18 @@ The following optional provider options are available for Anthropic models:
273
459
 
274
460
  Optional. See [Fast Mode section](#fast-mode) for more details.
275
461
 
462
+ - `serviceTier` _"auto" | "standard_only"_
463
+
464
+ Optional. Selects whether to use priority capacity when available (`"auto"`)
465
+ or standard capacity only (`"standard_only"`), sent as `service_tier`.
466
+ MiniMax uses its own `"standard"` and `"priority"` values. A tier belonging
467
+ to another known provider is omitted with an unsupported-setting warning.
468
+ See [Anthropic service tiers](https://platform.claude.com/docs/en/api/service-tiers).
469
+
470
+ The applied tier, when returned by the API, is available as
471
+ `providerMetadata.anthropic.serviceTier` for generation, streaming and batch
472
+ results. The original `usage.service_tier` remains in the raw usage metadata.
473
+
276
474
  - `inferenceGeo` _"us" | "global"_
277
475
 
278
476
  Optional. See [Data Residency section](#data-residency) for more details.
@@ -1972,7 +2170,61 @@ const result = await generateText({
1972
2170
  });
1973
2171
  ```
1974
2172
 
1975
- To change a tool's definition, remove the old definition at the end of one request, then carry the conversation forward with the updated definition in `tools` on the next request.
2173
+ #### Defining Tools by Value
2174
+
2175
+ A `tool_addition` can also define the tool by value with `tool`, in the same shape as an entry of the `tools` option. The tool does not need to be declared in `tools` up front, which lets you introduce tools that did not exist when the conversation started, for example after an MCP server connects. Defining a tool under an existing name replaces the earlier definition from that point on, so this also changes a tool's schema mid-conversation. The required `inline-tools-2026-09-15` beta header is added automatically.
2176
+
2177
+ ```ts
2178
+ import { anthropic } from '@ai-sdk/anthropic';
2179
+ import { generateText } from 'ai';
2180
+
2181
+ const result = await generateText({
2182
+ model: anthropic('claude-opus-4-8'),
2183
+ // required for system messages inside `messages`:
2184
+ allowSystemInMessages: true,
2185
+ messages: [
2186
+ { role: 'user', content: 'What is the weather forecast for Paris?' },
2187
+ {
2188
+ role: 'system',
2189
+ content: '',
2190
+ providerOptions: {
2191
+ anthropic: {
2192
+ toolChanges: [
2193
+ {
2194
+ type: 'tool_addition',
2195
+ tool: {
2196
+ type: 'function',
2197
+ name: 'get_forecast',
2198
+ description: 'Get 5-day forecast',
2199
+ inputSchema: {
2200
+ type: 'object',
2201
+ properties: { city: { type: 'string' } },
2202
+ required: ['city'],
2203
+ },
2204
+ },
2205
+ },
2206
+ ],
2207
+ },
2208
+ },
2209
+ },
2210
+ ],
2211
+ });
2212
+ ```
2213
+
2214
+ <Note>
2215
+ A tool defined by value is only known to the model. It is not part of the
2216
+ `tools` option, so functions like `generateText` cannot execute its calls. Use
2217
+ it when you handle the tool calls yourself, or declare the tool in `tools` and
2218
+ add it by reference with `toolName` to have the AI SDK execute it.
2219
+ `inputSchema` is a plain JSON Schema object.
2220
+ </Note>
2221
+
2222
+ <Note>
2223
+ The computer use tools cannot be defined in a message. Declare them in `tools`
2224
+ and add them by reference with `toolName`. The AI SDK ignores such an addition
2225
+ and emits a warning. A `tool_removal` always references the tool by
2226
+ `toolName`.
2227
+ </Note>
1976
2228
 
1977
2229
  <Note>
1978
2230
  Tool changes are not supported on the initial system message. The AI SDK
@@ -2168,6 +2420,45 @@ const result = await generateText({
2168
2420
 
2169
2421
  Supported file types include CSV, Excel, JSON, XML, images (JPEG, PNG, GIF, WebP), and text files.
2170
2422
 
2423
+ #### Managing Files
2424
+
2425
+ `anthropic.files()` also supports metadata reads, generated-file downloads, and deletion directly through its optional FilesV4 methods:
2426
+
2427
+ ```ts
2428
+ import { anthropic } from '@ai-sdk/anthropic';
2429
+ import { uploadFile } from 'ai';
2430
+
2431
+ const files = anthropic.files();
2432
+ const { providerReference } = await uploadFile({
2433
+ api: files,
2434
+ data: { type: 'text', text: 'Notes for Claude.' },
2435
+ filename: 'notes.txt',
2436
+ });
2437
+
2438
+ try {
2439
+ // These optional FilesV4 operations are supported by Anthropic.
2440
+ const metadata = await files.getFileMetadata!({ file: providerReference });
2441
+ console.log(metadata.filename, metadata.mediaType, metadata.byteSize);
2442
+ } finally {
2443
+ await files.deleteFile!({ file: providerReference });
2444
+ }
2445
+ ```
2446
+
2447
+ For a file generated by code execution or a skill, pass its file ID as the Anthropic provider reference:
2448
+
2449
+ ```ts
2450
+ const generatedFile = { anthropic: 'file_generated_by_code_execution' };
2451
+ const metadata = await files.getFileMetadata!({ file: generatedFile });
2452
+ if (metadata.providerMetadata?.anthropic?.downloadable === true) {
2453
+ const download = await files.downloadFile!({ file: generatedFile });
2454
+ const bytes = await new Response(download.content).arrayBuffer();
2455
+ }
2456
+ ```
2457
+
2458
+ Downloads return a `ReadableStream<Uint8Array>` and the response media type when available. Anthropic only allows downloads when `downloadable` is `true`; downloading a file you uploaded returns an API error. Metadata and deletion work for both uploaded and generated files. Returned standard metadata includes `filename`, `mediaType`, `byteSize`, `createdAt`, and `expiresAt` when available; `providerMetadata.anthropic` uses the same camelCase fields for uploads and metadata reads, including `downloadable`.
2459
+
2460
+ All operations accept `abortSignal` and per-call `headers`. The provider retains its existing Files beta header by default; per-call headers can override it. Anthropic's current Files API also supports requests without that beta, which may return additional metadata such as expiration.
2461
+
2171
2462
  #### Error Handling
2172
2463
 
2173
2464
  Code execution errors are handled differently depending on whether you're using streaming or non-streaming:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "4.0.96",
3
+ "version": "4.0.98",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.35",
39
- "@ai-sdk/provider-utils": "5.0.74"
38
+ "@ai-sdk/provider": "4.0.36",
39
+ "@ai-sdk/provider-utils": "5.0.75"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
@@ -35,13 +35,26 @@ export interface AnthropicSystemMessage {
35
35
  * conversation's tool set without invalidating the prompt cache.
36
36
  *
37
37
  * Only valid inside system messages that appear in the `messages` array.
38
- * Requires the `mid-conversation-tool-changes-2026-07-01` beta.
38
+ * Changes by reference require the `mid-conversation-tool-changes-2026-07-01`
39
+ * beta. Additions by value (`tool_definition`) require the
40
+ * `inline-tools-2026-09-15` beta, which also covers changes by reference.
39
41
  */
40
- export interface AnthropicToolChangeContent {
41
- type: 'tool_addition' | 'tool_removal';
42
- tool: { type: 'tool_reference'; name: string };
43
- cache_control?: never;
44
- }
42
+ export type AnthropicToolChangeContent =
43
+ | {
44
+ type: 'tool_addition' | 'tool_removal';
45
+ tool: { type: 'tool_reference'; name: string };
46
+ cache_control?: never;
47
+ }
48
+ | {
49
+ type: 'tool_addition';
50
+ /**
51
+ * The tool definition, in the same shape as an entry of the top-level
52
+ * `tools` array. It replaces any earlier definition with the same name
53
+ * from this point on.
54
+ */
55
+ tool: { type: 'tool_definition'; definition: AnthropicTool };
56
+ cache_control?: never;
57
+ };
45
58
 
46
59
  export interface AnthropicUserMessage {
47
60
  role: 'user';
@@ -1072,12 +1085,14 @@ export const anthropicResponseSchema = lazySchema(() =>
1072
1085
  ),
1073
1086
  stop_reason: z.string().nullish(),
1074
1087
  stop_sequence: z.string().nullish(),
1088
+ service_tier: z.string().nullish(),
1075
1089
  stop_details: anthropicStopDetailsSchema().nullish(),
1076
1090
  input_transformations: z
1077
1091
  .array(anthropicInputTransformationSchema())
1078
1092
  .nullish(),
1079
1093
  safeguard_results: z.array(anthropicSafeguardResultSchema()).nullish(),
1080
1094
  usage: z.looseObject({
1095
+ service_tier: z.string().nullish(),
1081
1096
  input_tokens: z.number(),
1082
1097
  output_tokens: z.number(),
1083
1098
  output_tokens_details: z
@@ -1156,7 +1171,9 @@ export const anthropicChunkSchema = lazySchema(() =>
1156
1171
  id: z.string().nullish(),
1157
1172
  model: z.string().nullish(),
1158
1173
  role: z.string().nullish(),
1174
+ service_tier: z.string().nullish(),
1159
1175
  usage: z.looseObject({
1176
+ service_tier: z.string().nullish(),
1160
1177
  input_tokens: z.number(),
1161
1178
  cache_creation_input_tokens: z.number().nullish(),
1162
1179
  cache_read_input_tokens: z.number().nullish(),
@@ -1508,6 +1525,7 @@ export const anthropicChunkSchema = lazySchema(() =>
1508
1525
  .nullish(),
1509
1526
  }),
1510
1527
  usage: z.looseObject({
1528
+ service_tier: z.string().nullish(),
1511
1529
  input_tokens: z.number().nullish(),
1512
1530
  output_tokens: z.number(),
1513
1531
  output_tokens_details: z
@@ -260,6 +260,12 @@ export class AnthropicBatch implements BatchV4<{
260
260
  userSuppliedBetas: new Set(explicitBatchBetas),
261
261
  },
262
262
  });
263
+ if (prepared.args.thread != null) {
264
+ throw new UnsupportedFunctionalityError({
265
+ functionality: 'message threads in batches',
266
+ message: `Anthropic Message Batches do not support message threads (request "${request.id}").`,
267
+ });
268
+ }
263
269
  if (prepared.usesJsonResponseTool) {
264
270
  throw new UnsupportedFunctionalityError({
265
271
  functionality: 'batch responseFormat JSON-tool fallback',
@@ -1126,10 +1132,12 @@ function anthropicCallerMetadata(
1126
1132
 
1127
1133
  function convertAnthropicMessageMetadata(response: AnthropicResponse) {
1128
1134
  const stopDetails = mapAnthropicStopDetails(response.stop_details);
1135
+ const serviceTier = response.usage.service_tier ?? response.service_tier;
1129
1136
 
1130
1137
  return {
1131
1138
  usage: response.usage as JSONObject,
1132
1139
  stopSequence: response.stop_sequence ?? null,
1140
+ ...(serviceTier != null ? { serviceTier } : {}),
1133
1141
  ...(stopDetails != null ? { stopDetails } : {}),
1134
1142
  ...(response.input_transformations != null
1135
1143
  ? { inputTransformations: response.input_transformations }
@@ -13,6 +13,13 @@ export const anthropicErrorDataSchema = lazySchema(() =>
13
13
  error: z.object({
14
14
  type: z.string(),
15
15
  message: z.string(),
16
+ details: z
17
+ .object({
18
+ error_code: z.string().nullish().catch(undefined),
19
+ unsupported: z.array(z.string()).nullish().catch(undefined),
20
+ })
21
+ .nullish()
22
+ .catch(undefined),
16
23
  }),
17
24
  }),
18
25
  ),
@@ -111,18 +111,44 @@ export const anthropicSystemMessageProviderOptions = lazySchema(() =>
111
111
  * initial system prompt). A system message carrying tool changes must come
112
112
  * right before an assistant message or at the end of the messages.
113
113
  *
114
- * Tools referenced by a `tool_addition` must be declared in the `tools`
115
- * option (typically with `deferLoading: true` so they are not loaded until
116
- * the addition surfaces them). The required
117
- * `mid-conversation-tool-changes-2026-07-01` beta is added automatically.
114
+ * A `tool_addition` either references a tool by `toolName` or defines it
115
+ * by value with `tool`:
116
+ * - By reference: the tool must be declared in the `tools` option
117
+ * (typically with `deferLoading: true` so it is not loaded until the
118
+ * addition surfaces it). The required
119
+ * `mid-conversation-tool-changes-2026-07-01` beta is added
120
+ * automatically.
121
+ * - By value: `tool` is a function or provider tool, in the same shape as
122
+ * an entry of the `tools` option. The tool does not need to be declared
123
+ * in `tools`, and defining a tool under an existing name replaces it
124
+ * from that point on. The required `inline-tools-2026-09-15` beta is
125
+ * added automatically.
126
+ *
127
+ * A `tool_removal` always references the tool by `toolName`.
118
128
  */
119
129
  toolChanges: z
120
130
  .array(
121
- z.discriminatedUnion('type', [
131
+ z.union([
122
132
  z.object({
123
133
  type: z.literal('tool_addition'),
124
134
  toolName: z.string(),
125
135
  }),
136
+ z.object({
137
+ type: z.literal('tool_addition'),
138
+ tool: z.union([
139
+ z.looseObject({
140
+ type: z.literal('function'),
141
+ name: z.string(),
142
+ inputSchema: z.record(z.string(), z.unknown()),
143
+ }),
144
+ z.looseObject({
145
+ type: z.literal('provider'),
146
+ id: z.string(),
147
+ name: z.string(),
148
+ args: z.record(z.string(), z.unknown()),
149
+ }),
150
+ ]),
151
+ }),
126
152
  z.object({
127
153
  type: z.literal('tool_removal'),
128
154
  toolName: z.string(),
@@ -141,6 +167,21 @@ export type AnthropicSystemMessageProviderOptions = InferSchema<
141
167
  export const anthropicLanguageModelOptions = lazySchema(() =>
142
168
  zodSchema(
143
169
  z.object({
170
+ /**
171
+ * Create or continue a short-lived server-side message thread.
172
+ * On continuation, messages must contain only new messages. Keep the full
173
+ * conversation locally so it can be replayed when the thread expires.
174
+ */
175
+ thread: z
176
+ .discriminatedUnion('type', [
177
+ z.object({ type: z.literal('create') }),
178
+ z.object({
179
+ type: z.literal('continue'),
180
+ previousMessageId: z.string().min(1),
181
+ }),
182
+ ])
183
+ .optional(),
184
+
144
185
  /**
145
186
  * Whether to send reasoning to the model.
146
187
  *
@@ -159,6 +200,9 @@ export const anthropicLanguageModelOptions = lazySchema(() =>
159
200
  .enum(['outputFormat', 'jsonTool', 'auto'])
160
201
  .optional(),
161
202
 
203
+ /** Emit typed streaming heartbeat parts. Disabled by default. */
204
+ includePings: z.boolean().optional(),
205
+
162
206
  /**
163
207
  * Configuration for enabling Claude's extended thinking.
164
208
  *
@@ -344,8 +388,14 @@ export const anthropicLanguageModelOptions = lazySchema(() =>
344
388
  */
345
389
  speed: z.enum(['fast', 'standard']).optional(),
346
390
 
347
- /** Selects Anthropic's service tier for the request. */
348
- serviceTier: z.enum(['auto', 'standard_only']).optional(),
391
+ /**
392
+ * Request admission tier. Anthropic accepts `auto` and `standard_only`;
393
+ * MiniMax accepts `standard` and `priority`. Values for another known
394
+ * provider are omitted with an unsupported-setting warning.
395
+ */
396
+ serviceTier: z
397
+ .enum(['auto', 'standard_only', 'standard', 'priority'])
398
+ .optional(),
349
399
 
350
400
  /**
351
401
  * Controls where model inference runs for this request.