@ai-sdk/anthropic 4.0.96 → 4.0.97

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.97
4
+
5
+ ### Patch Changes
6
+
7
+ - fd7e8a7: Preserve the order of text and complete function calls in streamed Google responses, including standalone thought signatures on empty text or reasoning parts.
8
+
9
+ Keep provider metadata on empty text parts when converting results to response messages so it can be passed back in subsequent requests.
10
+
11
+ Omit foreign-provider empty signature text when replaying history through Anthropic or Bedrock, preserving Bedrock’s existing native reasoning-history handling.
12
+
13
+ - 8291ccf: Add MiniMax `serviceTier` support for `standard` and `priority` admission. Omit tiers belonging to another known provider with an unsupported-setting warning instead of forwarding incompatible values. Expose the applied `serviceTier`, when returned, in Anthropic-compatible generation, stream and batch metadata without changing existing metadata construction types.
14
+ - 9754014: Add typed streaming heartbeat parts. Anthropic emits them only with `includePings: true` (disabled by default), without requiring raw chunks. Core forwards pings through stream retries without storing them as generated content or sending them to UI message streams. Consumers with exhaustive stream-part switches must handle the new `ping` union variant when upgrading, even when the opt-in is disabled. Typed pings do not flush partial words during stream smoothing.
15
+ - 4b8f00e: Add a `supportsNativeStructuredOutput` opt-in to the Vertex Anthropic provider so `auto` can use native structured output for Claude 4.5 and newer when enabled by Google Cloud policy. Keep tool emulation as the default and avoid adding the structured-output beta header for providers without strict tool support.
16
+ - 8b11ff6: Support deleting files, retrieving metadata, and streaming downloads of generated files through the Anthropic Files API. Metadata reads and uploads expose consistent media type, size, creation time, expiration, and provider metadata when available. Downloads preserve Anthropic’s restriction to files generated by tools or skills.
17
+ - Updated dependencies [36802d4]
18
+ - Updated dependencies [e0143b0]
19
+ - Updated dependencies [934100c]
20
+ - Updated dependencies [892af4d]
21
+ - Updated dependencies [89aff56]
22
+ - Updated dependencies [41465fd]
23
+ - Updated dependencies [9754014]
24
+ - Updated dependencies [4bb73b0]
25
+ - Updated dependencies [2e44144]
26
+ - @ai-sdk/provider@4.0.36
27
+ - @ai-sdk/provider-utils@5.0.75
28
+
3
29
  ## 4.0.96
4
30
 
5
31
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -280,6 +280,7 @@ declare const anthropicResponseSchema: import("@ai-sdk/provider-utils").LazySche
280
280
  [x: string]: unknown;
281
281
  input_tokens: number;
282
282
  output_tokens: number;
283
+ service_tier?: string | null | undefined;
283
284
  output_tokens_details?: {
284
285
  thinking_tokens?: number | null | undefined;
285
286
  } | null | undefined;
@@ -298,6 +299,7 @@ declare const anthropicResponseSchema: import("@ai-sdk/provider-utils").LazySche
298
299
  model?: string | null | undefined;
299
300
  stop_reason?: string | null | undefined;
300
301
  stop_sequence?: string | null | undefined;
302
+ service_tier?: string | null | undefined;
301
303
  stop_details?: {
302
304
  type: string;
303
305
  category?: string | null | undefined;
@@ -391,6 +393,8 @@ type AnthropicUsageIteration = {
391
393
  interface AnthropicMessageMetadata {
392
394
  usage: JSONObject;
393
395
  stopSequence: string | null;
396
+ /** The tier used by the provider, when returned in the response. */
397
+ serviceTier?: string | null;
394
398
  /**
395
399
  * Input blocks that Anthropic transformed before inference. This is
396
400
  * populated when thinking binding controls drop a mismatched thinking block.
@@ -586,6 +590,7 @@ type AnthropicSystemMessageProviderOptions = InferSchema<typeof anthropicSystemM
586
590
  declare const anthropicLanguageModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
587
591
  sendReasoning?: boolean | undefined;
588
592
  structuredOutputMode?: "outputFormat" | "jsonTool" | "auto" | undefined;
593
+ includePings?: boolean | undefined;
589
594
  thinking?: {
590
595
  type: "adaptive";
591
596
  display?: "omitted" | "summarized" | "updates" | undefined;
@@ -643,7 +648,7 @@ declare const anthropicLanguageModelOptions: import("@ai-sdk/provider-utils").La
643
648
  remaining?: number | undefined;
644
649
  } | undefined;
645
650
  speed?: "fast" | "standard" | undefined;
646
- serviceTier?: "auto" | "standard_only" | undefined;
651
+ serviceTier?: "auto" | "standard" | "standard_only" | "priority" | undefined;
647
652
  inferenceGeo?: "us" | "global" | undefined;
648
653
  fallbacks?: "default" | {
649
654
  model: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member","DecisionModelV4","BatchV4"],"sources":["../src/anthropic-api.ts","../src/anthropic-message-metadata.ts","../src/anthropic-provider-metadata.ts","../src/anthropic-language-model-options.ts","../src/anthropic-prepare-tools.ts","../src/tool/computer-toolset_20260801.ts","../src/tool/bash_20241022.ts","../src/tool/bash_20250124.ts","../src/anthropic-tools.ts","../src/anthropic-provider.ts","../src/forward-anthropic-container-id-from-last-step.ts","../src/version.ts"],"mappings":";;;;cAmsBM,sCAA8B,EAAA;;;;;;;;;;GAgBhC,EAAA,KAAA;KAEQ,2BAA2B,EAAE,MACvC,kBAAkB;cA2FP,0DAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgwBxB,WAAW,aACpB,mBAAmB;EAClB;;;;;;;;;;;;;;;;;;;KCjiDQ;EACV;;;;;;EAOA;;;;EAKA;;;;EAKA;;;;EAKA;;;;EAKA;;UAGe;EACf,OAAO;EACP;;;;;;;EAQA,uBAAuB;IACrB;IACA;IACA;;;;;;;;;;;;;EAcF,mBAAmB;;;;;;;;;;EAWnB;;;;;IAKE;;;;;IAMA;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A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQP;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAJlB;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAHxB;MACA;MAEa;MACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UCFJ,0BAA0B;;;;GAIxC,SAAS,mBAAmB;;;;EAK7B,cAAc,SAAS,mBAAmB;EAE1C,KAAK,SAAS,mBAAmB;EAEjC,SAAS,SAAS,mBAAmB;;EAGrC,cAAc,SAAS,mBAAmBE;;EAE1C,gBAAgB,SAAS,mBAAmBA;IAC1C,YAAYA;;EAGd,sBAAsBC;IAAU,MAAM;;;;;EAKtC,mBAAmB;EAEnB,SAAS;;;;EAKT,UAAU;;;;EAKV,cAAc;;UAGC;;EAEf;;IAEE;;;;;;EAOF;;;;;;EAOA;;;;;;;EAQA,YAAY;;;;EAKZ,UAAU;;;;;EAMV,QAAQ;EAER;;;;;EAMA;;;;;wBAMc,gBACd,UAAS,4BACR;;;;qBAsIU,WAAS;;;;;;;;;;wBCtQN,0CACd;EAEA,OAAO;IACL,mBAAmB,eAAe;;;EAEpB,kBAAkB,eAAe;;;;qBCdtC"}
1
+ {"version":3,"file":"index.d.ts","names":["SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member","DecisionModelV4","BatchV4"],"sources":["../src/anthropic-api.ts","../src/anthropic-message-metadata.ts","../src/anthropic-provider-metadata.ts","../src/anthropic-language-model-options.ts","../src/anthropic-prepare-tools.ts","../src/tool/computer-toolset_20260801.ts","../src/tool/bash_20241022.ts","../src/tool/bash_20250124.ts","../src/anthropic-tools.ts","../src/anthropic-provider.ts","../src/for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AAS,mBAAmB;EAE1C,KAAK,SAAS,mBAAmB;EAEjC,SAAS,SAAS,mBAAmB;;EAGrC,cAAc,SAAS,mBAAmBE;;EAE1C,gBAAgB,SAAS,mBAAmBA;IAC1C,YAAYA;;EAGd,sBAAsBC;IAAU,MAAM;;;;;EAKtC,mBAAmB;EAEnB,SAAS;;;;EAKT,UAAU;;;;EAKV,cAAc;;UAGC;;EAEf;;IAEE;;;;;;EAOF;;;;;;EAOA;;;;;;;EAQA,YAAY;;;;EAKZ,UAAU;;;;;EAMV,QAAQ;EAER;;;;;EAMA;;;;;wBAMc,gBACd,UAAS,4BACR;;;;qBAsIU,WAAS;;;;;;;;;;wBCtQN,0CACd;EAEA,OAAO;IACL,mBAAmB,eAAe;;;EAEpB,kBAAkB,eAAe;;;;qBCdtC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APICallError, InvalidArgumentError, InvalidResponseDataError, NoSuchModelError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
2
- import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, normalizeHeaders, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, stringifyWithBigIntAndCycles, validateBaseURL, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
2
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, normalizeHeaders, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, stringifyWithBigIntAndCycles, validateBaseURL, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
3
3
  import { Experimental_DecisionLanguageModel } from "@ai-sdk/provider-utils/experimental-decision";
4
4
  import { z } from "zod/v4";
5
5
  //#region src/anthropic-error.ts
@@ -15,16 +15,23 @@ const anthropicFailedResponseHandler = createJsonErrorResponseHandler({
15
15
  errorToMessage: (data) => data.error.message
16
16
  });
17
17
  //#endregion
18
- //#region src/anthropic-files.ts
18
+ //#region src/files/anthropic-files-api.ts
19
19
  const anthropicUploadFileResponseSchema = lazySchema(() => zodSchema(z.object({
20
20
  id: z.string(),
21
- type: z.literal("file"),
22
- filename: z.string(),
23
- mime_type: z.string(),
24
- size_bytes: z.number(),
25
- created_at: z.string(),
26
- downloadable: z.boolean().nullish()
21
+ type: z.literal("file").nullish(),
22
+ filename: z.string().nullish(),
23
+ mime_type: z.string().nullish(),
24
+ size_bytes: z.number().nullish(),
25
+ created_at: z.string().nullish(),
26
+ downloadable: z.boolean().nullish(),
27
+ expires_at: z.string().nullish()
28
+ })));
29
+ const anthropicDeleteFileResponseSchema = lazySchema(() => zodSchema(z.object({
30
+ type: z.literal("file_deleted").nullish(),
31
+ id: z.string()
27
32
  })));
33
+ //#endregion
34
+ //#region src/files/anthropic-files.ts
28
35
  var AnthropicFiles = class {
29
36
  get provider() {
30
37
  return this.config.provider;
@@ -33,6 +40,17 @@ var AnthropicFiles = class {
33
40
  this.config = config;
34
41
  this.specificationVersion = "v4";
35
42
  }
43
+ getFileId(file) {
44
+ const fileId = file.anthropic;
45
+ if (fileId == null || fileId.trim() === "") throw new InvalidArgumentError({
46
+ argument: "file",
47
+ message: "file reference is missing an 'anthropic' file id."
48
+ });
49
+ return fileId;
50
+ }
51
+ async getHeaders(headers) {
52
+ return combineHeaders(await resolve(this.config.headers), { "anthropic-beta": "files-api-2025-04-14" }, headers);
53
+ }
36
54
  async uploadFile({ data, mediaType, filename, abortSignal, headers }) {
37
55
  const fileBytes = convertInlineFileDataToUint8Array(data);
38
56
  const blob = new Blob([fileBytes], { type: mediaType });
@@ -41,7 +59,7 @@ var AnthropicFiles = class {
41
59
  else formData.append("file", blob);
42
60
  const { value: response } = await postFormDataToApi({
43
61
  url: `${this.config.baseURL}/files`,
44
- headers: combineHeaders(await resolve(this.config.headers), { "anthropic-beta": "files-api-2025-04-14" }, headers),
62
+ headers: await this.getHeaders(headers),
45
63
  formData,
46
64
  failedResponseHandler: anthropicFailedResponseHandler,
47
65
  successfulResponseHandler: createJsonResponseHandler(anthropicUploadFileResponseSchema),
@@ -53,13 +71,76 @@ var AnthropicFiles = class {
53
71
  providerReference: { anthropic: response.id },
54
72
  mediaType: response.mime_type ?? mediaType,
55
73
  filename: response.filename ?? filename,
56
- providerMetadata: { anthropic: {
57
- filename: response.filename,
58
- mimeType: response.mime_type,
59
- sizeBytes: response.size_bytes,
60
- createdAt: response.created_at,
61
- ...response.downloadable != null ? { downloadable: response.downloadable } : {}
62
- } }
74
+ byteSize: response.size_bytes ?? void 0,
75
+ createdAt: response.created_at != null ? new Date(response.created_at) : void 0,
76
+ expiresAt: response.expires_at != null ? new Date(response.expires_at) : void 0,
77
+ providerMetadata: { anthropic: this.toFileMetadata(response) }
78
+ };
79
+ }
80
+ async deleteFile({ file, abortSignal, headers }) {
81
+ const fileId = this.getFileId(file);
82
+ const { value: response } = await deleteFromApi({
83
+ url: `${this.config.baseURL}/files/${encodePathSegment(fileId)}`,
84
+ headers: await this.getHeaders(headers),
85
+ abortSignal,
86
+ fetch: this.config.fetch,
87
+ failedResponseHandler: anthropicFailedResponseHandler,
88
+ successfulResponseHandler: createJsonResponseHandler(anthropicDeleteFileResponseSchema)
89
+ });
90
+ return {
91
+ warnings: [],
92
+ providerReference: { anthropic: response.id },
93
+ deleted: true
94
+ };
95
+ }
96
+ async getFileMetadata({ file, abortSignal, headers }) {
97
+ const fileId = this.getFileId(file);
98
+ const { value: response } = await getFromApi({
99
+ url: `${this.config.baseURL}/files/${encodePathSegment(fileId)}`,
100
+ headers: await this.getHeaders(headers),
101
+ abortSignal,
102
+ fetch: this.config.fetch,
103
+ failedResponseHandler: anthropicFailedResponseHandler,
104
+ successfulResponseHandler: createJsonResponseHandler(anthropicUploadFileResponseSchema),
105
+ validateUrl: false
106
+ });
107
+ return {
108
+ warnings: [],
109
+ providerReference: { anthropic: response.id },
110
+ filename: response.filename ?? void 0,
111
+ mediaType: response.mime_type ?? void 0,
112
+ byteSize: response.size_bytes ?? void 0,
113
+ createdAt: response.created_at != null ? new Date(response.created_at) : void 0,
114
+ expiresAt: response.expires_at != null ? new Date(response.expires_at) : void 0,
115
+ providerMetadata: { anthropic: this.toFileMetadata(response) }
116
+ };
117
+ }
118
+ toFileMetadata(response) {
119
+ return {
120
+ ...response.filename != null ? { filename: response.filename } : {},
121
+ ...response.mime_type != null ? { mimeType: response.mime_type } : {},
122
+ ...response.size_bytes != null ? { sizeBytes: response.size_bytes } : {},
123
+ ...response.created_at != null ? { createdAt: response.created_at } : {},
124
+ ...response.downloadable != null ? { downloadable: response.downloadable } : {},
125
+ ...response.expires_at != null ? { expiresAt: response.expires_at } : {}
126
+ };
127
+ }
128
+ async downloadFile({ file, abortSignal, headers }) {
129
+ const fileId = this.getFileId(file);
130
+ const { value: content, responseHeaders } = await getFromApi({
131
+ url: `${this.config.baseURL}/files/${encodePathSegment(fileId)}/content`,
132
+ headers: await this.getHeaders(headers),
133
+ abortSignal,
134
+ fetch: this.config.fetch,
135
+ failedResponseHandler: anthropicFailedResponseHandler,
136
+ successfulResponseHandler: createBinaryStreamResponseHandler(),
137
+ validateUrl: false
138
+ });
139
+ const mediaType = responseHeaders?.["content-type"]?.split(";")[0].trim();
140
+ return {
141
+ warnings: [],
142
+ content,
143
+ ...mediaType ? { mediaType } : {}
63
144
  };
64
145
  }
65
146
  };
@@ -71,6 +152,7 @@ var AnthropicFiles = class {
71
152
  */
72
153
  const anthropicProviderOptions = { language: {
73
154
  sendReasoning: { description: "Whether to send reasoning to the model." },
155
+ includePings: { description: "Include transient ping events in streams." },
74
156
  structuredOutputMode: { description: "How structured outputs are generated." },
75
157
  thinking: { description: "Extended thinking configuration." },
76
158
  disableParallelToolUse: { description: "Use at most one tool per response." },
@@ -346,6 +428,7 @@ function createAnthropicLanguageModelEntry(modelId, documented) {
346
428
  compaction: documented?.compaction ?? "unknown"
347
429
  } },
348
430
  providerOptions: { language: declareProviderOptions(anthropicProviderOptions.language, declared ? true : "unknown", {
431
+ includePings: true,
349
432
  thinking: reasoningSupport,
350
433
  effort: documented?.effort ?? "unknown",
351
434
  speed: declared ? modelId === "claude-opus-4-6" : "unknown",
@@ -722,10 +805,12 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
722
805
  ])),
723
806
  stop_reason: z.string().nullish(),
724
807
  stop_sequence: z.string().nullish(),
808
+ service_tier: z.string().nullish(),
725
809
  stop_details: anthropicStopDetailsSchema().nullish(),
726
810
  input_transformations: z.array(anthropicInputTransformationSchema()).nullish(),
727
811
  safeguard_results: z.array(anthropicSafeguardResultSchema()).nullish(),
728
812
  usage: z.looseObject({
813
+ service_tier: z.string().nullish(),
729
814
  input_tokens: z.number(),
730
815
  output_tokens: z.number(),
731
816
  output_tokens_details: z.object({ thinking_tokens: z.number().nullish() }).nullish(),
@@ -775,7 +860,9 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
775
860
  id: z.string().nullish(),
776
861
  model: z.string().nullish(),
777
862
  role: z.string().nullish(),
863
+ service_tier: z.string().nullish(),
778
864
  usage: z.looseObject({
865
+ service_tier: z.string().nullish(),
779
866
  input_tokens: z.number(),
780
867
  cache_creation_input_tokens: z.number().nullish(),
781
868
  cache_read_input_tokens: z.number().nullish()
@@ -1064,6 +1151,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
1064
1151
  }).nullish()
1065
1152
  }),
1066
1153
  usage: z.looseObject({
1154
+ service_tier: z.string().nullish(),
1067
1155
  input_tokens: z.number().nullish(),
1068
1156
  output_tokens: z.number(),
1069
1157
  output_tokens_details: z.object({ thinking_tokens: z.number().nullish() }).nullish(),
@@ -1204,6 +1292,8 @@ const anthropicLanguageModelOptions = lazySchema(() => zodSchema(z.object({
1204
1292
  "jsonTool",
1205
1293
  "auto"
1206
1294
  ]).optional(),
1295
+ /** Emit typed streaming heartbeat parts. Disabled by default. */
1296
+ includePings: z.boolean().optional(),
1207
1297
  /**
1208
1298
  * Configuration for enabling Claude's extended thinking.
1209
1299
  *
@@ -1353,8 +1443,17 @@ userId: z.string().optional() }).optional(),
1353
1443
  * Only supported with claude-opus-4-6.
1354
1444
  */
1355
1445
  speed: z.enum(["fast", "standard"]).optional(),
1356
- /** Selects Anthropic's service tier for the request. */
1357
- serviceTier: z.enum(["auto", "standard_only"]).optional(),
1446
+ /**
1447
+ * Request admission tier. Anthropic accepts `auto` and `standard_only`;
1448
+ * MiniMax accepts `standard` and `priority`. Values for another known
1449
+ * provider are omitted with an unsupported-setting warning.
1450
+ */
1451
+ serviceTier: z.enum([
1452
+ "auto",
1453
+ "standard_only",
1454
+ "standard",
1455
+ "priority"
1456
+ ]).optional(),
1358
1457
  /**
1359
1458
  * Controls where model inference runs for this request.
1360
1459
  *
@@ -1864,7 +1963,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
1864
1963
  ...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
1865
1964
  ...tool.inputExamples != null ? { input_examples: tool.inputExamples.map((example) => example.input) } : {}
1866
1965
  });
1867
- if (supportsStructuredOutput === true) betas.add("structured-outputs-2025-11-13");
1966
+ if (supportsStructuredOutput === true && supportsStrictTools === true) betas.add("structured-outputs-2025-11-13");
1868
1967
  if (tool.inputExamples != null || allowedCallers != null) betas.add("advanced-tool-use-2025-11-20");
1869
1968
  break;
1870
1969
  }
@@ -2995,7 +3094,7 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
2995
3094
  for (let j = 0; j < block.messages.length; j++) {
2996
3095
  const message = block.messages[j];
2997
3096
  const isLastMessage = j === block.messages.length - 1;
2998
- const { content } = message;
3097
+ const content = message.content.filter((part) => part.type !== "text" || part.text.length > 0);
2999
3098
  for (let k = 0; k < content.length; k++) {
3000
3099
  const part = content[k];
3001
3100
  const isLastContentPart = k === content.length - 1;
@@ -4121,6 +4220,17 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4121
4220
  }) : null;
4122
4221
  const usedCustomProviderKey = customProviderOptions != null;
4123
4222
  const anthropicOptions = Object.assign({}, canonicalOptions ?? {}, customProviderOptions ?? {});
4223
+ if (anthropicOptions.serviceTier != null) {
4224
+ const supportedTiers = providerOptionsName === "anthropic" ? ["auto", "standard_only"] : providerOptionsName === "minimax" ? ["standard", "priority"] : void 0;
4225
+ if (supportedTiers != null && !supportedTiers.includes(anthropicOptions.serviceTier)) {
4226
+ warnings.push({
4227
+ type: "unsupported",
4228
+ feature: "serviceTier",
4229
+ details: `serviceTier "${anthropicOptions.serviceTier}" is not supported by ${providerOptionsName}. Use ${supportedTiers.map((tier) => `"${tier}"`).join(" or ")}.`
4230
+ });
4231
+ anthropicOptions.serviceTier = void 0;
4232
+ }
4233
+ }
4124
4234
  const { maxOutputTokens: maxOutputTokensForModel, supportsStructuredOutput: modelSupportsStructuredOutput, supportsAdaptiveThinking, rejectsSamplingParameters, supportsXhighEffort, rejectsThinkingDisabledAboveHighEffort, rejectsThinkingDisabled, rejectsBudgetThinking, rejectsForcedToolUse, supportsBetweenToolsThinking, isKnownModel } = getAnthropicModelCapabilities(modelId);
4125
4235
  if (!isKnownModel && maxOutputTokens == null) warnings.push({
4126
4236
  type: "compatibility",
@@ -4496,6 +4606,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4496
4606
  ...anthropicOptions?.anthropicBeta ?? []
4497
4607
  ]),
4498
4608
  usesJsonResponseTool: jsonResponseTool != null,
4609
+ includePings: stream === true && anthropicOptions?.includePings === true,
4499
4610
  toolNameMapping,
4500
4611
  providerOptionsName,
4501
4612
  usedCustomProviderKey
@@ -4929,9 +5040,11 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4929
5040
  warnings,
4930
5041
  providerMetadata: (() => {
4931
5042
  const stopDetails = mapAnthropicStopDetails$1(response.stop_details);
5043
+ const serviceTier = response.usage.service_tier ?? response.service_tier;
4932
5044
  const anthropicMetadata = {
4933
5045
  usage: response.usage,
4934
5046
  stopSequence: response.stop_sequence ?? null,
5047
+ ...serviceTier != null ? { serviceTier } : {},
4935
5048
  ...stopDetails != null ? { stopDetails } : {},
4936
5049
  ...response.input_transformations != null ? { inputTransformations: response.input_transformations } : {},
4937
5050
  ...response.safeguard_results != null ? { safeguardResults: response.safeguard_results } : {},
@@ -4963,7 +5076,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4963
5076
  async doStream(options) {
4964
5077
  "use step";
4965
5078
  const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
4966
- const { args: body, warnings, betas, usesJsonResponseTool, toolNameMapping, providerOptionsName, usedCustomProviderKey } = await this.getArgs({
5079
+ const { args: body, warnings, betas, usesJsonResponseTool, includePings, toolNameMapping, providerOptionsName, usedCustomProviderKey } = await this.getArgs({
4967
5080
  ...options,
4968
5081
  stream: true,
4969
5082
  userSuppliedBetas: this.getBetasFromHeaders(configHeaders, options.headers)
@@ -5002,6 +5115,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5002
5115
  let contextManagement = null;
5003
5116
  let rawUsage = void 0;
5004
5117
  let stopSequence = null;
5118
+ let serviceTier = null;
5005
5119
  let stopDetails = void 0;
5006
5120
  let inputTransformations;
5007
5121
  let safeguardResults;
@@ -5046,7 +5160,9 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5046
5160
  }
5047
5161
  const value = chunk.value;
5048
5162
  switch (value.type) {
5049
- case "ping": return;
5163
+ case "ping":
5164
+ if (includePings) controller.enqueue({ type: "ping" });
5165
+ return;
5050
5166
  case "content_block_start": {
5051
5167
  const part = value.content_block;
5052
5168
  const contentBlockType = part.type;
@@ -5610,6 +5726,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5610
5726
  });
5611
5727
  return;
5612
5728
  }
5729
+ serviceTier = value.message.usage.service_tier ?? value.message.service_tier ?? null;
5613
5730
  isMessageOpen = true;
5614
5731
  activeMessageId = value.message.id;
5615
5732
  heldBackTextByIndex.clear();
@@ -5701,6 +5818,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5701
5818
  if (value.context_management) contextManagement = mapAnthropicResponseContextManagement$1(value.context_management);
5702
5819
  if (value.input_transformations != null) inputTransformations = value.input_transformations;
5703
5820
  if (value.delta.safeguard_results != null) safeguardResults = value.delta.safeguard_results;
5821
+ serviceTier = value.usage.service_tier ?? serviceTier;
5704
5822
  rawUsage = {
5705
5823
  ...rawUsage,
5706
5824
  ...value.usage
@@ -5712,6 +5830,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5712
5830
  const anthropicMetadata = {
5713
5831
  usage: rawUsage ?? null,
5714
5832
  stopSequence,
5833
+ ...serviceTier != null ? { serviceTier } : {},
5715
5834
  ...stopDetails != null ? { stopDetails } : {},
5716
5835
  ...inputTransformations != null ? { inputTransformations } : {},
5717
5836
  ...safeguardResults != null ? { safeguardResults } : {},
@@ -5821,7 +5940,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5821
5940
  try {
5822
5941
  await firstChunkReader.read();
5823
5942
  let result = await firstChunkReader.read();
5824
- if (result.value?.type === "raw") result = await firstChunkReader.read();
5943
+ while (result.value?.type === "raw" || result.value?.type === "ping") result = await firstChunkReader.read();
5825
5944
  if (result.value?.type === "error") {
5826
5945
  const error = result.value.error;
5827
5946
  if (!isProviderStreamError(error)) throw new Error("Expected a normalized Anthropic stream error");
@@ -6614,9 +6733,11 @@ function anthropicCallerMetadata(caller) {
6614
6733
  }
6615
6734
  function convertAnthropicMessageMetadata(response) {
6616
6735
  const stopDetails = mapAnthropicStopDetails(response.stop_details);
6736
+ const serviceTier = response.usage.service_tier ?? response.service_tier;
6617
6737
  return {
6618
6738
  usage: response.usage,
6619
6739
  stopSequence: response.stop_sequence ?? null,
6740
+ ...serviceTier != null ? { serviceTier } : {},
6620
6741
  ...stopDetails != null ? { stopDetails } : {},
6621
6742
  ...response.input_transformations != null ? { inputTransformations: response.input_transformations } : {},
6622
6743
  ...response.safeguard_results != null ? { safeguardResults: response.safeguard_results } : {},
@@ -7349,7 +7470,7 @@ var AnthropicSkills = class {
7349
7470
  };
7350
7471
  //#endregion
7351
7472
  //#region src/version.ts
7352
- const VERSION = "4.0.96";
7473
+ const VERSION = "4.0.97";
7353
7474
  //#endregion
7354
7475
  //#region src/anthropic-provider.ts
7355
7476
  const ANTHROPIC_API_URL = "https://api.anthropic.com";