@ai-sdk/anthropic 4.0.0-beta.31 → 4.0.0-beta.33

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,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.33
4
+
5
+ ### Major Changes
6
+
7
+ - 832f86f: fix(anthropic): remove cacheCreationInputTokens from providerMetadata
8
+
9
+ ## 4.0.0-beta.32
10
+
11
+ ### Patch Changes
12
+
13
+ - ad0b376: fix(provider/anthropic): stop adding `fine-grained-tool-streaming-2025-05-14` beta for `claude-opus-4-7`
14
+
3
15
  ## 4.0.0-beta.31
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -21,7 +21,6 @@ interface AnthropicUsageIteration {
21
21
  }
22
22
  interface AnthropicMessageMetadata {
23
23
  usage: JSONObject;
24
- cacheCreationInputTokens: number | null;
25
24
  stopSequence: string | null;
26
25
  /**
27
26
  * Usage breakdown by iteration when compaction is triggered.
package/dist/index.js CHANGED
@@ -1003,10 +1003,11 @@ var anthropicLanguageModelOptions = z4.object({
1003
1003
  ).optional()
1004
1004
  }).optional(),
1005
1005
  /**
1006
- * Whether to enable tool streaming (and structured output streaming).
1007
- *
1008
- * When set to false, the model will return all tool calls and results
1009
- * at once after a delay.
1006
+ * Whether to enable fine-grained (eager) streaming of tool call inputs
1007
+ * and structured outputs for every function tool in the request. When
1008
+ * true (the default), each function tool receives a default of
1009
+ * `eager_input_streaming: true` unless it explicitly sets
1010
+ * `providerOptions.anthropic.eagerInputStreaming`.
1010
1011
  *
1011
1012
  * @default true
1012
1013
  */
@@ -1412,9 +1413,10 @@ async function prepareTools({
1412
1413
  disableParallelToolUse,
1413
1414
  cacheControlValidator,
1414
1415
  supportsStructuredOutput,
1415
- supportsStrictTools
1416
+ supportsStrictTools,
1417
+ defaultEagerInputStreaming = false
1416
1418
  }) {
1417
- var _a;
1419
+ var _a, _b;
1418
1420
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
1419
1421
  const toolWarnings = [];
1420
1422
  const betas = /* @__PURE__ */ new Set();
@@ -1431,7 +1433,7 @@ async function prepareTools({
1431
1433
  canCache: true
1432
1434
  });
1433
1435
  const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
1434
- const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1436
+ const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
1435
1437
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1436
1438
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1437
1439
  if (!supportsStrictTools && tool.strict != null) {
@@ -3453,9 +3455,7 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
3453
3455
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3454
3456
  betas.add("fast-mode-2026-02-01");
3455
3457
  }
3456
- if (stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true)) {
3457
- betas.add("fine-grained-tool-streaming-2025-05-14");
3458
- }
3458
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3459
3459
  const {
3460
3460
  tools: anthropicTools2,
3461
3461
  toolChoice: anthropicToolChoice,
@@ -3468,14 +3468,16 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
3468
3468
  disableParallelToolUse: true,
3469
3469
  cacheControlValidator,
3470
3470
  supportsStructuredOutput: false,
3471
- supportsStrictTools
3471
+ supportsStrictTools,
3472
+ defaultEagerInputStreaming
3472
3473
  } : {
3473
3474
  tools: tools != null ? tools : [],
3474
3475
  toolChoice,
3475
3476
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3476
3477
  cacheControlValidator,
3477
3478
  supportsStructuredOutput,
3478
- supportsStrictTools
3479
+ supportsStrictTools,
3480
+ defaultEagerInputStreaming
3479
3481
  }
3480
3482
  );
3481
3483
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3943,11 +3945,10 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
3943
3945
  },
3944
3946
  warnings,
3945
3947
  providerMetadata: (() => {
3946
- var _a2, _b2, _c2, _d2, _e2;
3948
+ var _a2, _b2, _c2, _d2;
3947
3949
  const anthropicMetadata = {
3948
3950
  usage: response.usage,
3949
- cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
3950
- stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
3951
+ stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
3951
3952
  iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
3952
3953
  type: iter.type,
3953
3954
  inputTokens: iter.input_tokens,
@@ -3956,15 +3957,15 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
3956
3957
  container: response.container ? {
3957
3958
  expiresAt: response.container.expires_at,
3958
3959
  id: response.container.id,
3959
- skills: (_d2 = (_c2 = response.container.skills) == null ? void 0 : _c2.map((skill) => ({
3960
+ skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
3960
3961
  type: skill.type,
3961
3962
  skillId: skill.skill_id,
3962
3963
  version: skill.version
3963
- }))) != null ? _d2 : null
3964
+ }))) != null ? _c2 : null
3964
3965
  } : null,
3965
- contextManagement: (_e2 = mapAnthropicResponseContextManagement(
3966
+ contextManagement: (_d2 = mapAnthropicResponseContextManagement(
3966
3967
  response.context_management
3967
- )) != null ? _e2 : null
3968
+ )) != null ? _d2 : null
3968
3969
  };
3969
3970
  const providerMetadata = {
3970
3971
  anthropic: anthropicMetadata
@@ -4026,7 +4027,6 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4026
4027
  const serverToolCalls = {};
4027
4028
  let contextManagement = null;
4028
4029
  let rawUsage = void 0;
4029
- let cacheCreationInputTokens = null;
4030
4030
  let stopSequence = null;
4031
4031
  let container = null;
4032
4032
  let isJsonResponseFromTool = false;
@@ -4038,7 +4038,7 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4038
4038
  controller.enqueue({ type: "stream-start", warnings });
4039
4039
  },
4040
4040
  transform(chunk, controller) {
4041
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4041
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
4042
4042
  if (options.includeRawChunks) {
4043
4043
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
4044
4044
  }
@@ -4573,7 +4573,6 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4573
4573
  rawUsage = {
4574
4574
  ...value.message.usage
4575
4575
  };
4576
- cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4577
4576
  if (value.message.container != null) {
4578
4577
  container = {
4579
4578
  expiresAt: value.message.container.expires_at,
@@ -4592,8 +4591,8 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4592
4591
  }
4593
4592
  controller.enqueue({
4594
4593
  type: "response-metadata",
4595
- id: (_h = value.message.id) != null ? _h : void 0,
4596
- modelId: (_i = value.message.model) != null ? _i : void 0
4594
+ id: (_g = value.message.id) != null ? _g : void 0,
4595
+ modelId: (_h = value.message.model) != null ? _h : void 0
4597
4596
  });
4598
4597
  if (value.message.content != null) {
4599
4598
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4609,7 +4608,7 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4609
4608
  id: part.id,
4610
4609
  toolName: part.name
4611
4610
  });
4612
- const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4611
+ const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4613
4612
  controller.enqueue({
4614
4613
  type: "tool-input-delta",
4615
4614
  id: part.id,
@@ -4647,7 +4646,6 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4647
4646
  }
4648
4647
  if (value.usage.cache_creation_input_tokens != null) {
4649
4648
  usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
4650
- cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
4651
4649
  }
4652
4650
  if (value.usage.iterations != null) {
4653
4651
  usage.iterations = value.usage.iterations;
@@ -4657,17 +4655,17 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4657
4655
  finishReason: value.delta.stop_reason,
4658
4656
  isJsonResponseFromTool
4659
4657
  }),
4660
- raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4658
+ raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4661
4659
  };
4662
- stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4660
+ stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4663
4661
  container = value.delta.container != null ? {
4664
4662
  expiresAt: value.delta.container.expires_at,
4665
4663
  id: value.delta.container.id,
4666
- skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4664
+ skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4667
4665
  type: skill.type,
4668
4666
  skillId: skill.skill_id,
4669
4667
  version: skill.version
4670
- }))) != null ? _n : null
4668
+ }))) != null ? _m : null
4671
4669
  } : null;
4672
4670
  if (value.context_management) {
4673
4671
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4683,7 +4681,6 @@ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
4683
4681
  case "message_stop": {
4684
4682
  const anthropicMetadata = {
4685
4683
  usage: rawUsage != null ? rawUsage : null,
4686
- cacheCreationInputTokens,
4687
4684
  stopSequence,
4688
4685
  iterations: usage.iterations ? usage.iterations.map((iter) => ({
4689
4686
  type: iter.type,
@@ -5572,7 +5569,7 @@ var AnthropicSkills = class {
5572
5569
  };
5573
5570
 
5574
5571
  // src/version.ts
5575
- var VERSION = true ? "4.0.0-beta.31" : "0.0.0-test";
5572
+ var VERSION = true ? "4.0.0-beta.33" : "0.0.0-test";
5576
5573
 
5577
5574
  // src/anthropic-provider.ts
5578
5575
  function createAnthropic(options = {}) {